mirror of
https://github.com/hwchase17/langchain
synced 2024-11-16 06:13:16 +00:00
Fix issue with Metaphor Search Tool throwing error on missing keys in API response (#9051)
- Description: Fixes an issue with Metaphor Search Tool throwing when missing keys in API response. - Issue: #9048 - Tag maintainer: @hinthornw @hwchase17 - Twitter handle: @pelaseyed
This commit is contained in:
parent
5e05ba2140
commit
abb1264edf
@ -163,10 +163,10 @@ class MetaphorSearchAPIWrapper(BaseModel):
|
||||
for result in raw_search_results:
|
||||
cleaned_results.append(
|
||||
{
|
||||
"title": result["title"],
|
||||
"url": result["url"],
|
||||
"author": result["author"],
|
||||
"published_date": result["publishedDate"],
|
||||
"title": result.get("title", "Unknown Title"),
|
||||
"url": result.get("url", "Unknown URL"),
|
||||
"author": result.get("author", "Unknown Author"),
|
||||
"published_date": result.get("publishedDate", "Unknown Date"),
|
||||
}
|
||||
)
|
||||
return cleaned_results
|
||||
|
Loading…
Reference in New Issue
Block a user