Add interactive chat harness for LLM service testing with auto-detection#90
Add interactive chat harness for LLM service testing with auto-detection#90SorraTheOrc merged 13 commits intomainfrom
Conversation
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
|
@copilot rather than require the user to provide the service URL can we please attempt to auto detect it. Start by looking for it on the windows host, assuming the client is running in WSL. This would require us to find the IP number and use that instead of localhost. If that fails then try localhost and if that fails return an error. Also allow /exit as an alias for /quit |
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
Done in commit 5ca8ec1. Auto-detection: The client now automatically detects the service URL when
If both fail, it displays a helpful error message. Example with auto-detection: /exit alias: Added The slash commands help text has been updated to show: |
Co-authored-by: SorraTheOrc <250240+SorraTheOrc@users.noreply.github.com>
…gging, and update tracker
…gamedev-agent-thoughts.txt
Engineers need a lightweight way to test
/parse_intentand/narrateendpoints, validate prompt changes, observe token usage, and debug latency without writing test code or navigating FastAPI docs.Implementation
HTTP Client (
src/gengine/echoes/llm/chat_client.py)httpx.AsyncClientwith context manager support/parse_intent,/narrate, and/healthzendpointsCLI REPL (
scripts/echoes_llm_chat.py)parse: Natural language → intent JSONnarrate: Events JSON → narrative text/etc/resolv.conf)http://localhost:8001/clear,/save <path>,/quit,/exit--context-filefor initial game stateUsage
Testing (
tests/echoes/test_llm_chat_cli.py)httpx.MockTransportfor HTTP layer mockingimportlib.util.spec_from_file_locationDocumentation
Added "LLM Chat Harness" section to README with:
Works with stub provider out of the box (no API keys required). Service URL auto-detection makes it easy to run without configuration—especially useful when working with WSL and Windows host services.
Original prompt
<issue_description>## Context
/parse_intentand/narrateoutside of automated tests.echoes_llm_service(stub, OpenAI, Anthropic, or Foundry providers) to validate prompt changes, observe token usage, and debug latency before wiring any gameplay endpoints.Goals
uv run python scripts/echoes_llm_chat.py --service-url http://localhost:8001) that opens an interactive prompt, accepts user text, and relays it to the configuredechoes_llm_service.Implementation Guidance
src/gengine/echoes/llm/chat_client.py) that wrapshttpx.AsyncClientand knows how to hit/parse_intent(default) and/narratewhen a--mode narrateflag is set. Accept base URL, timeout, and optional API key headers.scripts/(for examplescripts/echoes_llm_chat.py) that:argparseto capture--service-url,--context-file(JSON),--mode (parse|narrate),--history-limit, and--export transcript.json./clear,/save <path>, and/quitfor convenience.List[Dict[str, str]]history that is serialized into thecontextpayload for/parse_intent(e.g.,{ "history": [...], "metadata": {...} }).tests/echoes(e.g.,test_llm_chat_cli.py) that mock the HTTP layer (httpx.MockTransportorrespx) to verify:/clearresets the local buffer and/savewrites JSON transcriptsECHOES_LLM_*env vars.docker compose(http://localhost:8001).Acceptance Criteria
uv run python scripts/echoes_llm_chat.py --service-url http://localhost:8001opens an interactive prompt that can exchange messages with the stub provider out of the box.parse(intent JSON output) andnarrate(story text) modes via CLI flag without restarting the service.Risks & Mitigations
--history-limit) and redact API keys when exporting transcripts.Tracker Reference
See
.pm/tracker.md> Phase 13 > Task 13.1.1.</issue_description>
Comments on the Issue (you are @copilot in this section)
Original prompt
💬 We'd love your input! Share your thoughts on Copilot coding agent in our 2 minute survey.