pub struct OpenAiAdapterBuilder { /* private fields */ }
Expand description
Builder for OpenAiAdapter
.
§Typical usage
use artificial_openai::OpenAiAdapterBuilder;
let backend = OpenAiAdapterBuilder::new_from_env()
.build()
.expect("OPENAI_API_KEY must be set");
The builder pattern keeps future options (proxy URL, organisation ID, …)
backwards compatible without breaking existing build()
calls.
Implementations§
Source§impl OpenAiAdapterBuilder
impl OpenAiAdapterBuilder
Sourcepub fn new_from_env() -> Self
pub fn new_from_env() -> Self
Convenience constructor that tries to load the OPENAI_API_KEY
environment variable.
§Panics
Never panics. Missing keys only surface during Self::build
.
Sourcepub fn build(self) -> Result<OpenAiAdapter>
pub fn build(self) -> Result<OpenAiAdapter>
Finalise the builder and return a ready-to-use adapter.
§Errors
ArtificialError::Invalid
– if the API key is missing.
Trait Implementations§
Source§impl Default for OpenAiAdapterBuilder
impl Default for OpenAiAdapterBuilder
Source§fn default() -> OpenAiAdapterBuilder
fn default() -> OpenAiAdapterBuilder
Returns the “default value” for a type. Read more
Auto Trait Implementations§
impl Freeze for OpenAiAdapterBuilder
impl RefUnwindSafe for OpenAiAdapterBuilder
impl Send for OpenAiAdapterBuilder
impl Sync for OpenAiAdapterBuilder
impl Unpin for OpenAiAdapterBuilder
impl UnwindSafe for OpenAiAdapterBuilder
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