nodestep.chat.integrations ¶
Built-in chat integrations: ScriptedChat for tests, and OpenAIChat in the openai extra.
Anthropic (Claude) and Ollama are planned. See Agents and tools for the table of chat integrations, and Test with ScriptedChat.
| Name | What it is |
|---|---|
| Scripted model | |
ScriptedChat | Chat model that returns scripted responses, for tests and examples. |
| Page | Names |
|---|---|
| openai | OpenAIChat, OpenAISettings |
Scripted model¶
ScriptedChat¶
ScriptedChat(responses=(), *, default=None)
Chat model that returns scripted responses, for tests and examples.
responses | Iterable[ChatResponse | str] |
Responses returned in order, one per request. A |
default | ChatResponse | str | None |
Response returned for every request after the script runs out.
Without it, such a request raises |
TypeError |
If a response or |
model | str |
Always |
responses | list[ChatResponse] |
Responses not returned yet, in order. A response without a |
requests | list[ChatRequest] |
Every request received, in order. |
Methods
async complete(request)¶
Record the request and return the next scripted response.
async complete(request)¶async complete(request) -> ChatResponse
request | ChatRequest | |
ModelProviderError |
If the script ran out and no |
async stream(request)¶
Return the next scripted response as stream chunks.
async stream(request)¶async stream(request) -> AsyncIterator[ChatStreamChunk]
The chunks are the content word by word, whitespace kept, then the
refusal, one tool_call_delta per tool call, the finish reason and
the usage when set.
request | ChatRequest | |
ModelProviderError |
If the script ran out and no |
ValueError |
If the response sets |