legco_ai_assistant/backend/app/services
Woody 33b960f786 fix(backend): extract JSON from markdown code blocks in LLM responses
The LLM (Qwen3.5 via OpenRouter) returns JSON wrapped in markdown code blocks:

```json

["project manager", "limits", ...]

```

But the code was trying to parse this directly with json.loads(), causing:

- QueryDecomposer to return empty keywords

- RelevanceFilter to fail with "Expecting value: line 1 column 1"

Changes:

- Added _extract_json_from_markdown() helper function to both modules

- Strips markdown code block markers (```json and ```) before JSON parsing

- Added unit tests for markdown code block handling

Ultraworked with [Sisyphus](https://github.com/code-yeongyu/oh-my-openagent)

Co-authored-by: Sisyphus \u003cclio-agent@sisyphuslabs.ai\u003e
2026-04-23 16:28:07 +08:00
..
__init__.py feat: Phase 1.1 project setup with config, database, and models 2026-04-22 16:13:52 +08:00
embedding_client.py feat(backend): add embedding client and update LLM client 2026-04-23 13:26:43 +08:00
llm_client.py feat(backend): add LLM monitoring with step names, timing, and prompt logging 2026-04-23 14:51:57 +08:00
query_decomposer.py fix(backend): extract JSON from markdown code blocks in LLM responses 2026-04-23 16:28:07 +08:00
rag.py feat(backend): add LLM monitoring with step names, timing, and prompt logging 2026-04-23 14:51:57 +08:00
relevance_filter.py fix(backend): extract JSON from markdown code blocks in LLM responses 2026-04-23 16:28:07 +08:00