feat: add Avian as an LLM provider (#7561)
Signed-off-by: Kyle D <deximia@hotmail.com>
This commit is contained in:
@@ -0,0 +1,60 @@
|
||||
use super::api_client::{ApiClient, AuthMethod};
|
||||
use super::base::{ConfigKey, ProviderDef, ProviderMetadata};
|
||||
use super::openai_compatible::OpenAiCompatibleProvider;
|
||||
use crate::model::ModelConfig;
|
||||
use anyhow::Result;
|
||||
use futures::future::BoxFuture;
|
||||
|
||||
const AVIAN_PROVIDER_NAME: &str = "avian";
|
||||
pub const AVIAN_API_HOST: &str = "https://api.avian.io/v1";
|
||||
pub const AVIAN_DEFAULT_MODEL: &str = "deepseek/deepseek-v3.2";
|
||||
pub const AVIAN_KNOWN_MODELS: &[&str] = &[
|
||||
"deepseek/deepseek-v3.2",
|
||||
"moonshotai/kimi-k2.5",
|
||||
"z-ai/glm-5",
|
||||
"minimax/minimax-m2.5",
|
||||
];
|
||||
pub const AVIAN_DOC_URL: &str = "https://avian.io/docs";
|
||||
|
||||
pub struct AvianProvider;
|
||||
|
||||
impl ProviderDef for AvianProvider {
|
||||
type Provider = OpenAiCompatibleProvider;
|
||||
|
||||
fn metadata() -> ProviderMetadata {
|
||||
ProviderMetadata::new(
|
||||
AVIAN_PROVIDER_NAME,
|
||||
"Avian",
|
||||
"Cost-effective inference API with DeepSeek, Kimi, GLM, and MiniMax models",
|
||||
AVIAN_DEFAULT_MODEL,
|
||||
AVIAN_KNOWN_MODELS.to_vec(),
|
||||
AVIAN_DOC_URL,
|
||||
vec![
|
||||
ConfigKey::new("AVIAN_API_KEY", true, true, None, true),
|
||||
ConfigKey::new("AVIAN_HOST", false, false, Some(AVIAN_API_HOST), false),
|
||||
],
|
||||
)
|
||||
}
|
||||
|
||||
fn from_env(
|
||||
model: ModelConfig,
|
||||
_extensions: Vec<crate::config::ExtensionConfig>,
|
||||
) -> BoxFuture<'static, Result<OpenAiCompatibleProvider>> {
|
||||
Box::pin(async move {
|
||||
let config = crate::config::Config::global();
|
||||
let api_key: String = config.get_secret("AVIAN_API_KEY")?;
|
||||
let host: String = config
|
||||
.get_param("AVIAN_HOST")
|
||||
.unwrap_or_else(|_| AVIAN_API_HOST.to_string());
|
||||
|
||||
let api_client = ApiClient::new(host, AuthMethod::BearerToken(api_key))?;
|
||||
|
||||
Ok(OpenAiCompatibleProvider::new(
|
||||
AVIAN_PROVIDER_NAME.to_string(),
|
||||
api_client,
|
||||
model,
|
||||
String::new(),
|
||||
))
|
||||
})
|
||||
}
|
||||
}
|
||||
@@ -2,6 +2,7 @@ use std::sync::{Arc, RwLock};
|
||||
|
||||
use super::{
|
||||
anthropic::AnthropicProvider,
|
||||
avian::AvianProvider,
|
||||
azure::AzureProvider,
|
||||
base::{Provider, ProviderMetadata},
|
||||
bedrock::BedrockProvider,
|
||||
@@ -46,6 +47,7 @@ static REGISTRY: OnceCell<RwLock<ProviderRegistry>> = OnceCell::const_new();
|
||||
async fn init_registry() -> RwLock<ProviderRegistry> {
|
||||
let mut registry = ProviderRegistry::new().with_providers(|registry| {
|
||||
registry.register::<AnthropicProvider>(true);
|
||||
registry.register::<AvianProvider>(false);
|
||||
registry.register::<AzureProvider>(false);
|
||||
registry.register::<BedrockProvider>(false);
|
||||
registry.register::<LocalInferenceProvider>(false);
|
||||
|
||||
@@ -1,6 +1,7 @@
|
||||
pub mod anthropic;
|
||||
pub mod api_client;
|
||||
pub mod auto_detect;
|
||||
pub mod avian;
|
||||
pub mod azure;
|
||||
pub mod azureauth;
|
||||
pub mod base;
|
||||
|
||||
Reference in New Issue
Block a user