[tool] openapi工具代码示例运行失败:TypeError: argument of type 'OpenAPIPluginTool' is not iterable
Initial Checks
- [X] I have searched GitHub for a duplicate issue and I'm sure this is something new
- [X] I have read and followed the docs & demos and still think this is a bug
- [x] I am confident that the issue is with modelscope-agent (not my code, or another library in the ecosystem)
What happened + What you expected to happen
根据官方使用openapi的示例:https://github.com/modelscope/modelscope-agent/blob/master/examples/tools/openapi_schema_tool.ipynb,本地运行报错,相关的dashscopen已改为自己的,报错如下:
2024-05-21 12:10:04,212 - modelscope - INFO - PyTorch version 2.3.0 Found.
2024-05-21 12:10:04,217 - modelscope - INFO - TensorFlow version 2.16.1 Found.
2024-05-21 12:10:04,217 - modelscope - INFO - Loading ast index from C:\Users\Yang.cache\modelscope\ast_indexer
2024-05-21 12:10:04,363 - modelscope - INFO - Loading done! Current index file version is 1.12.0, with md5 bae340a52ccfa76c45f06e341a861891 and a total number of 964 components indexed
import wanx-v1_text2image failed, details: 'wanx-v1_text2image'
Traceback (most recent call last):
File "D:\test2023\modelscope-agent310\openapi_test.py", line 209, in
Versions / Dependencies
modelscope-agent版本:0.5.2
Reproduction script
schema_openAPI = {
"schema": {
"openapi":"3.1.0",
"info":{
"title":"wanx-v1 Generation API",
"description":"API for generating image with wanx-v1",
"version":"v1.0.0"
},
"servers":[
{
"url":"https://dashscope.aliyuncs.com"
}
],
"paths":{
"/api/v1/services/aigc/text2image/image-synthesis":{
"post":{
"summary":"wanx-v1 text2image",
"operationId":"wanx_v1_text2image",
"tags":[
"wanx-v1 text2image"
],
"requestBody":{
"required":True,
"X-DashScope-Async":"enable",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/wanx_v1_text2imageRequest"
}
}
}
},
"responses":{
"200":{
"description":"Successful Response",
"content":{
"application/json":{
"schema":{
"$ref":"#/components/schemas/wanx_v1_text2imageResponse"
}
}
}
}
},
"security":[
{
"BearerAuth":[]
}
]
}
},
"/api/v1/tasks/{task_id}":{
"get":{
"summary":"Get Text2image Result",
"operationId":"gettext2imageresult",
"tags":[
"Get Result"
],
"parameters":[
{
"name":"task_id",
"in":"path",
"required":True,
"description":"The unique identifier of the Text2image generation task",
"schema":{
"type":"string"
}
}
],
"security":[
{
"BearerAuth":[]
}
]
}
}
},
"components":{
"schemas":{
"wanx_v1_text2imageRequest":{
"type":"object",
"properties":{
"model":{
"type":"string",
"enum":[
"wanx-v1"
]
},
"input":{
"type":"object",
"properties":{
"prompt":{
"type":"string",
"example":"高清的,大师级的,4K,正面",
"description":"描述画面的提示词信息",
"required": True
}
}
},
"parameters":{
"type":"object",
"properties":{
"style":{
"type":"string",
"example":"
config_dict = openapi_schema_convert( schema=schema_openAPI["schema"], auth=schema_openAPI["auth"])
plugin_cfg = Config(config_dict)
function_list = []
for name, _ in plugin_cfg.items(): openapi_plugin_object = OpenAPIPluginTool(name=name, cfg=plugin_cfg) TOOL_REGISTRY[name] = openapi_plugin_object function_list.append(name)
from modelscope_agent.agents import RolePlay
role_template = '你扮演哆啦A梦小画家,你需要根据用户的要求用哆啦A梦的语气满足他们' llm_config = { 'model': 'qwen-max', 'model_server': 'dashscope', }
bot = RolePlay(function_list=function_list,llm=llm_config, instruction=role_template)
response = bot.run("哆啦A梦!帮我画一幅可爱的小女孩的照片", remote=False, print_info=True) text = '' for chunk in response: text += chunk print(text)
Issue Severity
None
已经定位到问题,在修复,参考pr
已经定位到问题,在修复,参考pr
谢谢,参考pr是什么
pr:https://github.com/modelscope/modelscope-agent/pull/451 已经合并到最新的master了,可以用master,或者等今明天发0.5.3版本。
0.5.3 版本已验证修复