loteriof commited on
Commit
dbdc490
·
verified ·
1 Parent(s): 313addc
Files changed (1) hide show
  1. app.py +13 -10
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 be supporting or contradicting the claim
62
  """
63
  model = HfApiModel()
64
 
65
  prompt = f"""
66
- Analyze 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,13 +73,16 @@ def support_decision(claim:str, news:dict)-> str:
73
  Response:
74
  """
75
 
76
- response = model.run(prompt)
77
- response = response.strip().lower()
78
-
79
- if response in ["supports", "contradicts", "unclear"]:
80
- return response
81
- else:
82
- return "An error ocurred: the model was not able to analyze the news article"
 
 
 
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