Save or update a search result.
(
url: Annotated[str, ParamMeta(description="URL of the search result (used as key)")],
title: Annotated[str, ParamMeta(description="Title of the search result")],
abs: Annotated[str, ParamMeta(description="Abstract/Summary of the content")],
detail: Annotated[str, ParamMeta(description="Detailed content")],
_context: Dict[str, Any] | None = None,
)
| 66 | |
| 67 | |
| 68 | def search_save_result( |
| 69 | url: Annotated[str, ParamMeta(description="URL of the search result (used as key)")], |
| 70 | title: Annotated[str, ParamMeta(description="Title of the search result")], |
| 71 | abs: Annotated[str, ParamMeta(description="Abstract/Summary of the content")], |
| 72 | detail: Annotated[str, ParamMeta(description="Detailed content")], |
| 73 | _context: Dict[str, Any] | None = None, |
| 74 | ) -> str: |
| 75 | """ |
| 76 | Save or update a search result. |
| 77 | """ |
| 78 | ctx = FileToolContext(_context) |
| 79 | search_file, _ = _get_files(ctx) |
| 80 | search_lock, _ = _get_locks(ctx) |
| 81 | |
| 82 | with FileLock(search_lock): |
| 83 | data = _load_search_results(search_file) |
| 84 | current = data.get(url, {}) |
| 85 | |
| 86 | # Preserve existing keys if updating |
| 87 | highlight_keys = current.get("highlight_keys", []) |
| 88 | |
| 89 | data[url] = { |
| 90 | "title": title, |
| 91 | "abs": abs, |
| 92 | "detail": detail, |
| 93 | "highlight_keys": highlight_keys, |
| 94 | } |
| 95 | |
| 96 | _save_search_results(search_file, data) |
| 97 | return f"Saved result for {url}" |
| 98 | |
| 99 | |
| 100 | def search_load_all( |
nothing calls this directly
no test coverage detected