datacipen commited on
Commit
b4d8901
1 Parent(s): 326348c

Update main.py

Browse files
Files changed (1) hide show
  1. main.py +19 -19
main.py CHANGED
@@ -12,7 +12,7 @@ from operator import itemgetter
12
  from pinecone import Pinecone
13
  from langchain_pinecone import PineconeVectorStore
14
  from langchain_community.chat_message_histories import ChatMessageHistory
15
- from langchain_google_community import GoogleSearchAPIWrapper
16
  from langchain.memory import ConversationBufferMemory
17
  from langchain.schema.runnable import Runnable, RunnablePassthrough, RunnableConfig, RunnableLambda
18
  from langchain.callbacks.base import BaseCallbackHandler
@@ -20,7 +20,7 @@ from langchain.chains import (
20
  StuffDocumentsChain, ConversationalRetrievalChain
21
  )
22
  from langchain_core.tracers.context import tracing_v2_enabled
23
- from langchain_core.tools import Tool
24
 
25
  import chainlit as cl
26
  from chainlit.input_widget import TextInput, Select, Switch, Slider
@@ -219,23 +219,23 @@ async def on_message(message: cl.Message):
219
  cl.Text(name="Sources", content=search[0], display="inline")
220
  ]
221
 
222
- os.environ["GOOGLE_CSE_ID"] = os.getenv('GOOGLE_CSE_ID')
223
- os.environ["GOOGLE_API_KEY"] = os.getenv('GOOGLE_API_KEY')
224
- searchAPI = GoogleSearchAPIWrapper()
225
- def top5_results(query):
226
- return searchAPI.results(query, 5)
227
-
228
- tool = Tool(
229
- name="Google Search Snippets",
230
- description="Search Google for recent results.",
231
- func=top5_results,
232
- )
233
- query = str(message.content)
234
- ref_text = tool.run(query)
235
- if 'Result' not in ref_text[0].keys():
236
- print(ref_text)
237
- else:
238
- print('None')
239
 
240
  await cl.Message(
241
  content="Sources : ",
 
12
  from pinecone import Pinecone
13
  from langchain_pinecone import PineconeVectorStore
14
  from langchain_community.chat_message_histories import ChatMessageHistory
15
+ #from langchain_google_community import GoogleSearchAPIWrapper
16
  from langchain.memory import ConversationBufferMemory
17
  from langchain.schema.runnable import Runnable, RunnablePassthrough, RunnableConfig, RunnableLambda
18
  from langchain.callbacks.base import BaseCallbackHandler
 
20
  StuffDocumentsChain, ConversationalRetrievalChain
21
  )
22
  from langchain_core.tracers.context import tracing_v2_enabled
23
+ #from langchain_core.tools import Tool
24
 
25
  import chainlit as cl
26
  from chainlit.input_widget import TextInput, Select, Switch, Slider
 
219
  cl.Text(name="Sources", content=search[0], display="inline")
220
  ]
221
 
222
+ #os.environ["GOOGLE_CSE_ID"] = os.getenv('GOOGLE_CSE_ID')
223
+ #os.environ["GOOGLE_API_KEY"] = os.getenv('GOOGLE_API_KEY')
224
+ #searchAPI = GoogleSearchAPIWrapper()
225
+ #def top5_results(query):
226
+ # return searchAPI.results(query, 5)
227
+
228
+ #tool = Tool(
229
+ # name="Google Search Snippets",
230
+ # description="Search Google for recent results.",
231
+ # func=top5_results,
232
+ #)
233
+ #query = str(message.content)
234
+ #ref_text = tool.run(query)
235
+ #if 'Result' not in ref_text[0].keys():
236
+ # print(ref_text)
237
+ #else:
238
+ # print('None')
239
 
240
  await cl.Message(
241
  content="Sources : ",