Hasan Iqbal
commited on
Reverted JSON fix for the time
Browse files
src/openfactcheck/solvers/webservice/factcheckgpt_utils/openai_api.py
CHANGED
|
@@ -6,10 +6,6 @@ import openai
|
|
| 6 |
client = None
|
| 7 |
|
| 8 |
|
| 9 |
-
def _json_fix(output):
|
| 10 |
-
return output.replace("```json\n", "").replace("```", "")
|
| 11 |
-
|
| 12 |
-
|
| 13 |
def init_client():
|
| 14 |
global client
|
| 15 |
if client is None:
|
|
@@ -46,9 +42,6 @@ def request(
|
|
| 46 |
|
| 47 |
response = client.chat.completions.create(model=model, messages=messages, temperature=temperature)
|
| 48 |
|
| 49 |
-
# Fix the json format
|
| 50 |
-
response = _json_fix(response)
|
| 51 |
-
|
| 52 |
if return_all:
|
| 53 |
return response
|
| 54 |
response_str = ""
|
|
|
|
| 6 |
client = None
|
| 7 |
|
| 8 |
|
|
|
|
|
|
|
|
|
|
|
|
|
| 9 |
def init_client():
|
| 10 |
global client
|
| 11 |
if client is None:
|
|
|
|
| 42 |
|
| 43 |
response = client.chat.completions.create(model=model, messages=messages, temperature=temperature)
|
| 44 |
|
|
|
|
|
|
|
|
|
|
| 45 |
if return_all:
|
| 46 |
return response
|
| 47 |
response_str = ""
|
src/openfactcheck/solvers/webservice/factool_utils/chat_api.py
CHANGED
|
@@ -72,9 +72,6 @@ class OpenAIChat:
|
|
| 72 |
else:
|
| 73 |
return None
|
| 74 |
|
| 75 |
-
def _json_fix(self, output):
|
| 76 |
-
return output.replace("```json\n", "").replace("```", "")
|
| 77 |
-
|
| 78 |
def _boolean_fix(self, output):
|
| 79 |
return output.replace("true", "True").replace("false", "False")
|
| 80 |
|
|
@@ -169,9 +166,7 @@ class OpenAIChat:
|
|
| 169 |
)
|
| 170 |
|
| 171 |
preds = [
|
| 172 |
-
self._type_check(
|
| 173 |
-
self._boolean_fix(self._json_fix(prediction.choices[0].message.content)), expected_type
|
| 174 |
-
)
|
| 175 |
if prediction is not None
|
| 176 |
else None
|
| 177 |
for prediction in predictions
|
|
|
|
| 72 |
else:
|
| 73 |
return None
|
| 74 |
|
|
|
|
|
|
|
|
|
|
| 75 |
def _boolean_fix(self, output):
|
| 76 |
return output.replace("true", "True").replace("false", "False")
|
| 77 |
|
|
|
|
| 166 |
)
|
| 167 |
|
| 168 |
preds = [
|
| 169 |
+
self._type_check(self._boolean_fix(prediction.choices[0].message.content), expected_type)
|
|
|
|
|
|
|
| 170 |
if prediction is not None
|
| 171 |
else None
|
| 172 |
for prediction in predictions
|