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:
parent
4d8df0a00b
commit
7492ec3f67
3 changed files with 188 additions and 48 deletions
|
@ -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)),
|
||||
}
|
||||
})
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue