Open 18600709862 opened 4 weeks ago
Running this example encountered the same problem.
我也是这样报这个错误有人解决吗?
我发现了一个简陋的解决方案。
首先说明一下我认为的问题所在:
通过debug观察swarm的执行记录并对比qwen-agent提供的vllm执行记录可以发现swarm在执行过程中对message参数增加了一些信息,因此我们需要做的是消除这些冗余信息就行。
解决方法
version: 0.1.1
修改swarm/core.py文件
"tool_name": name,
2.修改ru()函数,如下:
def run(
self,
agent: Agent,
messages: List,
context_variables: dict = {},
model_override: str = None,
stream: bool = False,
debug: bool = False,
max_turns: int = float("inf"),
execute_tools: bool = True,
) -> Response:
if stream:
return self.run_and_stream(
agent=agent,
messages=messages,
context_variables=context_variables,
model_override=model_override,
debug=debug,
max_turns=max_turns,
execute_tools=execute_tools,
)
active_agent = agent
context_variables = copy.deepcopy(context_variables)
history = copy.deepcopy(messages)
history_for_show = copy.deepcopy(messages)
init_len = len(messages)
while len(history) - init_len < max_turns and active_agent:
# get completion with current history, agent
completion = self.get_chat_completion(
agent=active_agent,
history=history,
context_variables=context_variables,
model_override=model_override,
stream=stream,
debug=debug,
)
message = completion.choices[0].message
debug_print(debug, "Received completion:", message)
# message.sender = active_agent.name
history.append(
json.loads(message.model_dump_json())
) # to avoid OpenAI types (?)
message_for_show = copy.deepcopy(message)
message_for_show.sender = active_agent.name
history_for_show.append(
json.loads(message_for_show.model_dump_json())
)
if not message.tool_calls or not execute_tools:
debug_print(debug, "Ending turn.")
break
# handle function calls, updating context_variables, and switching agents
partial_response = self.handle_tool_calls(
message.tool_calls, active_agent.functions, context_variables, debug
)
history.extend(partial_response.messages)
history_for_show.extend(partial_response.messages)
context_variables.update(partial_response.context_variables)
if partial_response.agent:
active_agent = partial_response.agent
return Response(
messages=history_for_show[init_len:],
agent=active_agent,
context_variables=context_variables,
)
修改后的执行效果(swarm/examples/weather_agent):
Model Series
Qwen2.5
What are the models used?
Qwen2.5-72B-Instruct-AWQ
What is the scenario where the problem happened?
vllm启动
Is this a known issue?
Information about environment
OS: Ubuntu 22.04 Python: Python 3.11 GPUs: 4 x NVIDIA A20 NVIDIA driver: 535 (from nvidia-smi) CUDA compiler: 12.1 (from nvcc -V) PyTorch: 2.4.1+cu121 (from python -c "import troch; print(torch.version)")
Log output
Description
Steps to reproduce
Qwen2.5-72B-Instruct-AWQ
部署验证openai的swarm 地址https://github.com/openai/swarm
swarm/examples/basic
1、vim function_calling.py
Expected results
使用ollama运行 qwen2.5:72b 可以正确得到调用结果
然而使用vllm
不能得到调用结果
日志显示
这里是否是vllm启动参数设置问题,还是没有正确启动。
Attempts to fix
没有效果
Anything else helpful for investigation