fix: DuckDuckGo image search tool error (#5606)

This commit is contained in:
非法操作 2024-06-26 13:21:40 +08:00 • committed by GitHub
commit b8926ea267
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
8 changed files with 26 additions and 16 deletions

View file

@ -19,7 +19,11 @@ class DuckDuckGoImageSearchTool(BuiltinTool):
"max_results": tool_parameters.get('max_results'),
}
response = DDGS().images(**query_dict)
results = []
result = []
for res in response:
results.append(self.create_image_message(image=res.get("image")))
return results
msg = ToolInvokeMessage(type=ToolInvokeMessage.MessageType.IMAGE_LINK,
message=res.get('image'),
save_as='',
meta=res)
result.append(msg)
return result