chat_text¶
basemode.chat.chat_text
async def chat_text(
prompt: str | list[dict],
model: str = "gpt-4o-mini",
*,
system: str | None = None,
max_tokens: int = 4096,
temperature: float = 0.7,
transcript: bool | None = None,
observation: ObservationContext | None = None,
on_usage: UsageCallback | None = None,
**extra,
) -> AsyncGenerator[str, None]
Stream a model's chat answer token-by-token.
Notes¶
promptis a single user message or a list of{"role", "content"}messages.systemis prepended unless the list already opens with a system message.- The model name is normalized and the request goes through
strategies.compat.build_kwargs, so temperature, thinking-budget andmax_completion_tokensquirks apply exactly as for continuations. No continuation prompt or healing is applied. - Models litellm lists as
mode: completionhave no chat endpoint. They get aUser:/Assistant:transcript on the text-completion endpoint, stopped (provider-side and client-side) at the next\nUser:.transcript=Trueforces this,transcript=Falseforces chat. - Recorded in the observation ledger with strategy
chatorchat_transcript.observationandon_usagebehave as in continue_text. extrais forwarded to the provider request.- Raises
EmptyCompletionError(strategy="chat"or"completion") when the model returns no content.