language_models: Use JsonSchemaSubset
for Gemini models in OpenRouter (#33477)
Closes #33466 Release Notes: - N/A
This commit is contained in:
parent
e3ce0618a3
commit
3ab4ad6de8
1 changed files with 11 additions and 2 deletions
|
@ -11,8 +11,8 @@ use language_model::{
|
|||
AuthenticateError, LanguageModel, LanguageModelCompletionError, LanguageModelCompletionEvent,
|
||||
LanguageModelId, LanguageModelName, LanguageModelProvider, LanguageModelProviderId,
|
||||
LanguageModelProviderName, LanguageModelProviderState, LanguageModelRequest,
|
||||
LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolUse, MessageContent,
|
||||
RateLimiter, Role, StopReason, TokenUsage,
|
||||
LanguageModelToolChoice, LanguageModelToolResultContent, LanguageModelToolSchemaFormat,
|
||||
LanguageModelToolUse, MessageContent, RateLimiter, Role, StopReason, TokenUsage,
|
||||
};
|
||||
use open_router::{
|
||||
Model, ModelMode as OpenRouterModelMode, ResponseStreamEvent, list_models, stream_completion,
|
||||
|
@ -374,6 +374,15 @@ impl LanguageModel for OpenRouterLanguageModel {
|
|||
self.model.supports_tool_calls()
|
||||
}
|
||||
|
||||
fn tool_input_format(&self) -> LanguageModelToolSchemaFormat {
|
||||
let model_id = self.model.id().trim().to_lowercase();
|
||||
if model_id.contains("gemini") {
|
||||
LanguageModelToolSchemaFormat::JsonSchemaSubset
|
||||
} else {
|
||||
LanguageModelToolSchemaFormat::JsonSchema
|
||||
}
|
||||
}
|
||||
|
||||
fn telemetry_id(&self) -> String {
|
||||
format!("openrouter/{}", self.model.id())
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue