openai: Don't append tool calls to prior assistant messages (#29969)
Closes https://github.com/zed-industries/zed/issues/29821 Release Notes: - Fixed an issue in the agent panel where OpenAI requests would fail if the assistant begins its response with a tool call.
This commit is contained in:
parent
55fd8352e4
commit
2eb10ab9fb
1 changed files with 4 additions and 8 deletions
|
@ -372,14 +372,10 @@ pub fn into_open_ai(
|
|||
},
|
||||
};
|
||||
|
||||
if let Some(last_assistant_message) = messages.iter_mut().rfind(|message| {
|
||||
matches!(message, open_ai::RequestMessage::Assistant { .. })
|
||||
}) {
|
||||
if let open_ai::RequestMessage::Assistant { tool_calls, .. } =
|
||||
last_assistant_message
|
||||
{
|
||||
tool_calls.push(tool_call);
|
||||
}
|
||||
if let Some(open_ai::RequestMessage::Assistant { tool_calls, .. }) =
|
||||
messages.last_mut()
|
||||
{
|
||||
tool_calls.push(tool_call);
|
||||
} else {
|
||||
messages.push(open_ai::RequestMessage::Assistant {
|
||||
content: None,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue