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]
53 pub const fn surface(self) -> ApiSurface {
54 match self {
55 Self::Anthropic => ApiSurface::Anthropic,
56 Self::OpenAiChat | Self::OpenAiResponses => ApiSurface::OpenAi,
57 Self::Gemini => ApiSurface::Gemini,
58 }
59 }
60
61 #[must_use]
62 pub const fn schema_capabilities(self) -> ProviderCapabilities {
63 match self {
64 Self::Anthropic => ProviderCapabilities::anthropic(),
65 Self::OpenAiChat | Self::OpenAiResponses => ProviderCapabilities::openai(),
66 Self::Gemini => ProviderCapabilities::gemini(),
67 }
68 }
69}
70
71impl std::fmt::Display for WireProtocol {
72 fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result {
73 f.write_str(self.as_tag())
74 }
75}