CheeYung commited on
Commit
b95571e
·
1 Parent(s): 7d88664

Update TavilySearch

Browse files
Files changed (1) hide show
  1. agent.py +6 -3
agent.py CHANGED
@@ -23,6 +23,9 @@ from supabase import create_client, Client
23
 
24
  load_dotenv()
25
 
 
 
 
26
  __embeddings = HuggingFaceEmbeddings(
27
  model_name="sentence-transformers/all-mpnet-base-v2",
28
  model_kwargs= { 'device': 'cpu' })
@@ -129,9 +132,9 @@ def web_search(query: str) -> str:
129
  Args:
130
  query: The search query.
131
  """
132
- search_docs = TavilySearchResults(max_results=3).invoke(query=query)
133
  formatted_search_docs = "\n\n---\n\n".join([
134
- f'<Document source="{doc.metadata["source"]}" page="{doc.metadata.get("page", "")}"/>\n\t{doc.page_content}\n<Document>'
135
  for doc in search_docs
136
  ])
137
  return { "web_results": formatted_search_docs }
@@ -205,7 +208,7 @@ def build_graph():
205
  # Test
206
  if __name__ == "__main__":
207
  # question = "When was a picture of St. Thomas Aquinas first added to the Wikipedia page on the Principle of double effect?"
208
- question = "Data feed 100ms happened once. If 50second "
209
  graph = build_graph()
210
  messages = [HumanMessage(content=question)]
211
  messages = graph.invoke({ "messages": messages })
 
23
 
24
  load_dotenv()
25
 
26
+ os.environ["TAVILY_API_KEY"] = os.environ.get("TAVILY_API_KEY")
27
+ os.environ["GOOGLE_API_KEY"] = os.environ.get("GOOGLE_API_KEY")
28
+
29
  __embeddings = HuggingFaceEmbeddings(
30
  model_name="sentence-transformers/all-mpnet-base-v2",
31
  model_kwargs= { 'device': 'cpu' })
 
132
  Args:
133
  query: The search query.
134
  """
135
+ search_docs = TavilySearchResults(max_results=3).invoke(input=query)
136
  formatted_search_docs = "\n\n---\n\n".join([
137
+ f'<Document source="{doc["url"]}"/>\n\t{doc["content"]}\n<Document>'
138
  for doc in search_docs
139
  ])
140
  return { "web_results": formatted_search_docs }
 
208
  # Test
209
  if __name__ == "__main__":
210
  # question = "When was a picture of St. Thomas Aquinas first added to the Wikipedia page on the Principle of double effect?"
211
+ question = "How many studio albums were published by Mercedes Sosa between 2000 and 2009 (included)? You can use the latest 2022 version of english wikipedia."
212
  graph = build_graph()
213
  messages = [HumanMessage(content=question)]
214
  messages = graph.invoke({ "messages": messages })