Tachi67 commited on
Commit
cde39d0
·
1 Parent(s): dab9fc7

Update Controller_CoderFlow.py

Browse files
Files changed (1) hide show
  1. Controller_CoderFlow.py +5 -3
Controller_CoderFlow.py CHANGED
@@ -115,9 +115,11 @@ class Controller_CoderFlow(ChatAtomicFlow):
115
  while True:
116
  api_output = super().run(input_data)["api_output"].strip()
117
  try:
118
- response = json.loads(api_output)
119
- return response
120
- except (json.decoder.JSONDecodeError, json.JSONDecodeError):
 
 
121
  updated_system_message_content = self._get_message(self.system_message_prompt_template, input_data)
122
  self._state_update_add_chat_message(content=updated_system_message_content,
123
  role=self.flow_config["system_name"])
 
115
  while True:
116
  api_output = super().run(input_data)["api_output"].strip()
117
  try:
118
+ start = api_output.index("{")
119
+ end = api_output.rindex("}") + 1
120
+ json_str = api_output[start:end]
121
+ return json.loads(json_str)
122
+ except (ValueError, json.decoder.JSONDecodeError, json.JSONDecodeError):
123
  updated_system_message_content = self._get_message(self.system_message_prompt_template, input_data)
124
  self._state_update_add_chat_message(content=updated_system_message_content,
125
  role=self.flow_config["system_name"])