systemprompt_models/profile/providers/
protocol.rs1use serde::{Deserialize, Serialize};
11
12use super::surface::ApiSurface;
13use crate::schema::ProviderCapabilities;
14
15#[derive(Debug, Clone, Copy, PartialEq, Eq, Hash, Serialize, Deserialize, schemars::JsonSchema)]
16pub enum WireProtocol {
17 #[serde(rename = "anthropic")]
18 Anthropic,
19 #[serde(rename = "openai-chat", alias = "openai_chat", alias = "openai")]
20 OpenAiChat,
21 #[serde(rename = "openai-responses", alias = "openai_responses")]
22 OpenAiResponses,
23 #[serde(rename = "gemini")]
24 Gemini,
25}
26
27impl WireProtocol {
28 #[must_use]
29 pub const fn as_tag(self) -> &'static str {
30 match self {
31 Self::Anthropic => "anthropic",
32 Self::OpenAiChat => "openai-chat",
33 Self::OpenAiResponses => "openai-responses",
34 Self::Gemini => "gemini",
35 }
36 }
37
38 #[must_use]
39 pub fn from_tag(tag: &str) -> Option<Self> {
40 match tag {
41 "anthropic" => Some(Self::Anthropic),
42 "openai-chat" | "openai_chat" | "openai" => Some(Self::OpenAiChat),
43 "openai-responses" | "openai_responses" => Some(Self::OpenAiResponses),
44 "gemini" => Some(Self::Gemini),
45 _ => None,
46 }
47 }
48
49 #[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}