Create a query
Make queries to a specific chatbot / library
Parameters
The ID of the library you are going to ask a question
Body
The question you will make to the library.
Optional. Use this for a continuation of the conversation. You will receive a conversation id on the first query you send.
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
The response from the library for the query provided in the request body
Use this in follow-up requests for a continuation of the conversation. You will receive a conversation id on the first query you send.
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
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 == 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.
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 == 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.
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: