Skip to main content

$rag.chat.create

The method creates a chat in a knowledge base.

caution

The method is available only in the ECMAScript 6 runtime and is asynchronous.

Syntax

The method accepts the following arguments:

ArgumentTypeDescriptionRequired
secretNameStringName of the knowledge base secret.Yes
nameStringChat name.No
settingsObject

Query processing settings. By default, the settings from the Tovie Data Agent project are used.

The settings format matches the format of the identically named object in the POST /api/knowledge-hub/chat request in the Tovie Data Agent API.
No
timeoutNumber

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.

Specify the arguments in order:

await $rag.chat.create("MyKnowledgeHub", "My chat", undefined, 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);