Conversation manages a running message history so you don’t have to track prior turns yourself. Create one via client.conversation() and call send() or stream() for each user turn. Both methods append the user message and the assistant response to messages automatically.
GatelitClient.conversation() for the constructor details.
Options
string
required
Model in
"provider/model-name" format. For example: "openai/gpt-4o".string
Optional system prompt prepended to every request. Useful for setting a persona or task scope that persists across all turns.
number
Maximum output tokens per request.
number
Sampling temperature applied to every request in the conversation.
Properties
messages
role ("system", "user", or "assistant") and a content string. Read-only — do not mutate this array directly. Use reset() to clear it.
Methods
send(content, signal?)
Sends a user message and returns the assistant’s full response. Appends both turns to messages.
string
required
The user’s message text.
AbortSignal
An optional
AbortSignal to cancel the in-flight request.ChatResponse — the same type returned by client.chat().
stream(content, signal?)
Sends a user message and streams the response. Appends the user turn immediately; the completed assistant turn is appended once the stream finishes.
string
required
The user’s message text.
AbortSignal
An optional
AbortSignal to cancel the stream.StreamChunk values — the same type produced by client.stream().
reset()
Clears the conversation history. The next call to send() or stream() starts a fresh conversation.
Examples
Multi-turn conversation
Streaming conversation
Using a system prompt
Resetting between sessions
reset() clears messages entirely. If you want to preserve context across resets, copy conv.messages before calling reset().