Skip to main content

rig_core/providers/doubleword/
client.rs

1use crate::client::{self, BearerAuth, DebugExt, Provider};
2
3// ================================================================
4// Doubleword Client
5// ================================================================
6// Base URL carries the `/v1`, so request paths are bare (`/chat/completions`).
7const DOUBLEWORD_API_BASE_URL: &str = "https://api.doubleword.ai/v1";
8
9#[derive(Debug, Default, Clone, Copy)]
10pub struct DoublewordExt;
11#[derive(Debug, Default, Clone, Copy)]
12pub struct DoublewordExtBuilder;
13
14type DoublewordApiKey = BearerAuth;
15
16pub type Client<H = reqwest::Client> = client::Client<DoublewordExt, H>;
17pub type ClientBuilder<H = crate::markers::Missing> =
18    client::ClientBuilder<DoublewordExtBuilder, DoublewordApiKey, H>;
19
20impl Provider for DoublewordExt {
21    type Builder = DoublewordExtBuilder;
22
23    const VERIFY_PATH: &'static str = "/models";
24}
25
26impl DebugExt for DoublewordExt {}
27
28impl crate::providers::openai::completion::OpenAICompatibleProvider for DoublewordExt {
29    const PROVIDER_NAME: &'static str = "doubleword";
30
31    type StreamingUsage = crate::providers::openai::Usage;
32    type Response = crate::providers::openai::CompletionResponse;
33}
34
35client::impl_capabilities!(
36    DoublewordExt,
37    completion = super::completion::CompletionModel<H>,
38    embeddings = super::EmbeddingModel<H>,
39);
40
41client::impl_default_provider_builder!(
42    DoublewordExtBuilder => DoublewordExt,
43    api_key = DoublewordApiKey,
44    base_url = DOUBLEWORD_API_BASE_URL,
45);
46
47client::impl_provider_client!(
48    Client,
49    input = String,
50    api_key_env = "DOUBLEWORD_API_KEY",
51    base_url_env_first = "DOUBLEWORD_BASE_URL",
52);
53
54#[cfg(test)]
55mod tests {
56    #[test]
57    fn test_client_initialization() {
58        let _client =
59            crate::providers::doubleword::Client::new("dummy-key").expect("Client::new() failed");
60        let _client_from_builder = crate::providers::doubleword::Client::builder()
61            .api_key("dummy-key")
62            .build()
63            .expect("Client::builder() failed");
64    }
65}