loteriof commited on
Commit
89c17f2
·
verified ·
1 Parent(s): 87f6a51

add functions as tools

Browse files

Add all the implemented functions as tools

Files changed (1) hide show
  1. app.py +9 -1
app.py CHANGED
@@ -8,6 +8,7 @@ from tools.final_answer import FinalAnswerTool
8
 
9
  from Gradio_UI import GradioUI
10
 
 
11
  def reliable_url(url)-> bool:
12
  """A tool that decides if a given url is a reliable source
13
  Args:
@@ -34,6 +35,7 @@ def reliable_url(url)-> bool:
34
  return True
35
  return False
36
 
 
37
  def url_to_claim(url:str)-> dict:
38
  """A tool that receives a news url and returns the main claim of the webpage content and some aditional context
39
  Args:
@@ -48,10 +50,11 @@ def url_to_claim(url:str)-> dict:
48
 
49
  soup = BeautifulSoup(response.content, "html.parser")
50
  title = soup.title.text
51
- context = soup.get_text()[:2000]
52
 
53
  return {"claim": title, "context": context}
54
 
 
55
  def support_decision(claim:str, news:dict)-> Literal["supports", "contradicts", "unclear"]:
56
  """A tool that decides if a given news article supports, contradicts or have an unclear opinion about a given claim
57
  Args:
@@ -79,6 +82,8 @@ def support_decision(claim:str, news:dict)-> Literal["supports", "contradicts",
79
  else:
80
  return "An error ocurred: the model was not able to analyze the news article"
81
 
 
 
82
  def web_search(claim:str)-> list:
83
  """A tool that receives a claim and gather news about it by making a web search
84
  Args:
@@ -162,6 +167,9 @@ with open("prompts.yaml", 'r') as stream:
162
  agent = ToolCallingAgent(
163
  model=model,
164
  tools=[final_answer,
 
 
 
165
  check],
166
  max_steps=6,
167
  verbosity_level=1,
 
8
 
9
  from Gradio_UI import GradioUI
10
 
11
+ @tool
12
  def reliable_url(url)-> bool:
13
  """A tool that decides if a given url is a reliable source
14
  Args:
 
35
  return True
36
  return False
37
 
38
+ @tool
39
  def url_to_claim(url:str)-> dict:
40
  """A tool that receives a news url and returns the main claim of the webpage content and some aditional context
41
  Args:
 
50
 
51
  soup = BeautifulSoup(response.content, "html.parser")
52
  title = soup.title.text
53
+ context = soup.get_text()[:5000]
54
 
55
  return {"claim": title, "context": context}
56
 
57
+ @tool
58
  def support_decision(claim:str, news:dict)-> Literal["supports", "contradicts", "unclear"]:
59
  """A tool that decides if a given news article supports, contradicts or have an unclear opinion about a given claim
60
  Args:
 
82
  else:
83
  return "An error ocurred: the model was not able to analyze the news article"
84
 
85
+
86
+ @tool
87
  def web_search(claim:str)-> list:
88
  """A tool that receives a claim and gather news about it by making a web search
89
  Args:
 
167
  agent = ToolCallingAgent(
168
  model=model,
169
  tools=[final_answer,
170
+ url_to_claim,
171
+ support_decision,
172
+ web_search,
173
  check],
174
  max_steps=6,
175
  verbosity_level=1,