rahulnamdev commited on
Commit
a5b4555
·
verified ·
1 Parent(s): 756b2a4

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +24 -2
app.py CHANGED
@@ -3,7 +3,7 @@ import gradio as gr
3
  import requests
4
  import inspect
5
  import pandas as pd
6
- from smolagents import (CodeAgent, DuckDuckGoSearchTool, HfApiModel)
7
  from tavily import TavilyClient
8
 
9
  # (Keep Constants as is)
@@ -14,7 +14,29 @@ DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
14
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
15
 
16
  #search_tool = DuckDuckGoSearchTool()
17
- search_tool = TavilyClient(api_key="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")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
18
 
19
  agent = CodeAgent(tools=[search_tool], model=HfApiModel())
20
 
 
3
  import requests
4
  import inspect
5
  import pandas as pd
6
+ from smolagents import (CodeAgent, DuckDuckGoSearchTool, HfApiModel, tool)
7
  from tavily import TavilyClient
8
 
9
  # (Keep Constants as is)
 
14
  # ----- THIS IS WERE YOU CAN BUILD WHAT YOU WANT ------
15
 
16
  #search_tool = DuckDuckGoSearchTool()
17
+
18
+
19
+ @tool
20
+ def web_search_tool(query: str) -> str:
21
+ """
22
+ This tool search for question as web serach and return back the answer
23
+
24
+ Args:
25
+ query: A search term for finding catering services.
26
+
27
+ Ex:
28
+ response = web_search_tool("where is Taj Mahal located ?")
29
+
30
+ """
31
+
32
+ # do a seach query
33
+ client = TavilyClient(api_key="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")
34
+
35
+ response = client.qna_search(query=query)
36
+
37
+ return response
38
+
39
+
40
 
41
  agent = CodeAgent(tools=[search_tool], model=HfApiModel())
42