This API allows you to define different RAG Assistants.
To use the API, check the generic variables needed.
In addition, read the explanation about parameters in RAG Assistants configuration.
The following endpoints require a Globant Enterprise AI API token related to project scope.
Below is a summary of the available endpoints for this API:
Method |
Path |
Description |
GET |
/profiles |
Gets all RAG assistans from a project |
GET |
/profile/{name} |
Gets a specific RAG assistant |
POST |
/profile |
Creates a new RAG assistant |
PUT |
/profile/{name} |
Updates a RAG assistant |
DELETE |
/profile/{name} |
Deletes a RAG assistant |
GET |
/profile/{name}/documents |
Gets documents for a RAG assistant |
DELETE |
/profile/{name}/documents |
Deletes all documents for a RAG assistant |
GET |
/profile/{name}/document/{id} |
Retrieves Document information |
POST |
/profile/{name}/document |
Uploads a Document |
DELETE |
/profile/{name}/document/{id} |
Deletes a Document |
POST |
/execute |
Executes a query against the defined RAG assistant |
Note: Keep in mind that the searchProfiles and {name} parameters refer to RAG Assistants. In addition, the {name} parameter, which represents the name of the RAG Assistants, must not contain blanks. Instead, they must be replaced by the + symbol.
Retrieves all the RAG Assistants for a Project.
{
"projectActive": "boolean",
"projectDescription": "string",
"projectId": "string",
"projectName": "string",
"projectStatus": "integer", /* 0:Active, 1:Deleted, 2:Hidden */
"searchProfiles": [
{
"description": "string",
"name": "string"
},
...
]
}
The description parameter is required for the chat option.
curl -X GET "$BASE_URL/v1/search/profiles" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "Accept: application/json"
Gets RAG Assistants {name} details.
{
"name": "string",
"description": "string",
"indexOptions": {
"chunks": {
"chunkOverlap": "integer",
"chunkSize": "integer"
}
},
"searchOptions": {
"historyCount": "integer",
"llm": {
"cache": "boolean",
"frequencyPenalty": "decimal",
"maxTokens": "integer",
"modelName": "string",
"n": "integer",
"presencePenalty": "decimal",
"provider": "string",
"stream": "boolean",
"temperature": "decimal",
"topP": "decimal",
"type": "string"
"verbose": "boolean"
},
"retriever": {
"type": "string" /* vectorStore, multiQuery, selfQuery, hyde, contextualCompression */
},
"search": {
"k": "integer",
"prompt": "string",
"returnSourceDocuments": "boolean",
"scoreThreshold": "decimal",
"template": "string"
}
},
"status": "integer" /* 1:Enabled, 2:Disabled */
}
The type parameter is explained in RAG Assistants - Configuration Retrieval.
curl -X GET "$BASE_URL/v1/search/profile/{name}" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json"
Creates a RAG Assistant.
Name |
Type |
Description |
name |
string |
RAG assistant name (required) |
descrition |
string |
Description of the RAG assistant |
template |
string |
Name of an existing RAG to base the configuration (optional), empty by default |
{
"name": "string", /* Required */
"description": "string",
"template": "string",
"searchOptions": {
"historyCount": "integer",
"llm": {
"cache": "boolean",
"frequencyPenalty": "decimal",
"maxTokens": "integer",
"modelName": "string",
"n": "integer",
"presencePenalty": "decimal",
"provider": "string",
"stream": "boolean",
"temperature": "decimal",
"topP": "decimal",
"type": "string", /* empty value (default) or json_object */
"verbose": "boolean"
},
"search": {
"k": "integer",
"type": "string", /* similarity (default) or mmr */
"fetchK": number, /* valid when using mmr type */
"lambda": decimal, /* valid when using mmr type */
"prompt": "string",
"returnSourceDocuments": "boolean",
"scoreThreshold": "decimal",
"template": "string"
},
"retriever": {
"type": "string", /* vectorStore, multiQuery, selfQuery, hyde, contextualCompression */
"searchType": "similarity | similarity_hybrid | semantic_hybrid" /* only valid for Azure AISearch, defaults to similarity */
"prompt": "string" /* not needed when using vectorStore */
}
},
"indexOptions": {
"chunks": {
"chunkOverlap": "integer",
"chunkSize": "integer"
},
"useParentDocument": "boolean", /* false by default */
"childDocument": { /* valid if the previous element is true */
"childK": decimal,
"child": {
"chunkSize": decimal,
"chunkOverlap": decimal
}
}
},
"welcomeData": {
"title": "string",
"description": "string",
"features": [
{
"title": "string",
"description": "string"
},
...
],
"examplesPrompt": [
{
"title": "string",
"description": "string",
"promptText": "string"
},
...
]
}
}
The LLM type option using json_object can be checked here.
Note: If you do not provide the WelcomeData section when creating a RAG Assistant, it will be empty.
Equivalent to Get Response.
curl -X POST "$BASE_URL/v1/search/profile" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json" \
-d '{
"name": "my RAG assistant",
"description": "My awesome profile",
"searchOptions": {
"historyCount": 2,
"llm": {
"temperature": 0.1,
"maxTokens": 1500,
"modelName": "gpt-3.5-turbo-16k"
},
"search": {
"k": 5
}
}
}'
curl -X POST "$BASE_URL/v1/search/profile" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json" \
-d '{
"name": "Test-Profile-WelcomeData",
"description": "Test Profile with WelcomeData",
"searchOptions": {
"historyCount": 2,
"llm": {
"cache": false,
"temperature": 0.1,
"maxTokens": 999,
"modelName": "gpt-3.5-turbo-16k",
"verbose": true
},
"search": {
"k": 5,
"returnSourceDocuments": false,
"scoreThreshold": 0,
"prompt": "Use {context} and {question}"
}
},
"indexOptions": {
"chunks": {
"chunkSize": 999,
"chunkOverlap": 99
}
},
"welcomeData": {
"title": "Welcome to the RAG",
"description": "It is a RAG created with WelcomeData via API",
"features": [
{
"title": "Weather conditions",
"description": "Obtain weather conditions in any country"
},
{
"title": "Rain probability",
"description": "Get the rain probability in any location"
}
],
"examplesPrompt": [
{
"title": "First Prompt Example",
"description": "First Prompt Example Description",
"promptText": "You are an assistant specializing in..."
}
]
}
}'
Updates a RAG Assistant.
Name |
Type |
Description |
name |
string |
RAG assistant name (required) |
Equivalent to Post Request, but the following elements are discarded:
- name element
- indexOptions section
In addition, status element can be specified by taking values:
If a RAG Assistants had WelcomeData and an update does not include this section, the existing information is deleted and becomes empty. Therefore, if you want to add new information to the WelcomeData, you must include both the old and the new information. If you only send the new one, it will completely replace the old one.
Equivalent to Get Response.
curl -X PUT "$BASE_URL/v1/search/profile/{name}" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json" \
-d '{
"description": "Updated RAG assistant",
"status": 1,
"searchOptions": {
"historyCount": 4,
"llm": {
"temperature": 0.5,
"maxTokens": 1000
},
"search": {
"k": 2,
"prompt": "You are an Assistant, only reply using the following context:\n{context}\n Question is: {question}\n",
"scoreThreshold": 0.2
}
}
}'
curl -X PUT "$BASE_URL/v1/search/profile/{name}" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json" \
-d '{
"name": "Test-Profile-WelcomeData",
"welcomeData": {
"title": "Welcome to RAG Update",
"description": "It is a RAG created with WelcomeData via API",
"features": [
{
"title": "Updated weather conditions",
"description": "Get the state of the weather in any country"
},
{
"title": "Rain probability updated",
"description": "Get the rain probability in any location"
}
],
"examplesPrompt": [
{
"title": "First Prompt Example",
"description": "First Prompt Example Description",
"promptText": "You are an assistant specializing in..."
}
]
}
}'
Deletes a RAG Assistant.
Name |
Type |
Description |
name |
string |
RAG assistant name (required) |
StatusCode 200 is shown when successfully deleted; otherwise, StatusCode 400* is shown with a collection of errors.
curl -X DELETE "$BASE_URL/v1/search/profile/{name}" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json"
Lists the documents for a RAG Assistant.
Name |
Type |
Description |
name |
string |
RAG assistant name |
skip |
integer |
Number of documents to skip |
count |
integer |
Number of documents to return (defaults to 10) |
{
"documents": [
{
"extension": "string",
"id": "string",
"name": "string",
"timestamp": "timestamp",
"url": "string",
"indexStatus": "string", /* Unknown, Starting, Failed, Pending, Success */
"indexDetail": "string"
},
...
],
"count": "integer" /* Total number of documents */
}
curl -X GET "$BASE_URL/v1/search/profile/{name}/documents" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json"
# Use the optional skip and count parameters
$BASE_URL/v1/search/profile/{name}/documents?skip={skip}&count={count}
Deletes all documents associated to the specified RAG assistant.
Name |
Type |
Description |
name |
string |
RAG assistant name (required) |
StatusCode 200 is shown when successfully deleted; otherwise, StatusCode 400* is shown with a collection of errors.
curl -X DELETE "$BASE_URL/v1/search/profile/{name}/documents" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json"
Using the {name} RAG Assistants, it gets details about the {id} document.
Name |
Type |
Description |
name |
string |
RAG assistant name (required) |
id |
string |
Document Id (required) |
{
"extension": "string",
"id": "string",
"indexStatus": "string", /* Unknown, Starting, Failed, Pending, Success */
"indexDetail": "string",
"keyName": "string",
"metadata": [
{
"key": "string",
"value": "string"
},
...
],
"name": "string",
"timestamp": "timestamp",
"url": "string"
}
For the Failed status, check the returned Index Detail field for further information.
Index Detail |
Description |
Invalid content |
The associated file does not have text content; the common case is a PDF file composed of images.
These files are not able to be used in a RAG Assistant. |
curl -X GET "$BASE_URL/v1/search/profile/{name}/document/{id}" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json"
Uploads a Document to the associated {name} RAG Assistants. Note that the file extension must be a supported one.
The supported options are binary or multipart/form-data including a File type.
It is useful for its simplicity and encodes the binary data directly in the request body. Set the request with the associated Content-Type header to indicate the type of data being sent (e.g., application/pdf, text/plain).
It is mandatory to set a filename header value with the document name and extension. For example:
filename: SampleFile.pdf
Note that this option does not enable to upload metadata.
This format allows you to include both binary data and other form fields in a single request. Each part of the data (binary file, text fields, etc.) is separated by a boundary and sent as separate parts. It is expected to be used for large files.
If you want to attach metadata to the file to be processed during ingestion, add a metadata form-data variable with the desired value; remember that the expected format is a key/value JSON list. For example, the following is a valid metadata for a Document:
{
"type": "test",
"domain": "Knowledge",
"year": 2023,
"quarter": "q3"
}
The metadata can be uploaded as Text or directly from a File.
Check for the following metadata special values
Item |
Description |
url |
If you want that the document point to a specific absolute URL, add a url metadata element poiting to the complete url resource. |
Equivalent to Get Response. Note that, once the document is uploaded, the indexStatus will be Unknown as it is queued to be ingested. Use the Get Response API to check the document status; the expected result is Success.
Possible return errors:
To upload a SampleFile.pdf file, you can follow these steps:
# binary
curl -X POST "$BASE_URL/v1/search/profile/{name}/document" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
--header 'filename: SampleFile.pdf' \
--header 'Content-Type: application/pdf' \
--data '@/C:/temp/SampleFile.pdf'
# multi-part
curl -X POST "$BASE_URL/v1/search/profile/{name}/document" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "Content-Type: multipart/form-data" \
--form 'file=@"/C:/temp/SampleFile.pdf"'
# multi-part with metadata as text
curl -X POST "$BASE_URL/v1/search/profile/{name}/document" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "Content-Type: multipart/form-data" \
--form 'metadata="{\"type\":\"test\",\"domain\":\"Knowledge\",\"year\":2023,\"quarter\":\"q3\"}"' \
--form 'file=@"/C:/temp/SampleFile.pdf"'
# multi-part with metadata as a File
curl -X POST "$BASE_URL/v1/search/profile/{name}/document" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "Content-Type: multipart/form-data" \
--form 'metadata=@"/C:/temp/upload_file_metadata.json"' \
--form 'file=@"/C:/temp/SampleFile.pdf"'
Deletes a Document.
Name |
Type |
Description |
name |
string |
RAG assistant name (required) |
id |
string |
Document Id (required) |
StatusCode 200 is shown when successfully deleted; otherwise, 400* is displayed with a collection of errors.
curl -X DELETE "$BASE_URL/v1/search/profile/{name}/document/{id}" \
-H "Authorization: Bearer $SAIA_PROJECT_APITOKEN" \
-H "accept: application/json"
Executes a search query. For more details, read Chat with Documents API.