Update CodeWriterCtrlFlow.py
Browse files- CodeWriterCtrlFlow.py +13 -10
CodeWriterCtrlFlow.py
CHANGED
@@ -80,13 +80,16 @@ class CodeWriterCtrlFlow(ChatAtomicFlow):
|
|
80 |
self._state_update_add_chat_message(content=updated_system_message_content,
|
81 |
role=self.flow_config["system_name"])
|
82 |
|
83 |
-
|
84 |
-
|
85 |
-
|
86 |
-
|
87 |
-
|
88 |
-
|
89 |
-
|
90 |
-
|
91 |
-
|
92 |
-
|
|
|
|
|
|
|
|
80 |
self._state_update_add_chat_message(content=updated_system_message_content,
|
81 |
role=self.flow_config["system_name"])
|
82 |
|
83 |
+
while True:
|
84 |
+
api_output = super().run(input_data)["api_output"].strip()
|
85 |
+
try:
|
86 |
+
response = json.loads(api_output)
|
87 |
+
return response
|
88 |
+
except (json.decoder.JSONDecodeError, json.JSONDecodeError):
|
89 |
+
updated_system_message_content = self._get_message(self.system_message_prompt_template, input_data)
|
90 |
+
self._state_update_add_chat_message(content=updated_system_message_content,
|
91 |
+
role=self.flow_config["system_name"])
|
92 |
+
new_goal = "The previous respond cannot be parsed with json.loads. Next time, do not provide any comments or code blocks. Make sure your next response is purely json parsable."
|
93 |
+
new_input_data = input_data.copy()
|
94 |
+
new_input_data['feedback'] = new_goal
|
95 |
+
input_data = new_input_data
|