pub struct MockLanguageModelClient<E> { /* private fields */ }
Implementations§
Source§impl<E> MockLanguageModelClient<E>
impl<E> MockLanguageModelClient<E>
pub fn batches(&self) -> &RwLock<HashMap<String, Batch>>
pub fn files(&self) -> &RwLock<HashMap<String, Bytes>>
pub fn fail_on_file_create_openai_error(&self) -> &bool
pub fn fail_on_file_create_other_error(&self) -> &bool
Sourcepub fn mock_batch_config(&self) -> &RwLock<MockBatchConfig>
pub fn mock_batch_config(&self) -> &RwLock<MockBatchConfig>
NEW FIELD: stores extra toggles and attempt counters for advanced mock behaviors
Source§impl<E> MockLanguageModelClient<E>
impl<E> MockLanguageModelClient<E>
pub fn set_batches( &mut self, val: RwLock<HashMap<String, Batch>>, ) -> &mut MockLanguageModelClient<E>
pub fn set_files( &mut self, val: RwLock<HashMap<String, Bytes>>, ) -> &mut MockLanguageModelClient<E>
pub fn set_fail_on_file_create_openai_error( &mut self, val: bool, ) -> &mut MockLanguageModelClient<E>
pub fn set_fail_on_file_create_other_error( &mut self, val: bool, ) -> &mut MockLanguageModelClient<E>
Sourcepub fn set_mock_batch_config(
&mut self,
val: RwLock<MockBatchConfig>,
) -> &mut MockLanguageModelClient<E>
pub fn set_mock_batch_config( &mut self, val: RwLock<MockBatchConfig>, ) -> &mut MockLanguageModelClient<E>
NEW FIELD: stores extra toggles and attempt counters for advanced mock behaviors
Source§impl<E> MockLanguageModelClient<E>
impl<E> MockLanguageModelClient<E>
Sourcepub fn configure_inprogress_then_complete_with(
&self,
batch_id: &str,
want_output: bool,
want_error: bool,
)
pub fn configure_inprogress_then_complete_with( &self, batch_id: &str, want_output: bool, want_error: bool, )
Configure the mock so that the next time we retrieve batch_id
, it will show
status = InProgress, then on retrieve => flip to Completed with the specified
(want_output, want_error).
This is used by “success” scenarios where we want the batch to end up Completed with optional output_file_id and/or error_file_id.
pub fn configure_failure(&self, batch_id: &str, is_immediate: bool)
Source§impl<E> MockLanguageModelClient<E>
impl<E> MockLanguageModelClient<E>
pub fn new() -> MockLanguageModelClient<E>
Sourcepub fn set_batch_to_inprogress_then_complete_with(
&self,
batch_id: &str,
want_output: bool,
want_error: bool,
)
pub fn set_batch_to_inprogress_then_complete_with( &self, batch_id: &str, want_output: bool, want_error: bool, )
Helper to forcibly mark the given batch_id
as “InProgress” in the
batches
map with a note in our mock_batch_config
so that
on the very next retrieve, we flip it to “Completed” with
an output_file_id
and/or error_file_id
.
This ensures that when wait_for_batch_completion
sees it become
“Completed,” it already has the relevant file IDs.
Trait Implementations§
Source§impl<E> CreateBatch for MockLanguageModelClient<E>
impl<E> CreateBatch for MockLanguageModelClient<E>
type Error = E
fn create_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
input_file_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Batch, <MockLanguageModelClient<E> as CreateBatch>::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockLanguageModelClient<E>: 'async_trait,
Source§impl<E> Debug for MockLanguageModelClient<E>where
E: Debug,
impl<E> Debug for MockLanguageModelClient<E>where
E: Debug,
Source§impl<E> GetBatchFileContent for MockLanguageModelClient<E>
impl<E> GetBatchFileContent for MockLanguageModelClient<E>
type Error = E
fn file_content<'life0, 'life1, 'async_trait>(
&'life0 self,
file_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Bytes, <MockLanguageModelClient<E> as GetBatchFileContent>::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockLanguageModelClient<E>: 'async_trait,
Source§impl<E> RetrieveBatchById for MockLanguageModelClient<E>
impl<E> RetrieveBatchById for MockLanguageModelClient<E>
type Error = E
fn retrieve_batch<'life0, 'life1, 'async_trait>(
&'life0 self,
batch_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Batch, <MockLanguageModelClient<E> as RetrieveBatchById>::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockLanguageModelClient<E>: 'async_trait,
Source§impl<E> UploadBatchFileCore for MockLanguageModelClient<E>
impl<E> UploadBatchFileCore for MockLanguageModelClient<E>
type Error = E
fn upload_batch_file_path<'life0, 'life1, 'async_trait>(
&'life0 self,
file_path: &'life1 Path,
) -> Pin<Box<dyn Future<Output = Result<OpenAIFile, <MockLanguageModelClient<E> as UploadBatchFileCore>::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockLanguageModelClient<E>: 'async_trait,
Source§impl<E> WaitForBatchCompletion for MockLanguageModelClient<E>
impl<E> WaitForBatchCompletion for MockLanguageModelClient<E>
type Error = E
fn wait_for_batch_completion<'life0, 'life1, 'async_trait>(
&'life0 self,
batch_id: &'life1 str,
) -> Pin<Box<dyn Future<Output = Result<Batch, <MockLanguageModelClient<E> as WaitForBatchCompletion>::Error>> + Send + 'async_trait>>where
'life0: 'async_trait,
'life1: 'async_trait,
MockLanguageModelClient<E>: 'async_trait,
impl<E> LanguageModelClientInterface<E> for MockLanguageModelClient<E>where
E: From<OpenAIClientError> + From<BatchDownloadError> + From<Error> + From<BatchMetadataError> + Debug + Send + Sync,
Auto Trait Implementations§
impl<E> !Freeze for MockLanguageModelClient<E>
impl<E> RefUnwindSafe for MockLanguageModelClient<E>where
E: RefUnwindSafe,
impl<E> Send for MockLanguageModelClient<E>where
E: Send,
impl<E> Sync for MockLanguageModelClient<E>where
E: Sync,
impl<E> Unpin for MockLanguageModelClient<E>where
E: Unpin,
impl<E> UnwindSafe for MockLanguageModelClient<E>where
E: UnwindSafe,
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> 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> Paint for Twhere
T: ?Sized,
impl<T> Paint for Twhere
T: ?Sized,
Source§fn fg(&self, value: Color) -> Painted<&T>
fn fg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the foreground set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like red()
and
green()
, which have the same functionality but are
pithier.
§Example
Set foreground color to white using fg()
:
use yansi::{Paint, Color};
painted.fg(Color::White);
Set foreground color to white using white()
.
use yansi::Paint;
painted.white();
Source§fn bright_black(&self) -> Painted<&T>
fn bright_black(&self) -> Painted<&T>
Source§fn bright_red(&self) -> Painted<&T>
fn bright_red(&self) -> Painted<&T>
Source§fn bright_green(&self) -> Painted<&T>
fn bright_green(&self) -> Painted<&T>
Source§fn bright_yellow(&self) -> Painted<&T>
fn bright_yellow(&self) -> Painted<&T>
Source§fn bright_blue(&self) -> Painted<&T>
fn bright_blue(&self) -> Painted<&T>
Source§fn bright_magenta(&self) -> Painted<&T>
fn bright_magenta(&self) -> Painted<&T>
Source§fn bright_cyan(&self) -> Painted<&T>
fn bright_cyan(&self) -> Painted<&T>
Source§fn bright_white(&self) -> Painted<&T>
fn bright_white(&self) -> Painted<&T>
Source§fn bg(&self, value: Color) -> Painted<&T>
fn bg(&self, value: Color) -> Painted<&T>
Returns a styled value derived from self
with the background set to
value
.
This method should be used rarely. Instead, prefer to use color-specific
builder methods like on_red()
and
on_green()
, which have the same functionality but
are pithier.
§Example
Set background color to red using fg()
:
use yansi::{Paint, Color};
painted.bg(Color::Red);
Set background color to red using on_red()
.
use yansi::Paint;
painted.on_red();
Source§fn on_primary(&self) -> Painted<&T>
fn on_primary(&self) -> Painted<&T>
Source§fn on_magenta(&self) -> Painted<&T>
fn on_magenta(&self) -> Painted<&T>
Source§fn on_bright_black(&self) -> Painted<&T>
fn on_bright_black(&self) -> Painted<&T>
Source§fn on_bright_red(&self) -> Painted<&T>
fn on_bright_red(&self) -> Painted<&T>
Source§fn on_bright_green(&self) -> Painted<&T>
fn on_bright_green(&self) -> Painted<&T>
Source§fn on_bright_yellow(&self) -> Painted<&T>
fn on_bright_yellow(&self) -> Painted<&T>
Source§fn on_bright_blue(&self) -> Painted<&T>
fn on_bright_blue(&self) -> Painted<&T>
Source§fn on_bright_magenta(&self) -> Painted<&T>
fn on_bright_magenta(&self) -> Painted<&T>
Source§fn on_bright_cyan(&self) -> Painted<&T>
fn on_bright_cyan(&self) -> Painted<&T>
Source§fn on_bright_white(&self) -> Painted<&T>
fn on_bright_white(&self) -> Painted<&T>
Source§fn attr(&self, value: Attribute) -> Painted<&T>
fn attr(&self, value: Attribute) -> Painted<&T>
Enables the styling Attribute
value
.
This method should be used rarely. Instead, prefer to use
attribute-specific builder methods like bold()
and
underline()
, which have the same functionality
but are pithier.
§Example
Make text bold using attr()
:
use yansi::{Paint, Attribute};
painted.attr(Attribute::Bold);
Make text bold using using bold()
.
use yansi::Paint;
painted.bold();
Source§fn rapid_blink(&self) -> Painted<&T>
fn rapid_blink(&self) -> Painted<&T>
Source§fn quirk(&self, value: Quirk) -> Painted<&T>
fn quirk(&self, value: Quirk) -> Painted<&T>
Enables the yansi
Quirk
value
.
This method should be used rarely. Instead, prefer to use quirk-specific
builder methods like mask()
and
wrap()
, which have the same functionality but are
pithier.
§Example
Enable wrapping using .quirk()
:
use yansi::{Paint, Quirk};
painted.quirk(Quirk::Wrap);
Enable wrapping using wrap()
.
use yansi::Paint;
painted.wrap();
Source§fn clear(&self) -> Painted<&T>
👎Deprecated since 1.0.1: renamed to resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.
fn clear(&self) -> Painted<&T>
resetting()
due to conflicts with Vec::clear()
.
The clear()
method will be removed in a future release.Source§fn whenever(&self, value: Condition) -> Painted<&T>
fn whenever(&self, value: Condition) -> Painted<&T>
Conditionally enable styling based on whether the Condition
value
applies. Replaces any previous condition.
See the crate level docs for more details.
§Example
Enable styling painted
only when both stdout
and stderr
are TTYs:
use yansi::{Paint, Condition};
painted.red().on_yellow().whenever(Condition::STDOUTERR_ARE_TTY);