legco_ai_assistant/backend/app/test
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
..
acceptance test(backend): update Phase 1 test suite 2026-04-23 13:27:40 +08:00
conftest.py test(backend): update Phase 1 test suite 2026-04-23 13:27:40 +08:00
test_phase1_chunking.py feat: Phase 1.2 ingestion pipeline with chunking and metadata 2026-04-22 16:49:52 +08:00
test_phase1_config.py feat: Phase 1.1 project setup with config, database, and models 2026-04-22 16:13:52 +08:00
test_phase1_database.py feat: Phase 1.1 project setup with config, database, and models 2026-04-22 16:13:52 +08:00
test_phase1_ingest.py feat: Phase 1.2 ingestion pipeline with chunking and metadata 2026-04-22 16:49:52 +08:00
test_phase1_llm_client.py test(backend): update unit tests for LLM monitoring changes 2026-04-23 14:52:41 +08:00
test_phase1_metadata.py feat: Phase 1.2 ingestion pipeline with chunking and metadata 2026-04-22 16:49:52 +08:00
test_phase1_parsers.py feat: Phase 1.2 ingestion pipeline with chunking and metadata 2026-04-22 16:49:52 +08:00
test_phase1_query.py test(backend): update Phase 1 test suite 2026-04-23 13:27:40 +08:00
test_phase1_query_decomposer.py fix(backend): extract JSON from markdown code blocks in LLM responses 2026-04-23 16:28:07 +08:00
test_phase1_rag_service.py test(backend): update Phase 1 test suite 2026-04-23 13:27:40 +08:00
test_phase1_relevance_filter.py fix(backend): extract JSON from markdown code blocks in LLM responses 2026-04-23 16:28:07 +08:00
test_phase2_asr_client.py init: project setup with AGENTS.md, test structure, and plan directory 2026-04-22 15:22:29 +08:00
test_phase2_video_upload.py init: project setup with AGENTS.md, test structure, and plan directory 2026-04-22 15:22:29 +08:00
test_phase2_ws_asr.py init: project setup with AGENTS.md, test structure, and plan directory 2026-04-22 15:22:29 +08:00