$rag.chat.create
The method creates a chat in a knowledge base.
The method is available only in the ECMAScript 6 runtime and is asynchronous.
Syntax
The method accepts the following arguments:
Argument | Type | Description | Required |
---|---|---|---|
secretName | String | Name of the knowledge base secret. | Yes |
name | String | Chat name. | No |
settings | Object | Query processing settings. By default, the settings from the Tovie Data Agent project are used. Thesettings format matches the format of the identically named object in the POST /api/knowledge-hub/chat request in the Tovie Data Agent API. | No |
timeout | Number | Timeout in milliseconds for the method execution. If the timeout is exceeded, an error will occur. By default, the timeout is not set. | No |
You can pass arguments to the method in different ways.
- Positional arguments
- Via object
Specify the arguments in order:
await $rag.chat.create("MyKnowledgeHub", "My chat", undefined, 5000);
Pass an object whose fields match the names of the arguments:
await $rag.chat.create({
secretName: "MyKnowledgeHub",
name: "My chat",
timeout: 5000
});
Return value
The method returns an object with information about the created chat.
{
"id": 12345,
"settings": {
"pipeline": "semantic",
"search": {
"similarityTopK": 5,
"numCandidates": 50,
"candidateRadius": 0,
"rephraseUserQuery": null,
"segment": null
},
"llm": {
"model": "GPT-4o",
"contextWindow": 16000,
"maxTokens": 1000,
"temperature": 0,
"topP": 1,
"frequencyPenalty": 0,
"presencePenalty": 0
},
"responseGeneration": {
"prompt": "You help users look for information in the documentation …"
}
},
"name": "My chat"
}
The object has the same format as the response to the POST /api/knowledge-hub/chat
request in the Tovie Data Agent API.
How to use
In this state, the bot creates a new chat with a knowledge base and sends its identifier:
state: NewChat
intent!: /new chat
scriptEs6:
const chat = await $rag.chat.create("MyKnowledgeHub", "My chat");
$reactions.answer("Chat ID: " + chat.id);