systemprompt_models/profile/providers/
protocol.rs1use serde::{Deserialize, Serialize};
14
15use super::surface::ApiSurface;
16use crate::schema::ProviderCapabilities;
17
18#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, schemars::JsonSchema)]
19pub enum WireProtocol {
20 #[serde(rename = "anthropic")]
21 Anthropic,
22 #[serde(rename = "openai-chat", alias = "openai_chat", alias = "openai")]
23 OpenAiChat,
24 #[serde(rename = "openai-responses", alias = "openai_responses")]
25 OpenAiResponses,
26 #[serde(rename = "gemini")]
27 Gemini,
28}
29
30impl WireProtocol {
31 #[must_use]
32 pub const fn as_tag(self) -> &'static str {
33 match self {
34 Self::Anthropic => "anthropic",
35 Self::OpenAiChat => "openai-chat",
36 Self::OpenAiResponses => "openai-responses",
37 Self::Gemini => "gemini",
38 }
39 }
40
41 #[must_use]
42 pub fn from_tag(tag: &str) -> Option<Self> {
43 match tag {
44 "anthropic" => Some(Self::Anthropic),
45 "openai-chat" | "openai_chat" | "openai" => Some(Self::OpenAiChat),
46 "openai-responses" | "openai_responses" => Some(Self::OpenAiResponses),
47 "gemini" => Some(Self::Gemini),
48 _ => None,
49 }
50 }
51
52 #[must_use]
56 pub const fn surface(self) -> ApiSurface {
57 match self {
58 Self::Anthropic => ApiSurface::Anthropic,
59 Self::OpenAiChat | Self::OpenAiResponses => ApiSurface::OpenAi,
60 Self::Gemini => ApiSurface::Gemini,
61 }
62 }
63
64 #[must_use]
65 pub const fn schema_capabilities(self) -> ProviderCapabilities {
66 match self {
67 Self::Anthropic => ProviderCapabilities::anthropic(),
68 Self::OpenAiChat | Self::OpenAiResponses => ProviderCapabilities::openai(),
69 Self::Gemini => ProviderCapabilities::gemini(),
70 }
71 }
72}
73
74impl std::fmt::Display for WireProtocol {
75 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
76 f.write_str(self.as_tag())
77 }
78}