接口报错 #597
Unanswered
smartparrot
asked this question in
Q&A
接口报错
#597
Replies: 1 comment
-
版本: |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
run:
curl -X POST 'http://localhost:31512/v1/chat/completions' -H 'Content-Type: application/json' -d '{
"tools": [{
"type": "function",
"function": {
"name": "amap_weather",
"description": "amap weather tool",
"parameters": [{
"name": "location",
"type": "string",
▒▒区
", "description": "城市/区具体名称,如
北京市海淀区请描述为
海▒"required": true
}]
}
}],
"tool_choice": "auto",
"model": "Qwen2-7B-Instruct",
"messages": [
{"content": "海淀区天气", "role": "user"}
]
}'
I get this:
2024-10-31 12:36:51.423 - modelscope-agent - INFO - | message: call openai api success, output: on": "
2024-10-31 12:36:51.435 - modelscope-agent - INFO - | message: call openai api success, output: 海淀区"}
INFO 10-31 12:36:51 async_llm_engine.py:141] Finished request chat-0483a41cb281444091a174b5362a0725.
2024-10-31 12:36:51.447 - modelscope-agent - INFO - | message: call openai api success, output:
{}
INFO: 127.0.0.1:38106 - "POST /v1/chat/completions HTTP/1.1" 200 OK
INFO 10-31 12:36:59 metrics.py:406] Avg prompt throughput: 32.4 tokens/s, Avg generation throughput: 1.8 tokens/s, Running: 0 reqs, Swapped: 0 reqs, Pending: 0 reqs, GPU KV cache usage: 0.0%, CPU KV cache usage: 0.0%.
2024-10-31 12:37:08.326 - modelscope-agent - INFO - | message: client url http://localhost:8000/v1, client key: EMPTY
INFO: 127.0.0.1:49482 - "POST /v1/chat/completions HTTP/1.1" 400 Bad Request
2024-10-31 12:37:08.368 - modelscope-agent - ERROR - | message: Traceback (most recent call last):
File "/workspace/myagent/modelscope-agent/modelscope_agent/llm/base.py", line 248, in support_function_calling
response = self.chat_with_functions(
File "/workspace/myagent/modelscope-agent/modelscope_agent/llm/openai.py", line 180, in chat_with_functions
response = self.client.chat.completions.create(
File "/usr/local/lib/python3.10/dist-packages/openai/_utils/_utils.py", line 274, in wrapper
return func(*args, **kwargs)
File "/usr/local/lib/python3.10/dist-packages/openai/resources/chat/completions.py", line 668, in create
return self._post(
File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 1259, in post
return cast(ResponseT, self.request(cast_to, opts, stream=stream, stream_cls=stream_cls))
File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 936, in request
return self._request(
File "/usr/local/lib/python3.10/dist-packages/openai/_base_client.py", line 1040, in _request
raise self._make_status_error_from_response(err.response) from None
openai.BadRequestError: Error code: 400 - {'object': 'error', 'message': "[{'type': 'value_error', 'loc': ('body',), 'msg': 'Value error, Curr ently only named tools are supported.', 'input': {'messages': [{'role': 'user', 'content': 'What is the weather like in Boston?'}], 'model': ' Qwen2-7B-Instruct', 'tool_choice': 'auto', 'tools': [{'type': 'function', 'function': {'name': 'get_current_weather', 'description': 'Get the current weather in a given location.', 'parameters': {'type': 'object', 'properties': {'location': {'type': 'string', 'description': 'The city and state, e.g. San Francisco, CA'}, 'unit': {'type': 'string', 'enum': ['celsius', 'fahrenheit']}}, 'required': ['location']}}}]}, 'ctx': {' error': ValueError('Currently only named tools are supported.')}}]", 'type': 'BadRequestError', 'param': None, 'code': 400}
2024-10-31 12:37:08.368 - modelscope-agent - INFO - | message: call llm 1 times output: <generator object enable_stream_callback at 0x7f285cd 21bd0>
2024-10-31 12:37:08.368 - modelscope-agent - INFO - | message: call openai api, model: Qwen2-7B-Instruct, messages: [{'role': 'system', 'cont ent': '\n# 工具\n\n## 你拥有如下工具:\n\namap_weather: amap_weather API. amap weather tool Parameters: [{"name": "location", "type": "string" , "description": "城市/区具体名称,如
北京市海淀区
请描述为海淀区
", "required": true}] Format the arguments as a JSON object.\n\n## 当你需要 调用工具时,请在你的回复中穿插如下的工具调用命令,可以根据需求调用零次或多次:\n\n工具调用\nAction: 工具1的名称,必须是[amap_weather]之一\nAct ion Input: 工具1的输入\nAction: 工具2的名称,必须是[amap_weather]之一\nAction Input: 工具2的输入\n...\nAction: 工具N的名称,必须是[amap_weathe r]之一\nAction Input: 工具N的输入\nObservation: 工具1返回的结果\nObservation: 工具2返回的结果\n...\nObservat ion: 工具N返回的结果\n\nAnswer: 根据Observation总结本次工具调用返回的结果,如果结果中出现url,请使用如下格式展示出来:![图片] (url)\n\n\n# 指令\n\nNone\n\n请注意:你具有图像和视频的展示能力,也具有运行代码的能力,不要在回复中说你做不到。\n'}, {'role': 'user', 'content ': '(。你可以使用工具:[amap_weather])海淀区天气'}], stop: ['Observation:', 'Observation:\n'], stream: True, args: {'tools': [{'type': 'functi on', 'function': {'name': 'amap_weather', 'description': 'amap weather tool', 'parameters': [{'name': 'location', 'type': 'string', 'descripti on': '城市/区具体名称,如北京市海淀区
请描述为海淀区
', 'required': True}]}}], 'tool_choice': 'auto', 'parallel_tool_calls': True}INFO 10-31 12:37:08 logger.py:36] Received request chat-977bfc4e239b41e291689c1c06f8ed7d: prompt: '<|im_start|>system\n\n# 工具\n\n## 你拥有如 下工具:\n\namap_weather: amap_weather API. amap weather tool Parameters: [{"name": "location", "type": "string", "description": "城市/区具体 名称,如
北京市海淀区
请描述为海淀区
", "required": true}] Format the arguments as a JSON object.\n\n## 当你需要调用工具时,请在你的回复中穿 插如下的工具调用命令,可以根据需求调用零次或多次:\n\n工具调用\nAction: 工具1的名称,必须是[amap_weather]之一\nAction Input: 工具1的输入\nActi on: 工具2的名称,必须是[amap_weather]之一\nAction Input: 工具2的输入\n...\nAction: 工具N的名称,必须是[amap_weather]之一\nAction Input: 工具N 的输入\nObservation: 工具1返回的结果\nObservation: 工具2返回的结果\n...\nObservation: 工具N返回的结 果\n\nAnswer: 根据Observation总结本次工具调用返回的结果,如果结果中出现url,请使用如下格式展示出来:\n\n\n# 指令\n\nNone\ n\n请注意:你具有图像和视频的展示能力,也具有运行代码的能力,不要在回复中说你做不到。\n<|im_end|>\n<|im_start|>user\n(。你可以使用工具:[amap_ weather])海淀区天气<|im_end|>\n<|im_start|>assistant\n', params: SamplingParams(n=1, best_of=1, presence_penalty=0.0, frequency_penalty=0.0, r epetition_penalty=1.0, temperature=0.7, top_p=1.0, top_k=-1, min_p=0.0, seed=None, use_beam_search=False, length_penalty=1.0, early_stopping=F alse, stop=['Observation:', 'Observation:\n'], stop_token_ids=[], include_stop_str_in_output=False, ignore_eos=False, max_tokens=32444, min_to kens=0, logprobs=None, prompt_logprobs=None, skip_special_tokens=True, spaces_between_special_tokens=True, truncate_prompt_tokens=None), promp t_token_ids: [151644, 8948, 271, 2, 83002, 98, 76813, 271, 565, 220, 56568, 103926, 104506, 102011, 48443, 309, 391, 69364, 25, 1079, 391, 693 64, 5333, 13, 1079, 391, 9104, 5392, 13522, 25, 61753, 606, 788, 330, 2527, 497, 330, 1313, 788, 330, 917, 497, 330, 4684, 788, 330, 99490, 14 , 23836, 100398, 29991, 3837, 29524, 63, 104554, 118999, 63, 14880, 53481, 17714, 63, 118999, 63, 497, 330, 6279, 788, 830, 25439, 15042, 279, 5977, 438, 264, 4718, 1633, 382, 565, 84897, 112735, 47872, 11622, 102011, 13343, 37945, 18493, 103929, 104787, 15946, 99621, 101255, 29524, 101373, 102011, 47872, 11622, 106167, 3837, 112184, 100354, 47872, 11622, 99822, 32571, 57191, 104183, 48443, 102011, 47872, 11622, 198, 2512, 25, 83002, 98, 76813, 16, 9370, 29991, 3837, 100645, 20412, 58, 309, 391, 69364, 60, 100653, 198, 2512, 5571, 25, 83002, 98, 76813, 16, 9370, 31196, 198, 2512, 25, 83002, 98, 76813, 17, 9370, 29991, 3837, 100645, 20412, 58, 309, 391, 69364, 60, 100653, 198, 2512, 5571, 25, 83002, 98 , 76813, 17, 9370, 31196, 198, 9338, 2512, 25, 83002, 98, 76813, 45, 9370, 29991, 3837, 100645, 20412, 58, 309, 391, 69364, 60, 100653, 198, 2 512, 5571, 25, 83002, 98, 76813, 45, 9370, 31196, 198, 37763, 367, 25, 366, 1382, 29, 102011, 16, 31526, 105369, 522, 1382, 397, 37763, 367, 2 5, 366, 1382, 29, 102011, 17, 31526, 105369, 522, 1382, 397, 9338, 37763, 367, 25, 366, 1382, 29, 102011, 45, 31526, 105369, 522, 1382, 1339, 16141, 25, 51461, 117, 16038, 37763, 367, 102050, 101184, 102011, 47872, 11622, 31526, 105369, 3837, 62244, 59151, 15946, 100347, 1085, 37945, 37029, 104506, 68805, 101987, 99898, 5122, 20703, 45930, 9533, 1085, 3623, 2, 6567, 234, 229, 99738, 271, 4064, 271, 118271, 5122, 56568, 100 629, 107553, 33108, 87140, 9370, 101987, 99788, 3837, 74763, 100629, 104001, 46100, 104426, 3837, 100148, 18493, 104787, 15946, 36587, 56568, 113287, 8997, 151645, 198, 151644, 872, 198, 7, 1773, 105048, 37029, 102011, 5122, 58, 309, 391, 69364, 2467, 118999, 104307, 151645, 198, 151 644, 77091, 198], lora_request: None, prompt_adapter_request: None.INFO: 127.0.0.1:49482 - "POST /v1/chat/completions HTTP/1.1" 200 OK
Beta Was this translation helpful? Give feedback.
All reactions