interplane.Get Omega
Read in your language

spark-adapters

Hardware abstraction adapters for local AI accelerators

Brought by drakestapleton

branch main Branches Tags History

spark-adapters / src / providers / mod.rs

36 lines · 1063 bytes Raw Blame History
1pub mod anthropic;
2pub mod openai;
3
4pub use anthropic::*;
5pub use openai::*;
6
7use reqwest::Client;
8use crate::models::{ChatMessage, ProviderType};
9
10pub async fn call_provider_unary(
11 client: &Client,
12 provider: ProviderType,
13 endpoint: &str,
14 model: &str,
15 api_key: Option<&str>,
16 messages: &[ChatMessage],
17 temperature: Option<f32>,
18) -> Result<(String, Option<String>, usize), String> {
19 match provider {
20 ProviderType::Anthropic => {
21 let key = api_key.ok_or_else(|| "Anthropic requires an API key".to_string())?;
22 call_anthropic_unary(client, endpoint, model, key, messages, temperature).await
23 }
24 ProviderType::OpenAI
25 | ProviderType::OpenRouter
26 | ProviderType::Gemini
27 | ProviderType::Groq
28 | ProviderType::DeepSeek
29 | ProviderType::Together
30 | ProviderType::Mistral
31 | ProviderType::Ollama
32 | ProviderType::LocalMax => {
33 call_openai_unary(client, endpoint, model, api_key, messages, temperature).await
34 }
35 }
36}