feat: optimize vision tools and image handling

- Add model-aware vision tool loading based on supports_vision flag
- Move view_image_tool from config to builtin tools for dynamic inclusion
- Add timeout to image search to prevent hanging requests
- Optimize image search results format using thumbnails
- Add image validation for reference images in generation
- Improve error handling with detailed messages

Co-Authored-By: Claude Sonnet 4.5 <noreply@anthropic.com>
This commit is contained in:
hetao
2026-01-29 14:57:26 +08:00
parent 3cbf54b2eb
commit 7aa10b980f
5 changed files with 59 additions and 19 deletions

View File

@@ -46,7 +46,7 @@ def _search_images(
logger.error("ddgs library not installed. Run: pip install ddgs")
return []
ddgs = DDGS()
ddgs = DDGS(timeout=30)
try:
kwargs = {
@@ -119,12 +119,8 @@ def image_search_tool(
normalized_results = [
{
"title": r.get("title", ""),
"image_url": r.get("image", ""),
"image_url": r.get("thumbnail", ""),
"thumbnail_url": r.get("thumbnail", ""),
"source_url": r.get("url", ""),
"source": r.get("source", ""),
"width": r.get("width"),
"height": r.get("height"),
}
for r in results
]