Spaces:
Running
Running
Francisco Zanartu
commited on
Commit
·
7f7028e
1
Parent(s):
52c15f4
clean leading "response:"
Browse files- utils/core.py +10 -2
utils/core.py
CHANGED
@@ -129,7 +129,7 @@ class HamburgerStyle:
|
|
129 |
|
130 |
prompt = INCONTEXT
|
131 |
chain = prompt | self.chat_model
|
132 |
-
|
133 |
{
|
134 |
"misinformation": misinformation,
|
135 |
"detected_fallacy": detected_fallacy,
|
@@ -138,7 +138,11 @@ class HamburgerStyle:
|
|
138 |
"example_myth": example_myth,
|
139 |
"factual_information": self.hamburger[1].content,
|
140 |
}
|
141 |
-
)
|
|
|
|
|
|
|
|
|
142 |
|
143 |
def generate_th_layer(self, misinformation):
|
144 |
|
@@ -172,15 +176,19 @@ class HamburgerStyle:
|
|
172 |
|
173 |
# generate rebuttal
|
174 |
self.hamburger[0] = self.hamburger[0]._replace(content=misinformation)
|
|
|
175 |
self.hamburger[1] = self.hamburger[1]._replace(
|
176 |
content=self.generate_st_layer(misinformation).strip()
|
177 |
)
|
|
|
178 |
self.hamburger[2] = self.hamburger[2]._replace(
|
179 |
content=self.generate_nd_layer(misinformation).strip()
|
180 |
)
|
|
|
181 |
self.hamburger[3] = self.hamburger[3]._replace(
|
182 |
content=self.generate_rd_layer(misinformation).strip()
|
183 |
)
|
|
|
184 |
self.hamburger[4] = self.hamburger[4]._replace(
|
185 |
content=self.generate_th_layer(misinformation).strip()
|
186 |
)
|
|
|
129 |
|
130 |
prompt = INCONTEXT
|
131 |
chain = prompt | self.chat_model
|
132 |
+
content = chain.invoke(
|
133 |
{
|
134 |
"misinformation": misinformation,
|
135 |
"detected_fallacy": detected_fallacy,
|
|
|
138 |
"example_myth": example_myth,
|
139 |
"factual_information": self.hamburger[1].content,
|
140 |
}
|
141 |
+
).content
|
142 |
+
|
143 |
+
content = re.sub(r"Response:", "", content)
|
144 |
+
|
145 |
+
return content
|
146 |
|
147 |
def generate_th_layer(self, misinformation):
|
148 |
|
|
|
176 |
|
177 |
# generate rebuttal
|
178 |
self.hamburger[0] = self.hamburger[0]._replace(content=misinformation)
|
179 |
+
## FACT
|
180 |
self.hamburger[1] = self.hamburger[1]._replace(
|
181 |
content=self.generate_st_layer(misinformation).strip()
|
182 |
)
|
183 |
+
## MYTH
|
184 |
self.hamburger[2] = self.hamburger[2]._replace(
|
185 |
content=self.generate_nd_layer(misinformation).strip()
|
186 |
)
|
187 |
+
## FALLACY
|
188 |
self.hamburger[3] = self.hamburger[3]._replace(
|
189 |
content=self.generate_rd_layer(misinformation).strip()
|
190 |
)
|
191 |
+
## FACT
|
192 |
self.hamburger[4] = self.hamburger[4]._replace(
|
193 |
content=self.generate_th_layer(misinformation).strip()
|
194 |
)
|