Skip to content

Commit

Permalink
Fix formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
ashpreetbedi committed Jul 20, 2024
1 parent 061f57f commit 5ad1792
Show file tree
Hide file tree
Showing 3 changed files with 16 additions and 13 deletions.
8 changes: 4 additions & 4 deletions cookbook/assistants/vision.py
Original file line number Diff line number Diff line change
Expand Up @@ -11,7 +11,7 @@
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
},
},
]
)
Expand All @@ -27,14 +27,14 @@
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
},
},
{
"type": "image_url",
"image_url": {
"url": "https://upload.wikimedia.org/wikipedia/commons/thumb/d/dd/Gfp-wisconsin-madison-the-nature-boardwalk.jpg/2560px-Gfp-wisconsin-madison-the-nature-boardwalk.jpg"
}
},
},
],
markdown=True,
)
)
4 changes: 2 additions & 2 deletions cookbook/tools/googlesearch_1.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,10 +7,10 @@
instructions=[
"Given a topic by the user, respond with 4 latest news items about that topic.",
"Search for 10 news items and select the top 4 unique items.",
"Search in English and in French."
"Search in English and in French.",
],
show_tool_calls=True,
debug_mode=True,
debug_mode=True,
)

news_assistant.print_response("Mistral IA", markdown=True)
17 changes: 10 additions & 7 deletions phi/tools/googlesearch.py
Original file line number Diff line number Diff line change
Expand Up @@ -14,19 +14,20 @@
except ImportError:
raise ImportError("`pycountry` not installed. Please install using `pip install pycountry`")


class GoogleSearch(Toolkit):
"""
GoogleSearch is a Python library for searching Google easily.
It uses requests and BeautifulSoup4 to scrape Google.
Args:
fixed_max_results (Optional[int]): A fixed number of maximum results.
fixed_language (Optional[str]): Language of the search results.
headers (Optional[Any]): Custom headers for the request.
proxy (Optional[str]): Proxy settings for the request.
timeout (Optional[int]): Timeout for the request, default is 10 seconds.
"""

def __init__(
self,
fixed_max_results: Optional[int] = None,
Expand Down Expand Up @@ -76,10 +77,12 @@ def google_search(self, query: str, max_results: int = 5, language: str = "en")
# Collect the search results
res: List[Dict[str, str]] = []
for result in results:
res.append({
"title": result.title,
"url": result.url,
"description": result.description,
})
res.append(
{
"title": result.title,
"url": result.url,
"description": result.description,
}
)

return json.dumps(res, indent=2)

0 comments on commit 5ad1792

Please sign in to comment.