mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-19 11:08:55 +00:00
community: add title, score and raw_content to tavily search results (#29995)
**Description:** Tavily search results returned from API include useful information like title, score and (optionally) raw_content that is missed in wrapper although it's documented there properly. Add this data to the result structure. --------- Co-authored-by: Chester Curme <chester.curme@gmail.com>
This commit is contained in:
parent
b525226531
commit
6177b9f9ab
@ -176,10 +176,13 @@ class TavilySearchAPIWrapper(BaseModel):
|
||||
"""Clean results from Tavily Search API."""
|
||||
clean_results = []
|
||||
for result in results:
|
||||
clean_results.append(
|
||||
{
|
||||
"url": result["url"],
|
||||
"content": result["content"],
|
||||
}
|
||||
)
|
||||
clean_result = {
|
||||
"title": result["title"],
|
||||
"url": result["url"],
|
||||
"content": result["content"],
|
||||
"score": result["score"],
|
||||
}
|
||||
if raw_content := result.get("raw_content"):
|
||||
clean_result["raw_content"] = raw_content
|
||||
clean_results.append(clean_result)
|
||||
return clean_results
|
||||
|
Loading…
Reference in New Issue
Block a user