Update main.py
Browse files
main.py
CHANGED
@@ -217,14 +217,21 @@ async def on_message(message: cl.Message):
|
|
217 |
|
218 |
os.environ["GOOGLE_CSE_ID"] = os.getenv('GOOGLE_CSE_ID')
|
219 |
os.environ["GOOGLE_API_KEY"] = os.getenv('GOOGLE_API_KEY')
|
220 |
-
searchAPI = GoogleSearchAPIWrapper(
|
|
|
|
|
|
|
221 |
tool = Tool(
|
222 |
-
name="
|
223 |
description="Search Google for recent results.",
|
224 |
-
func=
|
225 |
)
|
226 |
-
|
227 |
-
|
|
|
|
|
|
|
|
|
228 |
|
229 |
await cl.Message(
|
230 |
content="Sources : ",
|
|
|
217 |
|
218 |
os.environ["GOOGLE_CSE_ID"] = os.getenv('GOOGLE_CSE_ID')
|
219 |
os.environ["GOOGLE_API_KEY"] = os.getenv('GOOGLE_API_KEY')
|
220 |
+
searchAPI = GoogleSearchAPIWrapper()
|
221 |
+
def top5_results(query):
|
222 |
+
return search.results(query, 5)
|
223 |
+
|
224 |
tool = Tool(
|
225 |
+
name="Google Search Snippets",
|
226 |
description="Search Google for recent results.",
|
227 |
+
func=top5_results,
|
228 |
)
|
229 |
+
query = str(message.content)
|
230 |
+
ref_text = tool.run(query)
|
231 |
+
if 'Result' not in ref_text[0].keys():
|
232 |
+
print(ref_text)
|
233 |
+
else:
|
234 |
+
print('None')
|
235 |
|
236 |
await cl.Message(
|
237 |
content="Sources : ",
|