legco_ai_assistant/backend/app
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
..
core feat(backend): migrate LLM client to OpenAI SDK with thinking control 2026-04-23 14:10:26 +08:00
models refactor(backend): update Pydantic models for ingestion and query 2026-04-23 13:26:20 +08:00
routers refactor(backend): update ingest and query routers 2026-04-23 13:26:32 +08:00
services fix(backend): extract JSON from markdown code blocks in LLM responses 2026-04-23 16:28:07 +08:00
test fix(backend): extract JSON from markdown code blocks in LLM responses 2026-04-23 16:28:07 +08:00
utils refactor(backend): update document parsers for DOCX and PDF 2026-04-23 13:27:08 +08:00
__init__.py feat: Phase 1.1 project setup with config, database, and models 2026-04-22 16:13:52 +08:00
main.py feat(backend): add rotating file logging to backend/app/log/ 2026-04-23 14:09:48 +08:00