From 0cc09f45ae8e5c0eb64d6c845f0854c16f705751 Mon Sep 17 00:00:00 2001 From: =?UTF-8?q?=E6=8B=BF=E8=BE=B0?= Date: Thu, 26 Oct 2023 11:28:04 +0800 Subject: [PATCH] fix --- modelscope_agent/llm/openai.py | 2 +- modelscope_agent/output_parser.py | 5 +++-- modelscope_agent/tools/text_to_image_tool.py | 2 +- 3 files changed, 5 insertions(+), 4 deletions(-) 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)}