Update ControllerFlow_ExtLib.py
Browse files109 unmodified lines110111112113114115116117118119120121122109 unmodified linesself._state_update_add_chat_message(content=updated_system_message_content,role=self.flow_config["system_name"])api_output = super().run(input_data)["api_output"].strip()try:response = json.loads(api_output)return responseexcept json.decoder.JSONDecodeError:new_goal = f"Here is your previous response {api_output}, it cannot be parsed with json.loads, please fix this issue. Provide your response only in JSON format."new_input_data = input_data.copy()new_input_data['result'] = new_goalnew_api_output = super().run(new_input_data)["api_output"].strip()return json.loads(new_api_output)109 unmodified lines110111112113114115116117118119120121122123124125109 unmodified linesself._state_update_add_chat_message(content=updated_system_message_content,role=self.flow_config["system_name"])while True:api_output = super().run(input_data)["api_output"].strip()try:response = json.loads(api_output)return responseexcept (json.decoder.JSONDecodeError, json.JSONDecodeError):updated_system_message_content = self._get_message(self.system_message_prompt_template, input_data)self._state_update_add_chat_message(content=updated_system_message_content,role=self.flow_config["system_name"])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."new_input_data = input_data.copy()new_input_data['result'] = new_goalinput_data = new_input_data
ControllerFlow_ExtLib.py+13-10