cURL
curl --request POST \ --url https://gptbots.chat/agents/{id}/query \ --header 'Authorization: Bearer <token>' \ --header 'Content-Type: application/json' \ --data '{ "query": "<string>", "conversationId": "<string>", "visitorId": "<string>", "temperature": 123, "streaming": true, "modelName": "gpt_3_5_turbo", "maxTokens": 123, "presencePenalty": 123, "frequencyPenalty": 123, "topP": 123, "filters": { "custom_ids": [ "<string>" ], "datasource_ids": [ "<string>" ] }, "systemPrompt": "<string>", "userPrompt": "<string>", "promptType": "raw", "promptTemplate": "<string>" }'
{ "answer": "<string>", "conversationId": "<string>", "visitorId": "<string>", "sources": [ {} ] }
import { EventStreamContentType, fetchEventSource, } from '@microsoft/fetch-event-source'; let buffer = ''; let bufferEndpointResponse = ''; const ctrl = new AbortController(); await fetchEventSource(queryAgentURL, { method: 'POST', headers: { 'Content-Type': 'application/json', }, signal: ctrl.signal, body: JSON.stringify({ streaming: true, query, conversationId, visitorId, }), async onopen(response) { if (response.status === 402) { throw new ApiError(ApiErrorType.USAGE_LIMIT); } }, onmessage: (event) => { if (event.data === '[DONE]') { // End of stream ctrl.abort(); try { const { sources, conversationId, visitorId } = JSON.parse( bufferEndpointResponse ) as ChatResponse; } catch {} } else if (event.data?.startsWith('[ERROR]')) { // ... } else if (event.event === "endpoint_response") { bufferEndpointResponse += event.data; } else if (event.event === "answer") { buffer += event.data; // ... } }, });
Bearer authentication header of the form Bearer <token>, where <token> is your auth token.
Bearer <token>
<token>
Идентификатор агента
Success
The response is of type object.
object