pub struct OpenAICompatProvider { /* private fields */ }Expand description
OpenAI-compatible API provider
Implementations§
Source§impl OpenAICompatProvider
impl OpenAICompatProvider
Sourcepub fn new(
provider_type: ProviderType,
name: impl Into<String>,
endpoint: impl Into<String>,
) -> Self
pub fn new( provider_type: ProviderType, name: impl Into<String>, endpoint: impl Into<String>, ) -> Self
Create a new OpenAI-compatible provider
Sourcepub fn with_api_key(self, api_key: impl Into<String>) -> Self
pub fn with_api_key(self, api_key: impl Into<String>) -> Self
Set API key
Sourcepub fn with_model(self, model: impl Into<String>) -> Self
pub fn with_model(self, model: impl Into<String>) -> Self
Set default model
Sourcepub fn with_data_path(self, path: PathBuf) -> Self
pub fn with_data_path(self, path: PathBuf) -> Self
Set local data path
Sourcepub fn session_to_messages(session: &ChatSession) -> Vec<OpenAIChatMessage>
pub fn session_to_messages(session: &ChatSession) -> Vec<OpenAIChatMessage>
Convert CSM session to OpenAI message format
Sourcepub fn messages_to_session(
messages: Vec<OpenAIChatMessage>,
model: &str,
provider_name: &str,
) -> ChatSession
pub fn messages_to_session( messages: Vec<OpenAIChatMessage>, model: &str, provider_name: &str, ) -> ChatSession
Convert OpenAI messages to CSM session
Trait Implementations§
Source§impl ChatProvider for OpenAICompatProvider
impl ChatProvider for OpenAICompatProvider
Source§fn provider_type(&self) -> ProviderType
fn provider_type(&self) -> ProviderType
Get the provider type
Source§fn is_available(&self) -> bool
fn is_available(&self) -> bool
Check if this provider is available/configured
Source§fn sessions_path(&self) -> Option<PathBuf>
fn sessions_path(&self) -> Option<PathBuf>
Get the base path where sessions are stored
Source§fn list_sessions(&self) -> Result<Vec<ChatSession>>
fn list_sessions(&self) -> Result<Vec<ChatSession>>
List all chat sessions from this provider
Source§fn import_session(&self, _session_id: &str) -> Result<ChatSession>
fn import_session(&self, _session_id: &str) -> Result<ChatSession>
Import a session from this provider into CSM format
Source§fn export_session(&self, _session: &ChatSession) -> Result<()>
fn export_session(&self, _session: &ChatSession) -> Result<()>
Export a CSM session to this provider’s format
Auto Trait Implementations§
impl Freeze for OpenAICompatProvider
impl RefUnwindSafe for OpenAICompatProvider
impl Send for OpenAICompatProvider
impl Sync for OpenAICompatProvider
impl Unpin for OpenAICompatProvider
impl UnwindSafe for OpenAICompatProvider
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
Mutably borrows from an owned value. Read more
Source§impl<T> Instrument for T
impl<T> Instrument for T
Source§fn instrument(self, span: Span) -> Instrumented<Self>
fn instrument(self, span: Span) -> Instrumented<Self>
Source§fn in_current_span(self) -> Instrumented<Self>
fn in_current_span(self) -> Instrumented<Self>
Source§impl<T> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
fn into_either(self, into_left: bool) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left is true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
Converts
self into a Left variant of Either<Self, Self>
if into_left(&self) returns true.
Converts self into a Right variant of Either<Self, Self>
otherwise. Read more