Table of contents
Official Content
  • This documentation is valid for:

This API enables searches or queries on the indexed content. In this documentation, you will find detailed information on the available endpoints and how to interact with them. To manage settings associated with your RAG Assistants (for example, k, model, historyCount), read the RAG Assistants Section.

Check the generic variables needed to use the API.

The following endpoints require a Globant Enterprise AI API token related to project scope.

Endpoints

The Globant Enterprise AI Chat with documents API provides the following endpoints:

Method Path Description
POST /execute Executes a search query

POST/execute 

Executes a search query based on a specific profile and question.

Parameters

Parameter Type Description
id string Identifier for the conversation
profile string Profile to search
question string Question to ask
variables collection A list of key/value properties (optional)
filters collection List of filters to apply (optional)

For conversations with history, use the optional id element to refer to a particular conversation. These conversations will keep the History Count parameter from your RAG Assistants. If no id value is set, no history will be considered and your query will be treated as a one-off.

The variables parameter is used to fill in an associated prompt with values.

Filters

The filters parameter is used as a logical condition statement; check the detail here; these are predefined filters you can use.

Filter Description
id Document GUID returned during insertion
name Original document name
extension Original document extension
source Document source, in general, a URL

To use specific ones, remember to ingest documents with the correct metadata. A valid filters section is:

"filters": [
    {"key": "extension", "operator": "$ne", "value": "pdf"},
    {"key": "name", "operator": "$eq", "value": "sample"},
    {"key": "year", "operator": "$gte", "value": 2000} /* year added during ingestion */
]

Request Body

{
  "id": "string", /* optional */
  "profile": "string",
  "question": "string",
  "variables": [
    {"key": "string", "value": "string"},
    ...
  ],
  "filters": [
    {
      "key": "string",
      "operator": "string", /* Optional */
      "value": "string or number"
    },
    ...
  ]
}

Response

StatusCode 200 is displayed with Content-Type: application/json

{
  "documents": [ // optional: could not return elements when no information is present
    {
      "pageContent": "Example page content", // mandatory
      "score": 0.9, // optional
      "metadata": { // mandatory
        "source": "Example source", // optional
        "url": "Example source", // optional
        "description": "Example description", // optional
        "id": "12345", // mandatory
        "name": "Example document", // mandatory
        "extension": "doc", // mandatory
        "locationLinesFrom": 1, // optional
        "locationLinesTo": 10, // optional
        "locationLinesPageNumber": 1 // optional
      }
    }
  ],
  "id": "someId", // mandatory
  "requestId": "someId", // mandatory
  "text": "Example reply", // mandatory
  "result": { // mandatory
    "success": true, // mandatory
    "messages": [ // optional
      "Search query executed successfully"
    ]
  }
}

The returned score element (when available) measures the semantic similarity between the question and the associated pageContent; a value between 0 and 1 where 1 is closest.

You can use the requestId element to review the Request detail in the console.

StatusCode 200 is shown with Content-Type: application/json, when RAG Assistant does not exist or is disabled:

  "error": {
      "code": 1101,
      "message": "Search Index Profile Name not found"
  },
  "status": "failed",
  "success": false,
  "text": ""
}

Sample cURL Request

# Simple case
curl -X POST
  -H "Content-Type: application/json"
  -H "Authorization: $SAIA_PROJECT_APITOKEN"
  -d '{
  "profile": "Default",
  "question": "Explain to me what is SAIA?"
}' $BASE_URL/v1/search/execute
# Using variables and filters
curl -X POST
  -H "Content-Type: application/json"
  -H "Authorization: $SAIA_PROJECT_APITOKEN"
  -d '{
  "profile": "Default",
  "question": "Again, explain to me what is SAIA?",
  "variables": [
    {"key": "type","value": "Doc"}
  ],
  "filters": [
    {"key": "extension", "operator": "$ne", "value": "pdf"},
    {"key": "name", "operator": "$eq", "value": "sample"},
    {"key": "year", "operator": "$gte", "value": 2000}
  ]
}' $BASE_URL/v1/search/execute    
Last update: September 2024 | © GeneXus. All rights reserved. GeneXus Powered by Globant