modelscope-agent icon indicating copy to clipboard operation
modelscope-agent copied to clipboard

当添加配置信息时,报错:File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 647, in gen_wrapper yield from f(args, **kwargs) File "/content/modelscope-agent/apps/agentfabric/app.py", line 386, in preview_send_message user_agent = _state['user_agent'] KeyError: 'user_agent'

Open yangxia605 opened this issue 1 year ago • 3 comments

Error:weather api token must be acquired through https://lbs.amap.com/api/webservice/guide/create-project/get-key and set by AMAP_TOKEN, with detail: Traceback (most recent call last): File "/content/modelscope-agent/apps/agentfabric/app.py", line 20, in init_user user_agent = init_user_chatbot_agent(uuid_str) File "/content/modelscope-agent/apps/agentfabric/user_core.py", line 57, in init_user_chatbot_agent agent = AgentExecutor( File "/content/modelscope-agent/modelscope_agent/agent.py", line 55, in init self._init_tools(tool_cfg, additional_tool_list) File "/content/modelscope-agent/modelscope_agent/agent.py", line 89, in _init_tools self.tool_list[tool_name] = tool_class(tool_cfg) File "/content/modelscope-agent/modelscope_agent/tools/amap_weather.py", line 27, in init assert self.token != '', 'weather api token must be acquired through '
AssertionError: weather api token must be acquired through https://lbs.amap.com/api/webservice/guide/create-project/get-key and set by AMAP_TOKEN

|LLM inputs in round 1: [{'role': 'system', 'content': 'You are a helpful assistant.'}, {'role': 'user', 'content': '你现在要扮演一个制造 AI 角色( AI-Agent )的 AI 助手( QwenBuilder )。\n 你需要和用户进行对话,明确用户对 AI-Agent 的要求。并根据已有信息和你的联想能力,尽可能填充完整的配置文件: \n\n 配置文件为 json 格式: \n{"name": "... # AI-Agent 的名字", "description": "... # 对 AI-Agent 的要求,简单描述", "instructions": "... # 分点描述对 AI-Agent 的具体功能要求,尽量详细一些,类型是一个字符串数组,起始为 []", "prompt_recommend": "... # 推荐的用户将对 AI-Agent 说的指令,用于指导用户使用 AI-Agent ,类型是一个字符串数组,请尽可能补充 4 句左右,起始为 ["你可以做什么?"]", "logo_prompt": "... # 画 AI-Agent 的 logo 的指令,不需要画 logo 或不需要更新 logo 时可以为空,类型是 string"}\n\n 在接下来的对话中,请在回答时严格使用如下格式,先作出回复,再生成配置文件,不要回复其他任何内容: \nAnswer: ... # 你希望对用户说的话,用于询问用户对 AI-Agent 的要求,不要重复确认用户已经提出的要求,而应该拓展出新的角度来询问用户,尽量细节和丰富,禁止为空 \nConfig: ... # 生成的配置文件,严格按照以上 json 格式 \nRichConfig: ... # 格式和核心内容和 Config 相同,但是保证 name 和 description 不为空; instructions 需要在 Config 的基础上扩充字数,使指令更加详尽,如果用户给出了详细指令,请完全保留;补充 prompt_recommend ,并保证 prompt_recommend 是推荐的用户将对 AI-Agent 说的指令。请注意从用户的视角来描述 prompt_recommend、description 和 instructions。\n\n 一个优秀的 RichConfig 样例如下: \n{"name": "小红书文案生成助手", "description": "一个专为小红书用户设计的文案生成助手。", "instructions": "1. 理解并回应用户的指令; 2. 根据用户的需求生成高质量的小红书风格文案; 3. 使用表情提升文本丰富度", "prompt_recommend": ["你可以帮我生成一段关于旅行的文案吗?", "你会写什么样的文案?", "可以推荐一个小红书文案模版吗?"], "logo_prompt": "一个写作助手 logo ,包含一只羽毛钢笔"}\n\n\n 明白了请说“好的。”, 不要说其他的。'}, {'role': 'assistant', 'content': '好的。'}, {'role': 'user', 'content': '请实现一个数据库数据校验功能的单元测试用例,如果数据库不存在该数据,则可以新增。\n 如果数据库已经存在该数据,则新增失败。\n 输入:\n 该功能的接口类 com.xwbank.test.analysis.service.task.IntegrationExecConfigService。\n 该功能的接口方法 saveOrUpdateConfig。\n 该方法接收 1 个参数,方法参数: IntegrationExecConfigEntity entity。\n 参数 entity 的属性都具有 get/set 方法。\nget/set 方法包含的属性有 Long taskId , Long userId , String caseType , Integer testlinkProjectId , testlinkProjectName testlinkProjectName,String testlinkProjectPrefix,Integer testlinkSuiteId , String testlinkSuitePath , Integer testlinkPlanId , String testlinkPlanName , Integer testlinkBuildId , String testlinkBuildName , Long id , Date createdTime , Date updatedTime。\n\n\nWorkflows:\n\n 输出:\n 该方法 saveOrUpdateConfig 的返回值类型为: void 。\n\n\n 该方法 saveOrUpdateConfig 包含如下逻辑:\n 参数 entity 不能为空。\n 参数 entity 的 taskId 和 userId 不能为空 \n 参数 entity 的 userId 和 taskId 在数据库中组合唯一,当参数 entity 的 userId 和 taskId 在数据库中存在相同记录时,取出该记录的 id 复制给 entity 的 id。\n 参数 entity 的 caseType 只能为 1 或者 2.\n 参数 entity 的 testlinkSuitePath ,字符串格式为/xxx/xxx/xxx , xxx 代表非空的字符串。\n 取出第一个 xxx 作为 testlinkProjectName , testlinkProjectName 赋值给参数 entity 的 testlinkProjectName。通过 TestProject testlinkProject = testlinkService.api()\n.getTestProjectByName(testlinkProjectName)查询 testProject 对象, testlinkProject.getPrefix()赋值给参数 entity 的 testlinkProjectPrefix , testlinkProject.getId()赋值给参数 entityt 的 testlinkProjectId , \n 完成赋值操作后执行保存或更新 entity。\n 参数 entity 的 id 属性为空时,执行保存 entity 操作, id 属性不为空时执行更新 entity 操作。\n 结合自己的代码经验和该场景特点, 撰写代码, 需注意如下要点:\n 理解用户输入的关键词对应的异常场景, 思考该场景的单元测试用例。\n 注意不用使用 java 语言实现该功能,只需使用 spring-boot 和 junit 写单元测试用例即可。'}] Traceback (most recent call last): File "/usr/local/lib/python3.10/dist-packages/gradio/queueing.py", line 406, in call_prediction output = await route_utils.call_process_api( File "/usr/local/lib/python3.10/dist-packages/gradio/route_utils.py", line 226, in call_process_api output = await app.get_blocks().process_api( File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1554, in process_api result = await self.call_function( File "/usr/local/lib/python3.10/dist-packages/gradio/blocks.py", line 1206, in call_function prediction = await utils.async_iteration(iterator) File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 517, in async_iteration return await iterator.anext() File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 510, in anext return await anyio.to_thread.run_sync( File "/usr/local/lib/python3.10/dist-packages/anyio/to_thread.py", line 33, in run_sync return await get_asynclib().run_sync_in_worker_thread( File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 877, in run_sync_in_worker_thread return await future File "/usr/local/lib/python3.10/dist-packages/anyio/_backends/_asyncio.py", line 807, in run result = context.run(func, args) File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 493, in run_sync_iterator_async return next(iterator) File "/usr/local/lib/python3.10/dist-packages/gradio/utils.py", line 647, in gen_wrapper yield from f(args, **kwargs) File "/content/modelscope-agent/apps/agentfabric/app.py", line 386, in preview_send_message user_agent = _state['user_agent'] KeyError: 'user_agent' image

yangxia605 avatar Nov 27 '23 11:11 yangxia605

weather的api需要获取一下才能使用。 启动的时候稍微等一下,user_agent还没有初始化好,有操作的话就会报这个错

zzhangpurdue avatar Dec 01 '23 03:12 zzhangpurdue

这些api Key的配置在哪个文件?

shanmu-raoyunfei avatar Dec 16 '23 02:12 shanmu-raoyunfei

目前, 有.env.template但是不全,后续我们会把所有一需要key的地方汇总起来,感谢反馈。

zzhangpurdue avatar Mar 12 '24 12:03 zzhangpurdue