Skip to content

Commit

Permalink
fix tool calling error (#539)
Browse files Browse the repository at this point in the history
  • Loading branch information
zzhangpurdue authored Jul 23, 2024
1 parent e9e3ea9 commit 3364c3e
Show file tree
Hide file tree
Showing 3 changed files with 6 additions and 4 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -46,7 +46,7 @@ def call(self, params: str, **kwargs):
except AssertionError:
raise ValueError('Please set valid DASHSCOPE_API_KEY!')

if LOCAL_FILE_PATHS not in kwargs:
if LOCAL_FILE_PATHS not in kwargs or kwargs[LOCAL_FILE_PATHS] == {}:
raw_audio_file = WORK_DIR + '/' + params['audio_path']
else:
raw_audio_file = kwargs[LOCAL_FILE_PATHS][params['audio_path']]
Expand Down
2 changes: 1 addition & 1 deletion modelscope_agent/tools/dashscope_tools/qwen_vl.py
Original file line number Diff line number Diff line change
Expand Up @@ -91,7 +91,7 @@ def _parse_input(self, *args, **kwargs):

# current paths are deducted from llm, only contains basename, so need to add WORK_DIR
# convert image_file_paths to a valid local file path
if LOCAL_FILE_PATHS not in kwargs:
if LOCAL_FILE_PATHS not in kwargs or kwargs[LOCAL_FILE_PATHS] == {}:
# if no local file path exists, only a name of file paths exist
for i, image_file_path in enumerate(image_file_paths):
image_file_paths[i] = os.path.join(WORK_DIR, image_file_path)
Expand Down
6 changes: 4 additions & 2 deletions modelscope_agent/tools/dashscope_tools/style_repaint.py
Original file line number Diff line number Diff line change
Expand Up @@ -120,10 +120,12 @@ def _parse_input(self, *args, **kwargs):
if image_path and image_path.endswith(('.jpeg', '.png', '.jpg')):
# 生成 image_url,然后设置到 kwargs['input'] 中
# 复用dashscope公共oss
if LOCAL_FILE_PATHS not in kwargs:
if LOCAL_FILE_PATHS not in kwargs or kwargs[
LOCAL_FILE_PATHS] == {}:
image_path = f'file://{os.path.join(WORK_DIR,image_path)}'
else:
image_path = f'file://{kwargs["local_file_paths"][image_path]}'
image_path = f'file://{kwargs[LOCAL_FILE_PATHS][image_path]}'

image_url = get_upload_url(
model=
'style_repaint', # The default setting here is "style_repaint".
Expand Down

0 comments on commit 3364c3e

Please sign in to comment.