Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 4 additions & 0 deletions dashscope/app/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -196,4 +196,8 @@ def _build_input_parameters(cls, prompt, history, messages, **kwargs):
if image_list is not None and image_list:
input_param['image_list'] = image_list

file_list = kwargs.pop('file_list', None)
if file_list is not None and file_list:
input_param['file_list'] = file_list
Comment on lines +199 to +201
Copy link
Copy Markdown

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

high

The new file_list parameter is added to input_param without any type validation. This could lead to unexpected behavior or errors downstream if an invalid type is passed. For robustness, you should add validation to ensure file_list is a list of strings, similar to how doc_tag_codes is handled in this function.

Suggested change
file_list = kwargs.pop('file_list', None)
if file_list is not None and file_list:
input_param['file_list'] = file_list
file_list = kwargs.pop('file_list', None)
if file_list:
if isinstance(file_list, list) and all(
isinstance(item, str) for item in file_list):
input_param['file_list'] = file_list
else:
raise InvalidInput('file_list must be a List[str]')


return input_param, {**parameters, **kwargs}
8 changes: 5 additions & 3 deletions samples/test_application.py
Original file line number Diff line number Diff line change
Expand Up @@ -4,11 +4,13 @@
responses = Application.call(
api_key=os.getenv("DASHSCOPE_API_KEY"),
app_id=os.getenv("DASHSCOPE_APP_ID"),
prompt='你是谁?',
prompt='总结文件内容',
stream=True, # 流式输出
has_thoughts=True, # 输出节点内容
# has_thoughts=True, # 输出节点内容
incremental_output=True,
flow_stream_mode='agent_format') # 设置为Agent模式,透出指定节点的输出
file_list=["https://dashscope.oss-cn-beijing.aliyuncs.com/audios/welcome.mp3"],
# flow_stream_mode='agent_format' # 设置为Agent模式,透出指定节点的输出
)

for response in responses:
if response.status_code != HTTPStatus.OK:
Expand Down