Update CodeGeneratorAtomicFlow.py
Browse files- CodeGeneratorAtomicFlow.py +11 -10
CodeGeneratorAtomicFlow.py
CHANGED
|
@@ -63,14 +63,15 @@ class CodeGeneratorAtomicFlow(ChatAtomicFlow):
|
|
| 63 |
|
| 64 |
def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 65 |
self._update_prompts_and_input(input_data)
|
| 66 |
-
api_output = super().run(input_data)["api_output"].strip()
|
| 67 |
-
try:
|
| 68 |
-
response = json.loads(api_output)
|
| 69 |
-
return response
|
| 70 |
-
except json.decoder.JSONDecodeError:
|
| 71 |
-
new_goal = "The previous response cannot be parsed with json.loads, it cannot be parsed with json.loads, it could be the backslashes usesd for escaping single quotes in the string arguments of the code are not properly escaped themselves within the JSON context. Next time, do not provide any comments or code blocks. Make sure your next response is purely json parsable."
|
| 72 |
-
new_input_data = input_data.copy()
|
| 73 |
-
new_input_data['goal'] = new_goal
|
| 74 |
-
new_api_output = super().run(new_input_data)["api_output"].strip()
|
| 75 |
-
return json.loads(new_api_output)
|
| 76 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 63 |
|
| 64 |
def run(self, input_data: Dict[str, Any]) -> Dict[str, Any]:
|
| 65 |
self._update_prompts_and_input(input_data)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 66 |
|
| 67 |
+
|
| 68 |
+
while True:
|
| 69 |
+
api_output = super().run(input_data)["api_output"].strip()
|
| 70 |
+
try:
|
| 71 |
+
response = json.loads(api_output)
|
| 72 |
+
return response
|
| 73 |
+
except (json.decoder.JSONDecodeError, json.JSONDecodeError):
|
| 74 |
+
new_goal = "The previous response cannot be parsed with json.loads, it cannot be parsed with json.loads, it could be the backslashes usesd for escaping single quotes in the string arguments of the code are not properly escaped themselves within the JSON context. Next time, do not provide any comments or code blocks. Make sure your next response is purely json parsable."
|
| 75 |
+
new_input_data = input_data.copy()
|
| 76 |
+
new_input_data['goal'] = new_goal
|
| 77 |
+
input_data = new_input_data
|