Spaces:
Sleeping
Sleeping
remove help functions from the tools list
Browse filesRemove help functions from the tools list because they are encompassed in the "check" tool
app.py
CHANGED
|
@@ -8,7 +8,6 @@ from tools.final_answer import FinalAnswerTool
|
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
| 11 |
-
@tool
|
| 12 |
def reliable_url(url:str)-> bool:
|
| 13 |
"""A tool that decides if a given url is a reliable source
|
| 14 |
Args:
|
|
@@ -35,17 +34,23 @@ def reliable_url(url:str)-> bool:
|
|
| 35 |
return True
|
| 36 |
return False
|
| 37 |
|
| 38 |
-
@tool
|
| 39 |
def url_to_news(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:
|
| 42 |
url: the address of the webpage we want to summarize into main claim and context
|
| 43 |
"""
|
| 44 |
try:
|
| 45 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 46 |
response.raise_for_status()
|
| 47 |
-
|
| 48 |
-
|
|
|
|
|
|
|
|
|
|
| 49 |
|
| 50 |
soup = BeautifulSoup(response.content, "html.parser")
|
| 51 |
if soup.title:
|
|
@@ -57,7 +62,6 @@ def url_to_news(url:str)-> dict:
|
|
| 57 |
|
| 58 |
return {"title": title, "context": context}
|
| 59 |
|
| 60 |
-
@tool
|
| 61 |
def support_decision(model, claim:str, news:dict=None)-> str:
|
| 62 |
"""A tool that decides if a given news article supports, contradicts or have an unclear opinion about a given claim
|
| 63 |
Args:
|
|
@@ -91,7 +95,6 @@ def support_decision(model, claim:str, news:dict=None)-> str:
|
|
| 91 |
return "unclear"
|
| 92 |
|
| 93 |
|
| 94 |
-
@tool
|
| 95 |
def search(claim:str)-> list:
|
| 96 |
"""A tool that receives a claim and gather news about it by making a web search
|
| 97 |
Args:
|
|
@@ -177,9 +180,6 @@ with open("prompts.yaml", 'r') as stream:
|
|
| 177 |
agent = ToolCallingAgent(
|
| 178 |
model=model,
|
| 179 |
tools=[final_answer,
|
| 180 |
-
url_to_news,
|
| 181 |
-
support_decision,
|
| 182 |
-
search,
|
| 183 |
check],
|
| 184 |
max_steps=6,
|
| 185 |
verbosity_level=1,
|
|
|
|
| 8 |
|
| 9 |
from Gradio_UI import GradioUI
|
| 10 |
|
|
|
|
| 11 |
def reliable_url(url:str)-> bool:
|
| 12 |
"""A tool that decides if a given url is a reliable source
|
| 13 |
Args:
|
|
|
|
| 34 |
return True
|
| 35 |
return False
|
| 36 |
|
|
|
|
| 37 |
def url_to_news(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:
|
| 40 |
url: the address of the webpage we want to summarize into main claim and context
|
| 41 |
"""
|
| 42 |
try:
|
| 43 |
+
# Add headers to avoid being blocked
|
| 44 |
+
headers = {
|
| 45 |
+
'User-Agent': 'Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36'
|
| 46 |
+
}
|
| 47 |
+
response = requests.get(url, timeout=10, headers=headers)
|
| 48 |
response.raise_for_status()
|
| 49 |
+
|
| 50 |
+
# Check content type to avoid processing non-HTML content
|
| 51 |
+
content_type = response.headers.get('content-type', '')
|
| 52 |
+
if 'text/html' not in content_type:
|
| 53 |
+
return {"title": "Non-HTML content", "context": ""}
|
| 54 |
|
| 55 |
soup = BeautifulSoup(response.content, "html.parser")
|
| 56 |
if soup.title:
|
|
|
|
| 62 |
|
| 63 |
return {"title": title, "context": context}
|
| 64 |
|
|
|
|
| 65 |
def support_decision(model, claim:str, news:dict=None)-> str:
|
| 66 |
"""A tool that decides if a given news article supports, contradicts or have an unclear opinion about a given claim
|
| 67 |
Args:
|
|
|
|
| 95 |
return "unclear"
|
| 96 |
|
| 97 |
|
|
|
|
| 98 |
def search(claim:str)-> list:
|
| 99 |
"""A tool that receives a claim and gather news about it by making a web search
|
| 100 |
Args:
|
|
|
|
| 180 |
agent = ToolCallingAgent(
|
| 181 |
model=model,
|
| 182 |
tools=[final_answer,
|
|
|
|
|
|
|
|
|
|
| 183 |
check],
|
| 184 |
max_steps=6,
|
| 185 |
verbosity_level=1,
|