PromptContext

Struct PromptContext 

Source
pub struct PromptContext {
    pub text: String,
    pub images: Vec<PathBuf>,
    pub ready: bool,
    pub created_at: SystemTime,
}
Expand description

Prompt context containing text and images

Manages the context for a prompt including:

  • Text input
  • Associated images
  • Metadata about the context

§Requirements

  • Req 1.4: Add images to prompt context
  • Req 5.1: Display images in chat interface
  • Req 5.1: Include images in message history

Fields§

§text: String

Text content of the prompt

§images: Vec<PathBuf>

Images associated with the prompt

§ready: bool

Whether the context is complete and ready to send

§created_at: SystemTime

Timestamp when context was created

Implementations§

Source§

impl PromptContext

Source

pub fn new() -> Self

Create a new empty prompt context

Source

pub fn with_text(text: impl Into<String>) -> Self

Create a new prompt context with text

Source

pub fn with_text_and_images( text: impl Into<String>, images: Vec<PathBuf>, ) -> Self

Create a new prompt context with text and images

Source

pub fn set_text(&mut self, text: impl Into<String>)

Set the text content

§Arguments
  • text - The text content
Source

pub fn get_text(&self) -> &str

Get the text content

Source

pub fn add_image(&mut self, path: PathBuf)

Add an image to the context

§Arguments
  • path - Path to the image
§Requirements
  • Req 1.4: Add images to prompt context
Source

pub fn add_images(&mut self, paths: Vec<PathBuf>)

Add multiple images to the context

§Arguments
  • paths - Paths to the images
§Requirements
  • Req 1.4: Add images to prompt context
Source

pub fn remove_image(&mut self, path: &PathBuf) -> bool

Remove an image from the context

§Arguments
  • path - Path to the image to remove
§Returns

True if image was removed, false if not found

Source

pub fn clear_images(&mut self)

Clear all images from the context

Source

pub fn get_images(&self) -> &[PathBuf]

Get the images in the context

Source

pub fn image_count(&self) -> usize

Get the number of images in the context

Source

pub fn has_images(&self) -> bool

Check if the context has any images

Source

pub fn has_text(&self) -> bool

Check if the context has text

Source

pub fn is_complete(&self) -> bool

Check if the context is complete (has text or images)

Source

pub fn mark_ready(&mut self)

Mark the context as ready to send

Source

pub fn mark_not_ready(&mut self)

Mark the context as not ready

Source

pub fn is_ready(&self) -> bool

Check if the context is ready to send

Source

pub fn clear(&mut self)

Clear the context (text and images)

Source

pub fn summary(&self) -> String

Get a summary of the context

Trait Implementations§

Source§

impl Clone for PromptContext

Source§

fn clone(&self) -> PromptContext

Returns a duplicate of the value. Read more
1.0.0 · Source§

fn clone_from(&mut self, source: &Self)

Performs copy-assignment from source. Read more
Source§

impl Debug for PromptContext

Source§

fn fmt(&self, f: &mut Formatter<'_>) -> Result

Formats the value using the given formatter. Read more
Source§

impl Default for PromptContext

Source§

fn default() -> Self

Returns the “default value” for a type. Read more

Auto Trait Implementations§

Blanket Implementations§

Source§

impl<T> Any for T
where T: 'static + ?Sized,

Source§

fn type_id(&self) -> TypeId

Gets the TypeId of self. Read more
Source§

impl<T> Borrow<T> for T
where T: ?Sized,

Source§

fn borrow(&self) -> &T

Immutably borrows from an owned value. Read more
Source§

impl<T> BorrowMut<T> for T
where T: ?Sized,

Source§

fn borrow_mut(&mut self) -> &mut T

Mutably borrows from an owned value. Read more
Source§

impl<T> CloneToUninit for T
where T: Clone,

Source§

unsafe fn clone_to_uninit(&self, dest: *mut u8)

🔬This is a nightly-only experimental API. (clone_to_uninit)
Performs copy-assignment from self to dest. Read more
Source§

impl<T> From<T> for T

Source§

fn from(t: T) -> T

Returns the argument unchanged.

Source§

impl<T> Instrument for T

Source§

fn instrument(self, span: Span) -> Instrumented<Self>

Instruments this type with the provided Span, returning an Instrumented wrapper. Read more
Source§

fn in_current_span(self) -> Instrumented<Self>

Instruments this type with the current Span, returning an Instrumented wrapper. Read more
Source§

impl<T, U> Into<U> for T
where U: From<T>,

Source§

fn into(self) -> U

Calls U::from(self).

That is, this conversion is whatever the implementation of From<T> for U chooses to do.

Source§

impl<T> IntoEither for T

Source§

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 more
Source§

fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
where F: FnOnce(&Self) -> bool,

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
Source§

impl<T> ToOwned for T
where T: Clone,

Source§

type Owned = T

The resulting type after obtaining ownership.
Source§

fn to_owned(&self) -> T

Creates owned data from borrowed data, usually by cloning. Read more
Source§

fn clone_into(&self, target: &mut T)

Uses borrowed data to replace owned data, usually by cloning. Read more
Source§

impl<T, U> TryFrom<U> for T
where U: Into<T>,

Source§

type Error = Infallible

The type returned in the event of a conversion error.
Source§

fn try_from(value: U) -> Result<T, <T as TryFrom<U>>::Error>

Performs the conversion.
Source§

impl<T, U> TryInto<U> for T
where U: TryFrom<T>,

Source§

type Error = <U as TryFrom<T>>::Error

The type returned in the event of a conversion error.
Source§

fn try_into(self) -> Result<U, <U as TryFrom<T>>::Error>

Performs the conversion.
Source§

impl<T> WithSubscriber for T

Source§

fn with_subscriber<S>(self, subscriber: S) -> WithDispatch<Self>
where S: Into<Dispatch>,

Attaches the provided Subscriber to this type, returning a WithDispatch wrapper. Read more
Source§

fn with_current_subscriber(self) -> WithDispatch<Self>

Attaches the current default Subscriber to this type, returning a WithDispatch wrapper. Read more