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
|
@ -587,7 +587,7 @@ impl LanguageModel for CloudLanguageModel {
|
|||
match self.model {
|
||||
CloudModel::Anthropic(_) => true,
|
||||
CloudModel::Google(_) => true,
|
||||
CloudModel::OpenAi(_) => false,
|
||||
CloudModel::OpenAi(_) => true,
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -705,15 +705,13 @@ impl LanguageModel for CloudLanguageModel {
|
|||
},
|
||||
)
|
||||
.await?;
|
||||
Ok(open_ai::extract_text_from_events(response_lines(response)))
|
||||
Ok(
|
||||
crate::provider::open_ai::map_to_language_model_completion_events(
|
||||
Box::pin(response_lines(response)),
|
||||
),
|
||||
)
|
||||
});
|
||||
async move {
|
||||
Ok(future
|
||||
.await?
|
||||
.map(|result| result.map(LanguageModelCompletionEvent::Text))
|
||||
.boxed())
|
||||
}
|
||||
.boxed()
|
||||
async move { Ok(future.await?.boxed()) }.boxed()
|
||||
}
|
||||
CloudModel::Google(model) => {
|
||||
let client = self.client.clone();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue