Spaces:
Sleeping
Sleeping
Commit
•
1981c63
1
Parent(s):
aa910e9
Update crewai/tools/gemini_tools.py
Browse files- crewai/tools/gemini_tools.py +22 -1
crewai/tools/gemini_tools.py
CHANGED
@@ -23,6 +23,16 @@ model = genai.GenerativeModel('gemini-pro')
|
|
23 |
class GeminiSearchTools():
|
24 |
@tool("Gemini search the internet")
|
25 |
def gemini_search(query):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
26 |
try:
|
27 |
response = model.generate_content(query)
|
28 |
return response.text
|
@@ -32,9 +42,20 @@ class GeminiSearchTools():
|
|
32 |
# You can return a custom message or take other appropriate actions
|
33 |
return "Error: The request timed out. Please try again later."
|
34 |
|
|
|
35 |
|
36 |
@tool("Gemini search news on the internet")
|
37 |
def gemini_search_news(query):
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
38 |
try:
|
39 |
response = model.generate_content(query)
|
40 |
return response.text
|
@@ -42,4 +63,4 @@ class GeminiSearchTools():
|
|
42 |
# Handle the DeadlineExceeded exception here
|
43 |
print("Error: Deadline Exceeded -", str(e))
|
44 |
# You can return a custom message or take other appropriate actions
|
45 |
-
return "Error: The request timed out. Please try again later."
|
|
|
23 |
class GeminiSearchTools():
|
24 |
@tool("Gemini search the internet")
|
25 |
def gemini_search(query):
|
26 |
+
"""
|
27 |
+
Searches for content based on the provided query using the Gemini model.
|
28 |
+
Handles DeadlineExceeded exceptions from the Google API.
|
29 |
+
|
30 |
+
Args:
|
31 |
+
query (str): The search query.
|
32 |
+
|
33 |
+
Returns:
|
34 |
+
str: The response text from the Gemini model or an error message.
|
35 |
+
"""
|
36 |
try:
|
37 |
response = model.generate_content(query)
|
38 |
return response.text
|
|
|
42 |
# You can return a custom message or take other appropriate actions
|
43 |
return "Error: The request timed out. Please try again later."
|
44 |
|
45 |
+
|
46 |
|
47 |
@tool("Gemini search news on the internet")
|
48 |
def gemini_search_news(query):
|
49 |
+
"""
|
50 |
+
Searches for content based on the provided query using the Gemini model.
|
51 |
+
Handles DeadlineExceeded exceptions from the Google API.
|
52 |
+
|
53 |
+
Args:
|
54 |
+
query (str): The search query.
|
55 |
+
|
56 |
+
Returns:
|
57 |
+
str: The response text from the Gemini model or an error message.
|
58 |
+
"""
|
59 |
try:
|
60 |
response = model.generate_content(query)
|
61 |
return response.text
|
|
|
63 |
# Handle the DeadlineExceeded exception here
|
64 |
print("Error: Deadline Exceeded -", str(e))
|
65 |
# You can return a custom message or take other appropriate actions
|
66 |
+
return "Error: The request timed out. Please try again later."
|