POST
/
v2
/
library
/
{library_id}
/
query

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 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

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 true, the response is sent as a series of chunks where each of them will be a JSON object.

All chunks includes a type param the describes how the rest of the JSON will look like

type
string
required

Specifies the type of the chunk that is being sent

Possible values are: initializing, token, response, done

type == initializing

The initial chunk when the stream has just be opened.

Example:

{"type": "initializing"}

type == token

Each token represents a partial response sent from the library. When all chunks are concatenated together, you will have the final response.

The body will include a value attribute the will include the current token sent.

value
string

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.

{"type": "token",
 "value": "Paris"}

type == response

It contains the final response and additional metadata that has been used to generate the response

The body will include a data attribute the will include the final response and the metadata.

data
json

A json object containing the final response and additional metadata that has been used to generate the response.

done

The final chunk sent before the stream is closed.

Example:

{"type": "done"}