datacipen commited on
Commit
c2c00ef
·
verified ·
1 Parent(s): e7fc1d5

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +12 -5
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(k=10)
 
 
 
221
  tool = Tool(
222
- name="google_search",
223
  description="Search Google for recent results.",
224
- func=search.run,
225
  )
226
- print(tool.run(str(message.content)))
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 : ",