Arcpolar commited on
Commit
0a32ecc
·
verified ·
1 Parent(s): eb2c8fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +36 -6
app.py CHANGED
@@ -9,14 +9,44 @@ from Gradio_UI import GradioUI
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
- def my_cutom_tool(arg1:str, arg2:int)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
- """A tool that does nothing yet
15
  Args:
16
- arg1: the first argument
17
- arg2: the second argument
 
18
  """
19
- return "What magic will you build ?"
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
 
21
  @tool
22
  def get_current_time_in_timezone(timezone: str) -> str:
@@ -55,7 +85,7 @@ with open("prompts.yaml", 'r') as stream:
55
 
56
  agent = CodeAgent(
57
  model=model,
58
- tools=[get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)
59
  max_steps=6,
60
  verbosity_level=1,
61
  grammar=None,
 
9
 
10
  # Below is an example of a tool that does nothing. Amaze us with your creativity !
11
  @tool
12
+ def fact_checker(claim:str)-> str: #it's import to specify the return type
13
  #Keep this format for the description / args / args description but feel free to modify the tool
14
+ """A tool that checks the validity of a claim by analyzing search results
15
  Args:
16
+ claim: A statement or claim to fact-check
17
+ Returns:
18
+ A summarized analysis of search results indicating if the clam is likely true, false, or inconclusive.
19
  """
20
+ search_tool = DuckDuckGoSearchTool(max_results=5)
21
+
22
+ try:
23
+ # Get Search results
24
+ results = search_tool.forward(claim)
25
+
26
+ # Analyze the results to check if the claim is mentioned
27
+ lower_claim = claim.lower()
28
+ positive_hits = sum(1 for result in result.split("\n") if lower_claim in result.lower())
29
+
30
+ # Generate a response based on the number of positive hits
31
+ if positive_hits >= 3:
32
+ status = "likely true"
33
+ elif positive_hits >= 1:
34
+ status = "possibly true, but further verification is needed"
35
+ else:
36
+ status = "unliely or inconclusive"
37
+
38
+ # Return a summary with confidence level
39
+ summary = (
40
+ f"Search results inicate taht the claim '{claim}' is {status}.\n"
41
+ f"Number of positive hits: {positive_hits}\n\n"
42
+ f"Here are the top results: \n{results}"
43
+ )
44
+
45
+ return summary
46
+
47
+ except Exception as e:
48
+ return f"Error during fact-checking: {str(e)}"
49
+
50
 
51
  @tool
52
  def get_current_time_in_timezone(timezone: str) -> str:
 
85
 
86
  agent = CodeAgent(
87
  model=model,
88
+ tools=[fact_checker, get_current_time_in_timezone, final_answer], ## add your tools here (don't remove final answer)
89
  max_steps=6,
90
  verbosity_level=1,
91
  grammar=None,