Spaces:
Sleeping
Sleeping
fix bugs
Browse files
app.py
CHANGED
|
@@ -54,16 +54,16 @@ def url_to_claim(url:str)-> dict:
|
|
| 54 |
return {"claim": title, "context": context}
|
| 55 |
|
| 56 |
@tool
|
| 57 |
-
def support_decision(claim:str, news:dict)-> str:
|
| 58 |
"""A tool that decides if a given news article supports, contradicts or have an unclear opinion about a given claim
|
| 59 |
Args:
|
| 60 |
claim: the claim we want to decide whether it is supported or contradicted
|
| 61 |
-
news: the news that may
|
| 62 |
"""
|
| 63 |
model = HfApiModel()
|
| 64 |
|
| 65 |
prompt = f"""
|
| 66 |
-
|
| 67 |
'supports', 'contradicts', or 'unclear'.
|
| 68 |
|
| 69 |
Claim: "{claim}"
|
|
@@ -73,13 +73,16 @@ def support_decision(claim:str, news:dict)-> str:
|
|
| 73 |
Response:
|
| 74 |
"""
|
| 75 |
|
| 76 |
-
|
| 77 |
-
|
| 78 |
-
|
| 79 |
-
|
| 80 |
-
|
| 81 |
-
|
| 82 |
-
|
|
|
|
|
|
|
|
|
|
| 83 |
|
| 84 |
|
| 85 |
@tool
|
|
|
|
| 54 |
return {"claim": title, "context": context}
|
| 55 |
|
| 56 |
@tool
|
| 57 |
+
def support_decision(claim:str, news="":dict)-> str:
|
| 58 |
"""A tool that decides if a given news article supports, contradicts or have an unclear opinion about a given claim
|
| 59 |
Args:
|
| 60 |
claim: the claim we want to decide whether it is supported or contradicted
|
| 61 |
+
news: the news that may support or contradict the claim
|
| 62 |
"""
|
| 63 |
model = HfApiModel()
|
| 64 |
|
| 65 |
prompt = f"""
|
| 66 |
+
Analyse the sentiment of the provided news article in contrast with the given claim and respond with only one of the following words
|
| 67 |
'supports', 'contradicts', or 'unclear'.
|
| 68 |
|
| 69 |
Claim: "{claim}"
|
|
|
|
| 73 |
Response:
|
| 74 |
"""
|
| 75 |
|
| 76 |
+
try:
|
| 77 |
+
response = model.run(prompt)
|
| 78 |
+
response = response.strip().lower()
|
| 79 |
+
|
| 80 |
+
if response in ["supports", "contradicts", "unclear"]:
|
| 81 |
+
return response
|
| 82 |
+
else:
|
| 83 |
+
return "unclear" # Default instead of error
|
| 84 |
+
except Exception:
|
| 85 |
+
return "unclear"
|
| 86 |
|
| 87 |
|
| 88 |
@tool
|