Retrieval-augmented generation (RAG) - Fluid Topics - Latest

Fluid Topics API Reference Guide

Category
Reference Guides
Audience
public
Version
Latest

This web service allows users with the GENERATIVE_AI_USER role to query a chatbot-type large language model (LLM). The chatbot uses the content of the portal to give accurate answers with sources to users.

Method Endpoint
POST
/api/ai/rag/chat

Request example

The following code block is an example of JSON request body for the RAG API:

{
  "profileId": "chat",
  "query": "What is a drone?",
  "messages": [
    {
      "role": "assistant",
      "content": "Welcome! My name is Botty. How can I help you today?"
    }
  ],
  "metadataFilters": [
    {
      "key": "ft:locale",
      "valueFilter": {
        "values": [
          "en-US"
        ],
        "negative": false
      }
    }
  ]
}

The chat Generative AI profile contains the following prompt: "Your name is Botty and you are a helpful personal assistant. Answer questions in a friendly tone."

Field Type Required? Description
profileId String Yes A Generative AI profile ID of type Chatbot.
query String Yes The most recent user message.
messages Array No The history of messages between the bot and the user.
role String Yes One of user or assistant, in reference to who sent the message.
content String Yes The content of the message.
metadataFilters Array No Filters the results based on selected criteria including metadata and date ranges. Defaults to an empty list.
key String Yes Expects a metadata key.
valueFilter Object No Contains the filtering conditions based on metadata values.
values Array Yes Defines the value for the selected key. When multiple values are defined, they are combined with an AND or an OR operator depending on the tenant's configuration.
negative Boolean No When true, this parameter excludes results matching the previously defined values. By default, the negative parameter is implicit and false.
dateFilter Object No Specifies the date-based filtering conditions using predefined periods.
type String Yes Restricts results to those within a predefined period. Acceptable values are LAST_WEEK, LAST_MONTH, LAST_QUARTER, LAST_YEAR.
rangeFilter Object No Specifies custom date range filtering.
from String Yes The inclusive start date of the period. If unspecified, the default value is 1970-01-01.
to String Yes The inclusive end date of the period. If unspecified, the default value is the current day.

Response body

[
  {
    "id": "d1013b75-b3f8-4b51-813d-e63779497154"
  },
  {
    "message": "A"
  },
  {
    "message": " drone"
  },
  {
    "message": " is"
  },
  {
    "message": " an"
  },
  {
    "message": " unm"
  },
  {
    "message": "anned"
  },
  {
    "message": " aerial"
  },
  {
    "message": " vehicle"
  },
  {
    "message": " ("
  },
  {
    "message": "U"
  },
  {
    "message": "AV"
  },
  {
    "message": ")"
  },
  {
    "message": " that"
  },
  {
    "message": " can"
  },
  {
    "message": " be"
  },
  {
    "message": " remotely"
  },
  {
    "message": " controlled"
  },
  {
    "message": " or"
  },
  {
    "message": " fly"
  },
  {
    "message": " autonom"
  },
  {
    "message": "ously"
  },
  {
    "message": " using"
  },
  {
    "message": " software"
  },
  {
    "message": " and"
  },
  {
    "message": " sensors"
  },
  {
    "message": "."
  },
  {
    "message": " D"
  },
  {
    "message": "rones"
  },
  {
    "message": " are"
  },
  {
    "message": " used"
  },
  {
    "message": " for"
  },
  {
    "message": " various"
  },
  {
    "message": " applications"
  },
  {
    "message": ","
  },
  {
    "message": " including"
  },
  {
    "message": " aerial"
  },
  {
    "message": " photography"
  },
  {
    "message": ","
  },
  {
    "message": " surveillance"
  },
  {
    "message": ","
  },
  {
    "message": " delivery"
  },
  {
    "message": " services"
  },
  {
    "message": ","
  },
  {
    "message": " and"
  },
  {
    "message": " agricultural"
  },
  {
    "message": " monitoring"
  },
  {
    "message": "."
  },
  {
    "message": " They"
  },
  {
    "message": " come"
  },
  {
    "message": " in"
  },
  {
    "message": " various"
  },
  {
    "message": " sizes"
  },
  {
    "message": " and"
  },
  {
    "message": " designs"
  },
  {
    "message": ","
  },
  {
    "message": " depending"
  },
  {
    "message": " on"
  },
  {
    "message": " their"
  },
  {
    "message": " intended"
  },
  {
    "message": " use"
  },
  {
    "message": "."
  },
  {
    "message": " \n\n"
  },
  {
    "message": "*"
  },
  {
    "message": " See"
  },
  {
    "message": " also"
  },
  {
    "message": ":"
  },
  {
    "message": " ["
  },
  {
    "message": "Definitions"
  },
  {
    "message": "]("
  },
  {
    "message": "{tenantUrl}"
  },
  {
    "message": "/{path-to-documentation}"
  },
  {
    "message": ")"
  }
]

The message, once parsed, in Markdown format:

A drone is an unmanned aerial vehicle (UAV) that can be remotely controlled or fly autonomously using software and sensors. 
Drones are used for various applications, including aerial photography, surveillance, delivery services, and agricultural monitoring. 
They come in various sizes and designs, depending on their intended use.

* See also: [Definitions]({tenantUrl}/{path-to-documentation})
Field Type Description
id String The unique identifier for the chat.
message String A part of the answer from the large language model.
Return code Description
403 FORBIDDEN Invalid profile type COMPLETION, expected CHATBOT. The provided profile has the incorrect type.
404 NOT FOUND Profile with id Example not found. The profile with the given ID does not exist.

For a comprehensive list of all possible return codes, see Return codes.