GPTAPI类型模型,fastapi返回消息报错:缺少必要字段“input”
还没有人认领这个 Issue。
评估
- 难度
- 3/5
- 预计耗时
- 1-2 天
- 新手友好度
- 45/100
- Issue 类型
- 缺陷
- 描述清晰度
- 基本清楚
- 活跃度
- 停滞
- 技术栈
- fastapi, javascript, python
调研方向
从 models.py 和 FastAPI 服务使用的 GPTAPI 请求路径开始,然后使用报告中的 VLLM_BASE_URL、VLLM_API_KEY 和 VLLM_MODEL_NAME 设置重现该问题。将生成的请求与 FastAPI 验证错误以及 vLLM 的 chat-completions endpoint 进行比较。前端搜索能够完成且不再出现报告中的 400 响应,即表示完成。
由索引模型根据 Issue 内容生成。
描述
症状描述
在frontend中正常输入搜索关键词并触发搜索后,卡住不动。fastapi报错:
{"object":"error","message":"[{'type': 'missing', 'loc': ('body', 'messages'), 'msg': 'Field required', 'input': {'model': 'qwen2-vl-7b-instruct', 'input': {'messages': [{'role': 'system', 'content': 'The current date is 2024-12-04.'}, {'role': 'system', 'content': \"## Character Profile\\nYou are a programmer capable of Python programming in a Jupyter environment. You can utilize the provided API to construct a Web Search Graph, ultimately generating and executing code.\\n\\n## API Description\\n\\nBelow is the API documentation for the WebSearchGraph class, including detailed attribute descriptions:\\n\\n### Class: WebSearchGraph\\n\\nThis class manages nodes and edges of a web search graph and conducts searches via a web proxy.\\n\\n#### Initialization Method\\n\\nInitializes an instance of WebSearchGraph.\\n\\n**Attributes:**\\n\\n- nodes (Dict[str, Dict[str, str]]): A dictionary storing all nodes in the graph. Each node is indexed by its name and contains content, type, and other related information.\\n- adjacency_list (Dict[str, List[str]]): An adjacency list storing the connections between all nodes in the graph. Each node is indexed by its name and contains a list of adjacent node names.\\n\\n#### Method: add_root_node\\n\\nAdds the initial question as the root node.\\n**Parameters:**\\n\\n- node_content (str): The user's question.\\n- node_name (str, optional): The node name, default is 'root'.\\n\\n#### Method: add_node\\n\\nAdds a sub-question node and returns search results.\\n**Parameters:**\\n\\n- node_name (str): The node name.\\n- node_content (str): The sub-question content.\\n\\n**Returns:**\\n\\n- str: Returns the search results.\\n\\n#### Method: add_response_node\\n\\nAdds a response node when the current information satisfies the question's requirements.\\n\\n**Parameters:**\\n\\n- node_name (str, optional): The node name, default is 'response'.\\n\\n#### Method: add_edge\\n\\nAdds an edge.\\n\\n**Parameters:**\\n\\n- start_node (str): The starting node name.\\n- end_node (str): The ending node name.\\n\\n#### Method: reset\\n\\nResets nodes and edges.\\n\\n#### Method: node\\n\\nGet node information.\\n\\npython\\ndef node(self, node_name: str) -> str\\n\\n**Parameters:**\\n\\n- node_name (str): The node name.\\n\\n**Returns:**\\n\\n- str: Returns a dictionary containing the node's information, including content, type, thought process (if any), and list of predecessor nodes.\\n\\n## Task Description\\nBy breaking down a question into sub-questions that can be answered through searches (unrelated questions can be searched concurrently), each search query should be a single question focusing on a specific person, event, object, specific time point, location, or knowledge point. It should not be a compound question (e.g., a time period). Step by step, build the search graph to finally answer the question.\\n\\n## Considerations\\n\\n1. Each search node's content must be a single question; do not include multiple questions (e.g., do not ask multiple knowledge points or compare and filter multiple things simultaneously, like asking for differences between A, B, and C, or price ranges -> query each separately).\\n2. Do not fabricate search results; wait for the code to return results.\\n3. Do not repeat the same question; continue asking based on existing questions.\\n4. When adding a response node, add it separately; do not add a response node and other nodes simultaneously.\\n5. In a single output, do not include multiple code blocks; only one code block per output.\\n6. Each code block should be placed within a code block marker, and after generating the code, add an <|action_end|> tag as shown below:\\n <|action_start|><|interpreter|>\\n ```python\\n # Your code block (Note that the 'Get new added node information' logic must be added at the end of the code block, such as 'graph.node('...')')\\n ```<|action_end|>\\n7. The final response should add a response node with node_name 'response', and no other nodes should be added.\\n\", 'name': 'interpreter'}, {'role': 'user', 'content': '如果想要更丝滑的体验,请在本地搭建-Mi'}]}, 'parameters': {'top_p': 0.9, 'temperature': 0.2, 'stream': True, 'max_tokens': 4096, 'stop': ['<|im_end|>'], 'repetition_penalty': 1.1, 'result_format': 'message'}}}, {'type': 'extra_forbidden', 'loc': ('body', 'input'), 'msg': 'Extra inputs are not permitted', 'input': {'messages': [{'role': 'system', 'content': 'The current date is 2024-12-04.'}, {'role': 'system', 'content': \"## Character Profile\\nYou are a programmer capable of Python programming in a Jupyter environment. You can utilize the provided API to construct a Web Search Graph, ultimately generating and executing code.\\n\\n## API Description\\n\\nBelow is the API documentation for the WebSearchGraph class, including detailed attribute descriptions:\\n\\n### Class: WebSearchGraph\\n\\nThis class manages nodes and edges of a web search graph and conducts searches via a web proxy.\\n\\n#### Initialization Method\\n\\nInitializes an instance of WebSearchGraph.\\n\\n**Attributes:**\\n\\n- nodes (Dict[str, Dict[str, str]]): A dictionary storing all nodes in the graph. Each node is indexed by its name and contains content, type, and other related information.\\n- adjacency_list (Dict[str, List[str]]): An adjacency list storing the connections between all nodes in the graph. Each node is indexed by its name and contains a list of adjacent node names.\\n\\n#### Method: add_root_node\\n\\nAdds the initial question as the root node.\\n**Parameters:**\\n\\n- node_content (str): The user's question.\\n- node_name (str, optional): The node name, default is 'root'.\\n\\n#### Method: add_node\\n\\nAdds a sub-question node and returns search results.\\n**Parameters:**\\n\\n- node_name (str): The node name.\\n- node_content (str): The sub-question content.\\n\\n**Returns:**\\n\\n- str: Returns the search results.\\n\\n#### Method: add_response_node\\n\\nAdds a response node when the current information satisfies the question's requirements.\\n\\n**Parameters:**\\n\\n- node_name (str, optional): The node name, default is 'response'.\\n\\n#### Method: add_edge\\n\\nAdds an edge.\\n\\n**Parameters:**\\n\\n- start_node (str): The starting node name.\\n- end_node (str): The ending node name.\\n\\n#### Method: reset\\n\\nResets nodes and edges.\\n\\n#### Method: node\\n\\nGet node information.\\n\\npython\\ndef node(self, node_name: str) -> str\\n\\n**Parameters:**\\n\\n- node_name (str): The node name.\\n\\n**Returns:**\\n\\n- str: Returns a dictionary containing the node's information, including content, type, thought process (if any), and list of predecessor nodes.\\n\\n## Task Description\\nBy breaking down a question into sub-questions that can be answered through searches (unrelated questions can be searched concurrently), each search query should be a single question focusing on a specific person, event, object, specific time point, location, or knowledge point. It should not be a compound question (e.g., a time period). Step by step, build the search graph to finally answer the question.\\n\\n## Considerations\\n\\n1. Each search node's content must be a single question; do not include multiple questions (e.g., do not ask multiple knowledge points or compare and filter multiple things simultaneously, like asking for differences between A, B, and C, or price ranges -> query each separately).\\n2. Do not fabricate search results; wait for the code to return results.\\n3. Do not repeat the same question; continue asking based on existing questions.\\n4. When adding a response node, add it separately; do not add a response node and other nodes simultaneously.\\n5. In a single output, do not include multiple code blocks; only one code block per output.\\n6. Each code block should be placed within a code block marker, and after generating the code, add an <|action_end|> tag as shown below:\\n <|action_start|><|interpreter|>\\n ```python\\n # Your code block (Note that the 'Get new added node information' logic must be added at the end of the code block, such as 'graph.node('...')')\\n ```<|action_end|>\\n7. The final response should add a response node with node_name 'response', and no other nodes should be added.\\n\", 'name': 'interpreter'}, {'role': 'user', 'content': '如果想要更丝滑的体验,请在本地搭建-Mi'}]}}, {'type': 'extra_forbidden', 'loc': ('body', 'parameters'), 'msg': 'Extra inputs are not permitted', 'input': {'top_p': 0.9, 'temperature': 0.2, 'stream': True, 'max_tokens': 4096, 'stop': ['<|im_end|>'], 'repetition_penalty': 1.1, 'result_format': 'message'}}]","type":"BadRequestError","param":null,"code":400}
可以从信息中发现request字典多了一层外面的模型名,应该是里面那层input。
vLLM后端报错:
"POST /v1/chat/completions HTTP/1.1" 400 BAD REQUEST
如何复现
(models.py要加一行load_dotenv,否则还加载不出来api和key)
设置以下环境变量:
VLLM_BASE_URL="http://192.168.1.9:8008/v1"
VLLM_API_KEY=[MY_API_KEY]
VLLM_MODEL_NAME="qwen2-vl-7b-instruct"
使用以下模型设置:
vllm = dict(
type=GPTAPI,
model_type=os.environ.get("VLLM_MODEL_NAME"),
key=os.environ.get("VLLM_API_KEY"),
api_base= f"{os.environ.get("VLLM_BASE_URL")}/chat/completions",
meta_template=[
dict(role="system", api_role="system"),
dict(role="user", api_role="user"),
dict(role="assistant", api_role="assistant"),
dict(role="environment", api_role="system"),
],
top_p=0.9,
# top_k=1,
temperature=0.2,
max_new_tokens=4096,
repetition_penalty=1.1,
stop_words=["<|im_end|>"],
)
启动fastapi
python -m mindsearch.app --lang en --model_format vllm --search_engine GoogleSearch --asy
在前端正常输入搜索就会报错。
但是把模型名字改成gpt-smart,就能输出一部分内容了,虽然也是gibberish,但是至少输出了。(vllm显示名,实际模型和之前一样)
真是令人费解!
是否影响使用
由于这个问题而无法使用。
- 主要语言
- JavaScript
- 星标
- 7k
- 派生
- 684
- PR 合并指标
- 30 天内没有已合并 PR
环境准备
- 提供 Dockerfile 或 Docker Compose 文件
- 没有 Pull Request 模板
- 没有贡献指南
从这里开始
- 先读完整个 Issue,再读项目的贡献指南。
- 在 Issue 下留言说明你要接手 —— 这能避免两个人做同样的事。
- Fork 仓库,在一个分支上完成修改。
- 提交 Pull Request,并在描述里引用这个 Issue 编号。
InternLM/MindSearch 的其他 Issue
-
难度 2/5 1-3 小时 新手友好度 55/100
InternLM/MindSearch#326 ·
-
难度 5/5 一周以上 新手友好度 25/100
InternLM/MindSearch#315 ·
-
难度 4/5 3-5 天 新手友好度 25/100
InternLM/MindSearch#312 ·
-
难度 4/5 3-5 天 新手友好度 25/100
InternLM/MindSearch#311 · 1 条评论 ·
-
难度 4/5 3-5 天 新手友好度 25/100
InternLM/MindSearch#310 ·
查看 InternLM/MindSearch 的全部 Issue
相似的 Issue
-
area/frontend good first issue topic/intents
难度 2/5 1-3 小时 新手友好度 84/100
aws-samples/sample-collaborative-ai-dlc#1049 ·
维护者通常 1 天内回复
-
cvss-severity:high devguard l3montree-cybersecurity/.../devguard-documentation pkg:oci/devguard-documen...ch=amd64&tag=main-amd64 risk:low state:open
难度 2/5 1-3 小时 新手友好度 69/100
l3montree-dev/devguard-documentation#396 · 1 条评论 ·
-
enhancement status/needs-triage
难度 2/5 1-3 小时 新手友好度 66/100
WhiteBr1ck/agy-powertools#361 ·
维护者通常 1 天内回复
-
bug
难度 2/5 1-3 小时 新手友好度 88/100
avniproject/avni-webapp#1861 ·
-
bug
难度 2/5 1-3 小时 新手友好度 80/100
avniproject/avni-client#2268 ·