Add tool use support for OpenAI models (#28051)

This PR adds support for using tools to the OpenAI models.

Release Notes:

- agent: Added support for tool use with OpenAI models (Preview only).
This commit is contained in:
Marshall Bowers 2025-04-03 16:55:11 -04:00 committed by GitHub
parent 4d8df0a00b
commit 7492ec3f67
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
3 changed files with 188 additions and 48 deletions

View file

@ -2,7 +2,7 @@ mod supported_countries;
use anyhow::{Context as _, Result, anyhow};
use futures::{
AsyncBufReadExt, AsyncReadExt, Stream, StreamExt,
AsyncBufReadExt, AsyncReadExt, StreamExt,
io::BufReader,
stream::{self, BoxStream},
};
@ -618,14 +618,3 @@ pub fn embed<'a>(
}
}
}
pub fn extract_text_from_events(
response: impl Stream<Item = Result<ResponseStreamEvent>>,
) -> impl Stream<Item = Result<String>> {
response.filter_map(|response| async move {
match response {
Ok(mut response) => Some(Ok(response.choices.pop()?.delta.content?)),
Err(error) => Some(Err(error)),
}
})
}