open_ai: Configurable model capabilities
This commit is contained in:
parent
f17f63ec84
commit
de9d470e4f
1 changed files with 27 additions and 8 deletions
|
@ -38,6 +38,27 @@ pub struct AvailableModel {
|
||||||
pub max_tokens: u64,
|
pub max_tokens: u64,
|
||||||
pub max_output_tokens: Option<u64>,
|
pub max_output_tokens: Option<u64>,
|
||||||
pub max_completion_tokens: Option<u64>,
|
pub max_completion_tokens: Option<u64>,
|
||||||
|
#[serde(default)]
|
||||||
|
pub capabilities: ModelCapabilities,
|
||||||
|
}
|
||||||
|
|
||||||
|
#[derive(Clone, Debug, PartialEq, Serialize, Deserialize, JsonSchema)]
|
||||||
|
pub struct ModelCapabilities {
|
||||||
|
pub tools: bool,
|
||||||
|
pub images: bool,
|
||||||
|
pub parallel_tool_calls: bool,
|
||||||
|
pub prompt_cache_key: bool,
|
||||||
|
}
|
||||||
|
|
||||||
|
impl Default for ModelCapabilities {
|
||||||
|
fn default() -> Self {
|
||||||
|
Self {
|
||||||
|
tools: true,
|
||||||
|
images: false,
|
||||||
|
parallel_tool_calls: false,
|
||||||
|
prompt_cache_key: false,
|
||||||
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
pub struct OpenAiCompatibleLanguageModelProvider {
|
pub struct OpenAiCompatibleLanguageModelProvider {
|
||||||
|
@ -293,17 +314,17 @@ impl LanguageModel for OpenAiCompatibleLanguageModel {
|
||||||
}
|
}
|
||||||
|
|
||||||
fn supports_tools(&self) -> bool {
|
fn supports_tools(&self) -> bool {
|
||||||
true
|
self.model.capabilities.tools
|
||||||
}
|
}
|
||||||
|
|
||||||
fn supports_images(&self) -> bool {
|
fn supports_images(&self) -> bool {
|
||||||
false
|
self.model.capabilities.images
|
||||||
}
|
}
|
||||||
|
|
||||||
fn supports_tool_choice(&self, choice: LanguageModelToolChoice) -> bool {
|
fn supports_tool_choice(&self, choice: LanguageModelToolChoice) -> bool {
|
||||||
match choice {
|
match choice {
|
||||||
LanguageModelToolChoice::Auto => true,
|
LanguageModelToolChoice::Auto => self.model.capabilities.tools,
|
||||||
LanguageModelToolChoice::Any => true,
|
LanguageModelToolChoice::Any => self.model.capabilities.tools,
|
||||||
LanguageModelToolChoice::None => true,
|
LanguageModelToolChoice::None => true,
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
@ -355,13 +376,11 @@ impl LanguageModel for OpenAiCompatibleLanguageModel {
|
||||||
LanguageModelCompletionError,
|
LanguageModelCompletionError,
|
||||||
>,
|
>,
|
||||||
> {
|
> {
|
||||||
let supports_parallel_tool_call = true;
|
|
||||||
let supports_prompt_cache_key = false;
|
|
||||||
let request = into_open_ai(
|
let request = into_open_ai(
|
||||||
request,
|
request,
|
||||||
&self.model.name,
|
&self.model.name,
|
||||||
supports_parallel_tool_call,
|
self.model.capabilities.parallel_tool_calls,
|
||||||
supports_prompt_cache_key,
|
self.model.capabilities.prompt_cache_key,
|
||||||
self.max_output_tokens(),
|
self.max_output_tokens(),
|
||||||
None,
|
None,
|
||||||
);
|
);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue