WIP v0.2.0: pannello /endpoint e nomi abbreviati dei modelli (in pausa, non compilato)
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
@@ -21,6 +21,8 @@ use http::header::HeaderValue;
|
||||
use schemars::JsonSchema;
|
||||
use serde::Deserialize;
|
||||
use serde::Serialize;
|
||||
use akode_protocol::openai_models::ReasoningEffort;
|
||||
use std::collections::BTreeMap;
|
||||
use std::collections::HashMap;
|
||||
use std::fmt;
|
||||
use std::num::NonZeroU64;
|
||||
@@ -218,6 +220,10 @@ pub struct ModelProviderInfo {
|
||||
/// Whether this provider supports the standalone web-search endpoint.
|
||||
#[serde(default)]
|
||||
pub supports_standalone_web_search: bool,
|
||||
/// Per-model settings keyed by model id (`[model_providers.<id>.models."<model id>"]`).
|
||||
/// A value set here wins over the matching global setting (e.g. `model_context_window`).
|
||||
#[serde(default, skip_serializing_if = "BTreeMap::is_empty")]
|
||||
pub models: BTreeMap<String, ProviderModelSettings>,
|
||||
/// Runtime-only opt-in for internal metadata, independent of the destination check.
|
||||
/// This cannot be loaded from or written to serialized provider configuration.
|
||||
#[serde(skip)]
|
||||
@@ -230,6 +236,31 @@ pub struct ModelProviderInfo {
|
||||
pub keyring_account: Option<String>,
|
||||
}
|
||||
|
||||
/// Settings for one model of a provider. Every value is optional; unset values fall back to
|
||||
/// the global settings, then to what the server reports, then to the defaults.
|
||||
#[derive(Debug, Clone, Default, Deserialize, Serialize, PartialEq, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
pub struct ProviderModelSettings {
|
||||
/// Context window in tokens (wins over `model_context_window`).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub context_window: Option<i64>,
|
||||
/// Sampling temperature sent with each request.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub temperature: Option<f64>,
|
||||
/// Nucleus sampling (`top_p`) sent with each request.
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub top_p: Option<f64>,
|
||||
/// Maximum output tokens per response (`max_output_tokens`).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub max_output_tokens: Option<u64>,
|
||||
/// Reasoning effort (wins over `model_reasoning_effort`).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub reasoning_effort: Option<ReasoningEffort>,
|
||||
/// Name shown in the interface instead of the model id (the API always gets the id).
|
||||
#[serde(default, skip_serializing_if = "Option::is_none")]
|
||||
pub display_name: Option<String>,
|
||||
}
|
||||
|
||||
/// Command used to export credentials for a model provider.
|
||||
#[derive(Debug, Clone, Deserialize, Serialize, PartialEq, Eq, JsonSchema)]
|
||||
#[schemars(deny_unknown_fields)]
|
||||
@@ -304,6 +335,11 @@ pub fn provider_api_key_keyring_account(provider_id: &str) -> String {
|
||||
}
|
||||
|
||||
impl ModelProviderInfo {
|
||||
/// Settings configured for `model`, if any.
|
||||
pub fn model_settings(&self, model: &str) -> Option<&ProviderModelSettings> {
|
||||
self.models.get(model)
|
||||
}
|
||||
|
||||
pub fn validate(&self) -> std::result::Result<(), String> {
|
||||
if let Some(gateway) = &self.gateway_oauth {
|
||||
gateway.validate(self)?;
|
||||
@@ -613,6 +649,7 @@ pub fn create_oss_provider_with_base_url(base_url: &str, wire_api: WireApi) -> M
|
||||
merge_system_messages: None,
|
||||
include_internal_metadata: false,
|
||||
keyring_account: None,
|
||||
models: Default::default(),
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -103,6 +103,7 @@ base_url = "http://localhost:11434/v1"
|
||||
merge_system_messages: None,
|
||||
keyring_account: None,
|
||||
include_internal_metadata: false,
|
||||
models: Default::default(),
|
||||
};
|
||||
|
||||
let provider: ModelProviderInfo = toml::from_str(azure_provider_toml).unwrap();
|
||||
@@ -144,6 +145,7 @@ query_params = { api-version = "2025-04-01-preview" }
|
||||
merge_system_messages: None,
|
||||
keyring_account: None,
|
||||
include_internal_metadata: false,
|
||||
models: Default::default(),
|
||||
};
|
||||
|
||||
let provider: ModelProviderInfo = toml::from_str(azure_provider_toml).unwrap();
|
||||
@@ -189,6 +191,7 @@ supports_standalone_web_search = true
|
||||
merge_system_messages: None,
|
||||
keyring_account: None,
|
||||
include_internal_metadata: false,
|
||||
models: Default::default(),
|
||||
};
|
||||
|
||||
let provider: ModelProviderInfo = toml::from_str(azure_provider_toml).unwrap();
|
||||
|
||||
Reference in New Issue
Block a user