(results: list[dict[str, Any]], chapter: str)
| 121 | |
| 122 | |
| 123 | def pick_hit_in_chapter(results: list[dict[str, Any]], chapter: str) -> dict[str, Any]: |
| 124 | target = chapter.strip().upper() |
| 125 | for hit in results: |
| 126 | if str(hit.get("chapter", "")).strip().upper() == target: |
| 127 | return hit |
| 128 | return {} |
| 129 | |
| 130 | |
| 131 | def chapter_prompt( |