增强sengments_agent异常处理
This commit is contained in:
@@ -47,6 +47,8 @@ Warning: Never wrap the entire JSON object in quotes to make it a single string.
|
||||
def _result_handler(self, result: str, origin_prompt: str, logger: Logger):
|
||||
try:
|
||||
result = json_repair.loads(result)
|
||||
if not isinstance(result,dict):
|
||||
raise ValueError("agent返回结果不是dict的json形式")
|
||||
except:
|
||||
logger.error("结果不能正确解析")
|
||||
return self._error_result_handler(origin_prompt, logger)
|
||||
@@ -105,7 +107,7 @@ Warning: Never wrap the entire JSON object in quotes to make it a single string.
|
||||
try:
|
||||
for key, val in chunk.items():
|
||||
if key in indexed_translated:
|
||||
indexed_translated[key] = val
|
||||
indexed_translated[key] = str(val)
|
||||
except JSONDecodeError as e:
|
||||
self.logger.info(f"json解析错误,解析文本:{chunk},错误:{e.__repr__()}")
|
||||
except ValueError as e:
|
||||
|
||||
Reference in New Issue
Block a user