Update Controller_JarvisFlow.py
Browse files- Controller_JarvisFlow.py +13 -10
Controller_JarvisFlow.py
CHANGED
|
@@ -108,13 +108,16 @@ class Controller_JarvisFlow(ChatAtomicFlow):
|
|
| 108 |
role=self.flow_config["system_name"])
|
| 109 |
|
| 110 |
|
| 111 |
-
|
| 112 |
-
|
| 113 |
-
|
| 114 |
-
|
| 115 |
-
|
| 116 |
-
|
| 117 |
-
|
| 118 |
-
|
| 119 |
-
|
| 120 |
-
|
|
|
|
|
|
|
|
|
|
|
|
| 108 |
role=self.flow_config["system_name"])
|
| 109 |
|
| 110 |
|
| 111 |
+
while True:
|
| 112 |
+
api_output = super().run(input_data)["api_output"].strip()
|
| 113 |
+
try:
|
| 114 |
+
response = json.loads(api_output)
|
| 115 |
+
return response
|
| 116 |
+
except (json.decoder.JSONDecodeError, json.JSONDecodeError):
|
| 117 |
+
updated_system_message_content = self._get_message(self.system_message_prompt_template, input_data)
|
| 118 |
+
self._state_update_add_chat_message(content=updated_system_message_content,
|
| 119 |
+
role=self.flow_config["system_name"])
|
| 120 |
+
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."
|
| 121 |
+
new_input_data = input_data.copy()
|
| 122 |
+
new_input_data['result'] = new_goal
|
| 123 |
+
input_data = new_input_data
|