(
query: str,
top_k: int = 8,
chapter: str = "",
section: str = "",
semantic_weight: float = 0.86,
include_text: bool = True,
)
| 196 | ), |
| 197 | ) |
| 198 | def afml_search( |
| 199 | query: str, |
| 200 | top_k: int = 8, |
| 201 | chapter: str = "", |
| 202 | section: str = "", |
| 203 | semantic_weight: float = 0.86, |
| 204 | include_text: bool = True, |
| 205 | ) -> dict[str, Any]: |
| 206 | if top_k < 1: |
| 207 | top_k = 1 |
| 208 | if top_k > 50: |
| 209 | top_k = 50 |
| 210 | |
| 211 | results = _score_results( |
| 212 | query=query, |
| 213 | top_k=top_k, |
| 214 | chapter=chapter, |
| 215 | section=section, |
| 216 | semantic_weight=semantic_weight, |
| 217 | ) |
| 218 | if not include_text: |
| 219 | for r in results: |
| 220 | r.pop("text", None) |
| 221 | |
| 222 | return { |
| 223 | "query": query, |
| 224 | "top_k": top_k, |
| 225 | "filters": {"chapter": chapter, "section": section}, |
| 226 | "results": results, |
| 227 | } |
| 228 | |
| 229 | |
| 230 | @mcp.tool( |
no test coverage detected