pub fn extract_json_from_response(response: &str) -> &strExpand description
Extracts JSON from LLM response, handling markdown code blocks (CQ-H2).
This is a centralized utility for extracting JSON from LLM responses that may include markdown formatting, prose, or other surrounding text.
§Handling
- Markdown code blocks with
jsonlanguage marker - Markdown code blocks without language marker
- Raw JSON objects (first
{to last}) - JSON arrays (first
[to last])
§Arguments
response- The raw LLM response text
§Returns
The extracted JSON string, or the trimmed input if no JSON found