Documentation Index
Fetch the complete documentation index at: https://docs.illa.io/llms.txt
Use this file to discover all available pages before exploring further.
Chat represents one conversation and gives direct control over prompts, context, and streaming.
Use IllaSDK#createChat unless you need custom dependency wiring.
Construction
new Chat({
coreApiProvider,
contextManager,
userContext,
id,
asyncToolChecker,
defaultRole,
personalityContext,
modelContext,
})
Properties
getId(): string
Returns the chat identifier.
messages: Promise<MessageHistoryType>
Returns current message history from the context manager.
Core methods
sendMessage(prompt, options?)
sendMessage(
prompt: Prompt | Prompt[],
options?: SendMessageOptions,
): Promise<SendMessageResult>
Rules:
- Single
Prompt must be text-kind.
Prompt[] is for tool-result prompts only.
sendMessageStreaming(prompt, options?)
sendMessageStreaming(
prompt: Prompt,
options?: SendMessageStreamingOptions,
): Promise<void>
Streams telemetry and final result via callbacks.
getContext() / setContext(snapshot)
getContext(): Promise<ChatContextSnapshot>
setContext(snapshot: ChatContextSnapshot): Promise<void>
Read/replace persisted chat context.
awaitAction(descriptor)
awaitAction(descriptor: AwaitableActionDescriptor): Promise<AwaitActionResult>
Requires asyncToolChecker at construction. Descriptor fields are toolName, protocol, and args.
Example
import {
AsyncToolChecker,
Chat,
ContextManager,
CoreApiProvider,
InMemoryCache,
Prompt,
} from '@illalabs/sdk'
const provider = new CoreApiProvider({
headers: { 'x-api-key': process.env.ILLA_API_KEY! },
})
const contextManager = new ContextManager(new InMemoryCache())
const checker = new AsyncToolChecker({ coreApiProvider: provider })
const chat = new Chat({
coreApiProvider: provider,
contextManager,
asyncToolChecker: checker,
userContext: { address: '0x1234...' },
})
const result = await chat.sendMessage(new Prompt({ text: 'What is my wallet balance?' }))
if (!result.response.isError) {
console.log(result.response.data.text)
}
See also