diff --git a/modelscope_agent/llm/openai.py b/modelscope_agent/llm/openai.py index ee1ec58f4..c059a8fc5 100644 --- a/modelscope_agent/llm/openai.py +++ b/modelscope_agent/llm/openai.py @@ -32,7 +32,7 @@ def generate(self, prompt): response = ''.join(completions) # truncate response - response = response.split("<|user|>")[0] + response = response.split('<|user|>')[0] idx = response.find('<|endofthink|>') if idx != -1: response = response[:idx + len('<|endofthink|>')] diff --git a/modelscope_agent/output_parser.py b/modelscope_agent/output_parser.py index 73f0fd11b..c835f8381 100644 --- a/modelscope_agent/output_parser.py +++ b/modelscope_agent/output_parser.py @@ -1,8 +1,9 @@ import re +import traceback from typing import Dict, Tuple import json -import traceback + class OutputParser: @@ -75,4 +76,4 @@ def parse_response(self, response: str) -> Tuple[str, Dict]: return action, parameters except Exception: - raise ValueError('Wrong response format for output parser') \ No newline at end of file + raise ValueError('Wrong response format for output parser') diff --git a/modelscope_agent/tools/text_to_image_tool.py b/modelscope_agent/tools/text_to_image_tool.py index 0ecb4c170..93077518b 100644 --- a/modelscope_agent/tools/text_to_image_tool.py +++ b/modelscope_agent/tools/text_to_image_tool.py @@ -49,6 +49,6 @@ def _parse_output(self, origin_result, remote=True): cv2.COLOR_BGR2RGB) else: # image = origin_result['output_img'] - image = origin_result.output['results'][0]["url"] + image = origin_result.output['results'][0]['url'] return {'result': ImageWrapper(image)}