Constructor
new MessageClient(messageApiKey, optsopt)
Initializes a new message client.
- Source:
Parameters:
| Name | Type | Attributes | Default | Description | |||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
messageApiKey |
string
|
API key for the chat completion endpoint. Any placeholder value works for local LLM servers that don't require authentication. | |||||||||||||||||||||||||||
opts |
object
|
<optional> |
{} |
Client options.
|
Methods
_parseStructuredReply(message) → {Object}
Parse and validate a structured reply returned by the model.
The API enforces the JSON schema for supported models. Validation here
keeps failures explicit when an OpenAI-compatible endpoint does not.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
message |
object
|
OpenAI completion message. |
Returns:
- Type:
-
Object
Structured reply.
(async) chat(memory, player, message) → {Promise.<{reply: string, confidenceScore: number}>}
Send a message to the chat completion endpoint and return the generated reply.
- Source:
Parameters:
| Name | Type | Description |
|---|---|---|
memory |
Memory
|
Per-player conversation memory. |
player |
string
|
Player name or id. |
message |
string
|
Player message. |
Returns:
- Type:
-
Promise.<{reply: string, confidenceScore: number}>
Reply and confidence score.