POST
/
library
/
{library_id}
/
query
Create a query
curl --request POST \
  --url https://api.libraria.ai/library/{library_id}/query \
  --header 'Authorization: Bearer <token>' \
  --header 'Content-Type: application/json' \
  --data '{
  "query": "<string>",
  "conversationId": {},
  "streaming": {}
}'
{
  "reply": "The capital of France is Paris.",
  "conversationId": "optional-unique-id",
  "metadata": {
      "documents": [
          {
  			"id": "some-document-id",
  			"title": "The france capital",
  			"similarity": 0.966698234468654,
  			"extraFields": {
  				"learnMoreLink": {
  					"url": "https://france-capital",
  					"text": "The France Capital"
  				}
  			}
  		},
      ],
      "images": [],
      "helpArticles": [
          {
              "url": "https://france-capital",
              "text": "The France Capital"
  		}
      ]
  }
}

Parameters

library_id
string
required
The ID of the library you are going to ask a question

Body

query
string
required
The question you will make to the library.
conversationId
string | null
Optional. Use this for a continuation of the conversation. You will receive a conversation id on the first query you send.
streaming
boolean | null
Optional. Whether or not you want to receive a streamed response. Default value is False.

Response

The response will vary according to the value of the streaming attribute.

Non-streamed response

When streaming is equal to false the response will be a JSON object containing the following fields
reply
string
required
The response from the library for the query provided in the request body
conversationId
string
required
Optional. Use this in follow-up requests for a continuation of the conversation. You will receive a conversation id on the first query you send.
metadata
json
required
A map containing data used to generate the query response. It provides additional sources of information to the reply.

Streamed response

When streaming is equal to true the response is sent as a series of chunk where each of them will be a JSON object.
type
string
required
Specifies the type of the chunk that is being sentPossible values are: initializing, token, response, done
value
string | null
It only appears when type == token.It represents the token that is currently being sent as part of a partial response. If you concatenate all tokens you will have the complete response.
data
json | null
It only appears when type == response.A json object containing the final response and metadata for the gptQuery.
{
  "reply": "The capital of France is Paris.",
  "conversationId": "optional-unique-id",
  "metadata": {
      "documents": [
          {
  			"id": "some-document-id",
  			"title": "The france capital",
  			"similarity": 0.966698234468654,
  			"extraFields": {
  				"learnMoreLink": {
  					"url": "https://france-capital",
  					"text": "The France Capital"
  				}
  			}
  		},
      ],
      "images": [],
      "helpArticles": [
          {
              "url": "https://france-capital",
              "text": "The France Capital"
  		}
      ]
  }
}