refactor(backend): extract LLM transport into llm_service (#134) #216

Merged
claude-bot merged 1 commit from feat/134-llm-service-extraction into feat/v3.10-gm-workbench 2026-07-19 14:37:28 +00:00
Contributor

First foundational item of v3.10.0 GM Workbench. Targets the integration branch feat/v3.10-gm-workbench.

Closes #134.

What

A purely mechanical extraction of the LLM transport layer out of the overgrown audio_service.py into a new services/llm_service.py — the stable import target every Workbench tool (#136+) will sit on.

  • Moved to llm_service.py: generate_structured_text (dispatcher), the four _structured_* provider adapters (Ollama / llama.cpp / Anthropic / OpenAI), extract_json_object, and the constants they own (_LLM_TIMEOUT, _is_ollama_url, _LORE_PROPOSAL_SYSTEM_PROMPT).
  • audio_service.py re-exports them, so every call site keeps working unchanged — reminder_tasks, lore_service, audio_service's own domain functions (summarise / statblock / convert / names / …), and the LLM-mocking tests that patch("…audio_service.generate_structured_text") (verified: domain functions resolve the bare name from audio_service's namespace at call time, so the patch still lands).
  • No circular importllm_service never imports audio_service; identity check confirms audio_service.generate_structured_text is llm_service.generate_structured_text. Domain functions (transcription, summarisation, lore/name/stat generation) stay in audio_service.

Verification (Docker, py3.12)

  • 659 backend tests pass, unmodified — no behaviour change (esp. the LLM-mocking suites).
  • ruff check + ruff format --check clean (0.4.4). No migration, no new endpoints/schemas/prompts; no bot API change.

🤖 Generated with Claude Code

First foundational item of **v3.10.0 GM Workbench**. Targets the integration branch `feat/v3.10-gm-workbench`. Closes #134. ## What A purely mechanical extraction of the LLM transport layer out of the overgrown `audio_service.py` into a new `services/llm_service.py` — the stable import target every Workbench tool (#136+) will sit on. - **Moved to `llm_service.py`:** `generate_structured_text` (dispatcher), the four `_structured_*` provider adapters (Ollama / llama.cpp / Anthropic / OpenAI), `extract_json_object`, and the constants they own (`_LLM_TIMEOUT`, `_is_ollama_url`, `_LORE_PROPOSAL_SYSTEM_PROMPT`). - **`audio_service.py` re-exports** them, so every call site keeps working unchanged — `reminder_tasks`, `lore_service`, `audio_service`'s own domain functions (summarise / statblock / convert / names / …), and the LLM-mocking tests that `patch("…audio_service.generate_structured_text")` (verified: domain functions resolve the bare name from `audio_service`'s namespace at call time, so the patch still lands). - **No circular import** — `llm_service` never imports `audio_service`; identity check confirms `audio_service.generate_structured_text is llm_service.generate_structured_text`. Domain functions (transcription, summarisation, lore/name/stat generation) stay in `audio_service`. ## Verification (Docker, py3.12) - **659 backend tests pass, unmodified** — no behaviour change (esp. the LLM-mocking suites). - `ruff check` + `ruff format --check` clean (0.4.4). No migration, no new endpoints/schemas/prompts; no bot API change. 🤖 Generated with [Claude Code](https://claude.com/claude-code)
Move the provider-agnostic LLM transport out of the overgrown audio_service:
generate_structured_text, the four _structured_* provider adapters
(Ollama/llama.cpp/Anthropic/OpenAI), extract_json_object, and the constants they
own (_LLM_TIMEOUT, _is_ollama_url, _LORE_PROPOSAL_SYSTEM_PROMPT) now live in
services/llm_service.py. audio_service re-exports them so every existing call
site (reminder_tasks, lore_service, audio_service's own domain functions, and
the LLM-mocking tests that patch audio_service.generate_structured_text) keeps
working unchanged. No circular import; llm_service is the low-level layer.

Foundation for the v3.10.0 GM Workbench: the generalized generation endpoint
(#136) and every Workbench tool sit on llm_service. Pure mechanical move — no
behaviour change, no new endpoints/schemas/prompts.

Verified in Docker (py3.12): 659 tests pass unmodified; ruff check + format clean.

Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>
claude-bot merged commit 210541f99c into feat/v3.10-gm-workbench 2026-07-19 14:37:28 +00:00
Sign in to join this conversation.
No description provided.