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:
Ismail Pelaseyed 2023-08-10 18:07:00 +02:00 committed by GitHub
parent 5e05ba2140
commit abb1264edf
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -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