Difference between revisions of "Bot Playground/AI/Bot.AI.chat"
From SmartBots Developers Docs
(Created page with "{{DISPLAYTITLE:{{SUBPAGENAME}}}} <onlyinclude>'''Sends a chat message request to bot AI.'''</onlyinclude> <syntaxhighlight lang="javascript"> Bot.AI.chat(message, senderName[...") |
|||
(4 intermediate revisions by the same user not shown) | |||
Line 1: | Line 1: | ||
{{DISPLAYTITLE:{{SUBPAGENAME}}}} | {{DISPLAYTITLE:{{SUBPAGENAME}}}} | ||
− | <onlyinclude> | + | <onlyinclude>Sends a chat message request to bot AI.</onlyinclude> |
<syntaxhighlight lang="javascript"> | <syntaxhighlight lang="javascript"> | ||
Line 14: | Line 14: | ||
{{API Variable|residentName|yes}} The name of the resident sending the message | {{API Variable|residentName|yes}} The name of the resident sending the message | ||
{{API Variable|options|optional}} The name of the resident sending the message Format: | {{API Variable|options|optional}} The name of the resident sending the message Format: | ||
− | < | + | <syntaxhighlight lang="javascript"> |
{ | { | ||
− | instructions?: string; | + | instructions?: string; |
− | // Previous messade ID, if responding to a particular previous AI message of the bot | + | // Previous messade ID, if responding to a particular previous AI message of the bot |
− | parentMessageId?: string; | + | parentMessageId?: string; |
− | // Maximum number of tokens to generate in response | + | // Maximum number of tokens to generate in response |
− | maxResponseTokens?: number; | + | maxResponseTokens?: number; |
+ | |||
+ | // Max number of response in bytes. SL IM has a max limit of 1023bytes. | ||
+ | maxResponseBytes?: number; | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
{{API Variable Group|Output}} | {{API Variable Group|Output}} | ||
{{API Variable|text|}} The response of the bot | {{API Variable|text|}} The response of the bot | ||
{{API Variable|messageId|}} The id of the response message. Can be specified as parentMessageId later | {{API Variable|messageId|}} The id of the response message. Can be specified as parentMessageId later | ||
{{API Variable|usage|}} The object which contains Token Usage. Format: The object which contains all groups. Format: | {{API Variable|usage|}} The object which contains Token Usage. Format: The object which contains all groups. Format: | ||
− | < | + | <syntaxhighlight lang="javascript"> |
{ | { | ||
// Number of tokens in a request (message + instructions + history) | // Number of tokens in a request (message + instructions + history) | ||
Line 38: | Line 41: | ||
tokens_left: number; | tokens_left: number; | ||
} | } | ||
− | </ | + | </syntaxhighlight> |
{{API Variables Table End}} | {{API Variables Table End}} | ||
* In case of error functions throws an error with a message. | * In case of error functions throws an error with a message. | ||
+ | |||
+ | {{NavMenu}} |
Latest revision as of 18:35, 12 November 2024
Sends a chat message request to bot AI.
Bot.AI.chat(message, senderName[, options])
Reference
This command accepts the following parameters:
Variable | Required | Description
| |
---|---|---|---|
Input: | |||
message | yes | chat message to the bot | |
residentName | yes | The name of the resident sending the message | |
options | optional | The name of the resident sending the message Format:
{
instructions?: string;
// Previous messade ID, if responding to a particular previous AI message of the bot
parentMessageId?: string;
// Maximum number of tokens to generate in response
maxResponseTokens?: number;
// Max number of response in bytes. SL IM has a max limit of 1023bytes.
maxResponseBytes?: number;
}
| |
Output: | |||
text | The response of the bot | ||
messageId | The id of the response message. Can be specified as parentMessageId later | ||
usage | The object which contains Token Usage. Format: The object which contains all groups. Format:
{
// Number of tokens in a request (message + instructions + history)
prompt_tokens: number;
// Number of tokens in a response
completion_tokens: number;
// Total tokens used
total_tokens: number;
// Tokens left on SmartBots AI balance
tokens_left: number;
}
|
- In case of error functions throws an error with a message.