#[non_exhaustive]pub enum ApiProtocol {
OpenAiChat,
Anthropic,
}Expand description
The wire protocol an endpoint exposes.
Selects the request path, the authentication header, the request body shape and the
streaming event vocabulary. Defaults to ApiProtocol::OpenAiChat, which is what every
endpoint the SDK supported before 0.9.0 speaks.
§Examples
use open_agent::ApiProtocol;
assert_eq!(ApiProtocol::default(), ApiProtocol::OpenAiChat);
assert_eq!(ApiProtocol::Anthropic.path(), "/messages");Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
OpenAiChat
OpenAI chat completions: POST {base_url}/chat/completions, bearer auth.
Anthropic
Anthropic messages: POST {base_url}/messages, x-api-key auth.
Implementations§
Source§impl ApiProtocol
impl ApiProtocol
Sourcepub fn path(&self) -> &'static str
pub fn path(&self) -> &'static str
The path appended to base_url to reach the completion endpoint.
Includes the leading slash, because base_url is documented as carrying no trailing
one.
Sourcepub fn as_str(&self) -> &'static str
pub fn as_str(&self) -> &'static str
The lowercase name used in configuration files and diagnostics.
Sourcepub fn from_wire(raw: &str) -> Option<Self>
pub fn from_wire(raw: &str) -> Option<Self>
Parses a protocol name, ASCII-case-insensitively.
Returns None for anything unrecognised, so a caller reading a config file can name
the offending value in its own error rather than silently falling back to a default
the user did not ask for.
openai is accepted alongside openai-chat and openai_chat: configuration files
in the wild write it every way, and rejecting the short form would be a trap with no
upside.
§Examples
use open_agent::ApiProtocol;
assert_eq!(ApiProtocol::from_wire("Anthropic"), Some(ApiProtocol::Anthropic));
assert_eq!(ApiProtocol::from_wire("openai_chat"), Some(ApiProtocol::OpenAiChat));
assert_eq!(ApiProtocol::from_wire("cohere"), None);Trait Implementations§
Source§impl Clone for ApiProtocol
impl Clone for ApiProtocol
Source§fn clone(&self) -> ApiProtocol
fn clone(&self) -> ApiProtocol
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
source. Read moreimpl Copy for ApiProtocol
Source§impl Debug for ApiProtocol
impl Debug for ApiProtocol
Source§impl Default for ApiProtocol
impl Default for ApiProtocol
Source§fn default() -> ApiProtocol
fn default() -> ApiProtocol
Source§impl Display for ApiProtocol
impl Display for ApiProtocol
impl Eq for ApiProtocol
Source§impl PartialEq for ApiProtocol
impl PartialEq for ApiProtocol
impl StructuralPartialEq for ApiProtocol
Auto Trait Implementations§
impl Freeze for ApiProtocol
impl RefUnwindSafe for ApiProtocol
impl Send for ApiProtocol
impl Sync for ApiProtocol
impl Unpin for ApiProtocol
impl UnsafeUnpin for ApiProtocol
impl UnwindSafe for ApiProtocol
Blanket Implementations§
Source§impl<T> BorrowMut<T> for Twhere
T: ?Sized,
impl<T> BorrowMut<T> for Twhere
T: ?Sized,
Source§fn borrow_mut(&mut self) -> &mut T
fn borrow_mut(&mut self) -> &mut T
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§impl<Q, K> Equivalent<K> for Q
impl<Q, K> Equivalent<K> for Q
Source§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
key and return true if they are equal.