Skip to content

AI chat

AI chat · Type

NameTypeDescription
argsLogarray
functionsCalledarray
lastFunctionCalledFunctionInfo
modelstring
requiredFunctionFunctionInfo
chat.addFunction(functionInfo: FunctionInfo)

No description yet.

chat.addTool(functionInfo: FunctionInfo)

No description yet.

chat.generateChat(messages: array) → string

No description yet.

chat.generateChatOrReturnFunctionCalled(messages: array) → string|FunctionInfo[]

This function exists to let the developer handle the tools calls on their own. It should not call the tools automatically.

chat.generateChatStream(messages: array) → StreamInterface

No description yet.

chat.generateChatStreamWithTools(messages: array, onTextDelta: callable)

Stream the assistant turn, looping through tool calls until the model finishes without requesting another tool. Mirrors the public surface of Minnow\LLPhant\Chat\AnthropicChat::generateChatStreamWithTools so GraceController’s method_exists($chat, 'generateChatStreamWithTools') branch lights up for the Mistral family.

Mistral La Plateforme speaks OpenAI-shape Server-Sent Events (deltas in choices[0].delta.{content,tool_calls}, final data: [DONE]), so this uses raw curl + SSE parsing rather than the SDK’s typed stream — the SDK’s CreateStreamedResponse path doesn’t carry a multi-turn tool loop.

chat.generateStreamOfText(prompt: string) → StreamInterface

No description yet.

chat.generateText(prompt: string) → string

No description yet.

chat.generateTextOrReturnFunctionCalled(prompt: string) → string|FunctionInfo[]

No description yet.

chat.getApiCalls() → int

No description yet.

chat.getCacheReadTokens() → int

No description yet.

chat.getInputTokens() → int

No description yet.

chat.getLastResponse() → CreateResponse

No description yet.

chat.getOutputTokens() → int

No description yet.

chat.getTotalTokens() → int

No description yet.

chat.getUsage() → CreateResponseUsage

No description yet.

chat.setFunctions(functions: array)

No description yet.

chat.setModelOption(option: string, value: mixed)

Mistral serves a repeated prompt prefix from its cache at a tenth of the input price, unasked; requests sharing this key are more likely to hit (docs.mistral.ai, prompt caching). Sent on the streaming and the non-streaming path. The key must not carry anything sensitive.

chat.setPromptCacheKey(key: string)

No description yet.

chat.setSystemMessage(message: string)

No description yet.

chat.setTools(tools: array)

No description yet.