Tachi67 commited on
Commit
35d9991
·
1 Parent(s): 412045a

Update Controller_JarvisFlow.py

Browse files
Files changed (1) hide show
  1. Controller_JarvisFlow.py +5 -3
Controller_JarvisFlow.py CHANGED
@@ -111,9 +111,11 @@ class Controller_JarvisFlow(ChatAtomicFlow):
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"])
 
111
  while True:
112
  api_output = super().run(input_data)["api_output"].strip()
113
  try:
114
+ start = api_output.index("{")
115
+ end = api_output.rindex("}") + 1
116
+ json_str = api_output[start:end]
117
+ return json.loads(json_str)
118
+ except (ValueError, json.decoder.JSONDecodeError, json.JSONDecodeError):
119
  updated_system_message_content = self._get_message(self.system_message_prompt_template, input_data)
120
  self._state_update_add_chat_message(content=updated_system_message_content,
121
  role=self.flow_config["system_name"])