Generic agentic 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 an AI-powered chatbot with agentic capabilities. The chatbot uses tools, the content of the portal, as well as reasoning, to give accurate answers with sources to users. The structure of the answer is based on a JSON schema defined in the Generic agent AI profile.

Method Endpoint
POST
/api/ai/agent/generate

Request example

The following example shows a JSON request body for this web service:

{
  "query": "value",
  "profileId": "generic_agent_profile_id",
  "conversationId": "c41dcf61-8ecb-49f7-a613-890264bbd746",
  "stream": true,
  "searchFilters": []
}
Field Type Required? Description
query String Yes The user's input.
profileId String Yes An AI profile ID.
This web service requires the use of a GENERIC_AGENT profile.
conversationId String Yes An ID for the conversation. Use a unique ID (for example, an UUID).
stickyFiltersId String No Filters the results based on the specified sticky filter set ID.
stream Boolean No Whether the response is streamed or not. Defaults to true.
searchFilters Array No Filters the results based on selected criteria including metadata and date ranges. Defaults to an empty list.
and Object No Combines filters requiring all conditions to be met.
or Object No Combines filters requiring any condition to be met.
not Object No Excludes results that match the specified condition.
key String No Expects a metadata key.
values Array No 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.
hierarchicalValues Array No Defines hierarchical values for the selected key.

Response body

The content type of the response is of type text/event-stream if stream is set to true. Otherwise the response type is application/json. The response conforms to the JSON schema defined in the Generic agent AI profile, and as such varies from profile to profile.

For example, the following schema orders the agent to identify metadata values applicable to the content, returning all possible options with confidence scores:

{
    "type": "object",
    "properties": {
        "category": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "value": { "enum": ["How to", "Reference guides", "Troubleshooting"] },
                    "confidence": { "type": "number", "minimum": 0, "maximum": 1 }
                },
                "required": ["value", "confidence"],
                "additionalProperties": false
            }
        },
        "subject": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "value": { "enum": ["AI", "Analytics", "API", "Authentication", "Content", "Design", "Integration", "Introduction", "Languages", "Network", "Search", "Users"] },
                    "confidence": { "type": "number", "minimum": 0, "maximum": 1 }
                },
                "required": ["value", "confidence"],
                "additionalProperties": false
            }
        },
        "language": {
            "type": "array",
            "items": {
                "type": "object",
                "properties": {
                    "value": { "enum": ["en", "fr", "de"] },
                    "confidence": { "type": "number", "minimum": 0, "maximum": 1 }
                },
                "required": ["value", "confidence"],
                "additionalProperties": false
            }
        }
    }
}

It is accompanied by this prompt:

For each metadata key, return confidence scores for all possible values defined in the schema. Sort by confidence score. Include every enum option, scoring each one even if confidence is low.

For this example, the agent is given the content of the Introduction to the Fluid Topics designer topic. The stream field was set to false, so the generic agent returns the following:

{
    "type": "response",
    "content": {
        "category": [
            {
                "value": "Reference guides",
                "confidence": 0.99
            },
            {
                "value": "How to",
                "confidence": 0.8
            },
            {
                "value": "Troubleshooting",
                "confidence": 0.01
            }
        ],
        "subject": [
            {
                "value": "Design",
                "confidence": 0.99
            },
            {
                "value": "Introduction",
                "confidence": 0.9
            },
            {
                "value": "Integration",
                "confidence": 0.7
            },
            {
                "value": "Users",
                "confidence": 0.5
            },
            {
                "value": "Search",
                "confidence": 0.3
            },
            {
                "value": "Content",
                "confidence": 0.2
            },
            {
                "value": "API",
                "confidence": 0.1
            },
            {
                "value": "Authentication",
                "confidence": 0.05
            },
            {
                "value": "AI",
                "confidence": 0.01
            },
            {
                "value": "Analytics",
                "confidence": 0.01
            },
            {
                "value": "Languages",
                "confidence": 0.01
            },
            {
                "value": "Network",
                "confidence": 0.01
            }
        ],
        "language": [
            {
                "value": "en",
                "confidence": 0.99
            },
            {
                "value": "fr",
                "confidence": 0.005
            },
            {
                "value": "de",
                "confidence": 0.005
            }
        ]
    },
    "run_id": "lc_run--01a0d8cc-3488-7492-b2de-cd5adc345352",
    "session_id": "2dc3ec4a-4680-4e3a-b577-ddd53412af2b"
}
Field Type Description
type String The response provided by the .
content Object Present in response events. An object containing what has been defined in the JSON schema.
run_id String The run identifier for this event.
session_id String The session identifier for this conversation.
Return code Description
200 OK The chatbot rating has been successfully sent.
400 BAD REQUEST Invalid JSON request body, or the requested action is impossible.

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