Repository navigation
Add an offline EchoLLM for tests - #1684
Conversation
EchoLLM returns the message history it received, then a fixed echo line. It needs no API key and does not request tool calls. Structured output raises NotImplementedError. Co-authored-by: Mangesh Raut <mangeshraut712@users.noreply.github.com>
|
Thanks for this, @mangeshraut712! The implementation is clean and matches the issue spec. Tests, lint, mypy, and One addition before we merge: streaming support. At the moment, Suggested behaviour ( do not need 100%, just something I though reasonable)
Where it goes
A rough shape: async def _astream_chat(self, messages: MessageHistory) -> AsyncGenerator[str | Response, None]:
response = self._echo(messages)
for chunk in _split_evenly(response.message.content, _STREAM_CHUNKS):
await asyncio.sleep(_STREAM_SECONDS / _STREAM_CHUNKS)
yield chunk
yield responseTestsPlease monkeypatch
Thanks again! Once this is in, we're happy to merge. |
|
@Amir-R25 Want your quick second eye on this when ur back, as it adds another component of llm module, though I thought really reasonable. |
Streamed chat calls yield the echo as five slices, one per second, then the same response chat returns. A reply shorter than five characters still yields five slices, with the later ones empty. Tool streaming never requests a tool call. Co-authored-by: Mangesh Raut <mangeshraut712@users.noreply.github.com>
|
Thanks! Added streaming in 879aea8. Each call sends the echo in 5 chunks, one per second, then the same Response as chat. Tests use a fake sleep and cover rt.astream with and without tools. Structured streaming still raises NotImplementedError. |
CoronRing
left a comment
There was a problem hiding this comment.
Great work; all is clear as day on my side! If you enjoyed the framework, please tell your friends and star the repo so it gets a bit of attention.
Thanks & love from the maintenance team >_<
Summary
Adds
rt.llm.EchoLLM, an offline model for tests that do not have an API key.On each chat call it returns the full message history it received, one message per line (
role: content), then the lineThis is an echo of the test model.It never requests a tool call, so an agent with tools still finishes in one turn.structuredandastructuredraiseNotImplementedError. Usage is reported as zero tokens, zero cost, and zero latency, with the model nameecho.I left the provider as
ModelProvider.UNKNOWN. This is not a real provider, so a new enum value did not seem useful.Fixes #1682
Type of change
Checklist
ruff check .andruff format --check .)pytest -c pyproject.toml packages/railtracks/tests: 3485 passed, 8 skipped)mkdocs build --strictsucceeded)Notes
The docs section is on the LLM Setup page. The runnable snippet is
docs/scripts/documentation/echo_llm.py.