systemprompt_models/
providers.rs1use serde::{Deserialize, Serialize};
19
20#[derive(
21 Debug,
22 Clone,
23 Copy,
24 PartialEq,
25 Eq,
26 PartialOrd,
27 Ord,
28 Hash,
29 Serialize,
30 Deserialize,
31 schemars::JsonSchema,
32)]
33#[serde(rename_all = "lowercase")]
34pub enum ClientFamily {
35 Claude,
36 #[serde(rename = "openai")]
37 OpenAi,
38 Gemini,
39}
40
41impl ClientFamily {
42 pub const ALL: [Self; 3] = [Self::Claude, Self::OpenAi, Self::Gemini];
43
44 #[must_use]
45 pub const fn as_tag(self) -> &'static str {
46 match self {
47 Self::Claude => "claude",
48 Self::OpenAi => "openai",
49 Self::Gemini => "gemini",
50 }
51 }
52
53 #[must_use]
54 pub fn from_tag(tag: &str) -> Option<Self> {
55 Self::ALL.into_iter().find(|family| family.as_tag() == tag)
56 }
57}
58
59impl std::fmt::Display for ClientFamily {
60 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
61 f.write_str(self.as_tag())
62 }
63}
64
65pub const CONTEXT_VARIANT_SUFFIX: &str = "[1m]";
70
71pub const LONG_CONTEXT_WINDOW: u32 = 1_000_000;
72
73#[must_use]
74pub fn without_context_variant(requested: &str) -> &str {
75 requested
76 .strip_suffix(CONTEXT_VARIANT_SUFFIX)
77 .unwrap_or(requested)
78}
79
80#[must_use]
81pub fn has_context_variant(requested: &str) -> bool {
82 requested.ends_with(CONTEXT_VARIANT_SUFFIX)
83}
84
85#[must_use]
86pub fn with_context_variant(model: &str) -> String {
87 format!("{}{CONTEXT_VARIANT_SUFFIX}", without_context_variant(model))
88}