#[non_exhaustive]pub enum Instructions {
System(SystemMessage),
Messages(Vec<SystemMessage>),
}Expand description
One system message or an ordered sequence of system messages.
String conversions create a single message. Use Self::messages for
several instruction messages with independent provider options.
Variants (Non-exhaustive)§
This enum is marked as non-exhaustive
Non-exhaustive enums could have additional variants added in future. Therefore, when matching against variants of non-exhaustive enums, an extra wildcard arm must be added to account for any future variants.
System(SystemMessage)
A single system message.
Messages(Vec<SystemMessage>)
System messages in prompt order (an empty vector adds none).
Implementations§
Source§impl Instructions
impl Instructions
Sourcepub fn messages(messages: impl IntoIterator<Item = SystemMessage>) -> Self
pub fn messages(messages: impl IntoIterator<Item = SystemMessage>) -> Self
Creates ordered instructions with independent message metadata.
§Examples
use ferrin_core::Instructions;
use ferrin_message::SystemMessage;
let instructions = Instructions::messages([
SystemMessage { content: "Be concise.".into(), provider_options: None },
SystemMessage { content: "Use supplied sources.".into(), provider_options: None },
]);
assert_eq!(instructions.as_messages().len(), 2);Sourcepub fn with_provider_options(self, options: ProviderOptions) -> Self
pub fn with_provider_options(self, options: ProviderOptions) -> Self
Replaces provider options on every configured system message.
Sourcepub fn as_messages(&self) -> &[SystemMessage]
pub fn as_messages(&self) -> &[SystemMessage]
Borrows instruction messages in prompt order.
Sourcepub fn into_messages(self) -> Vec<SystemMessage>
pub fn into_messages(self) -> Vec<SystemMessage>
Consumes the instructions into ordered system messages.
Trait Implementations§
Source§impl Clone for Instructions
impl Clone for Instructions
Source§fn clone(&self) -> Instructions
fn clone(&self) -> Instructions
Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§fn clone_from(&mut self, source: &Self)
fn clone_from(&mut self, source: &Self)
Performs copy-assignment from
source. Read moreSource§impl Debug for Instructions
impl Debug for Instructions
Source§impl Default for Instructions
impl Default for Instructions
impl Eq for Instructions
Source§impl From<&str> for Instructions
impl From<&str> for Instructions
Source§impl From<String> for Instructions
impl From<String> for Instructions
Source§impl From<SystemMessage> for Instructions
impl From<SystemMessage> for Instructions
Source§fn from(message: SystemMessage) -> Self
fn from(message: SystemMessage) -> Self
Converts to this type from the input type.
Source§impl From<Vec<SystemMessage>> for Instructions
impl From<Vec<SystemMessage>> for Instructions
Source§fn from(messages: Vec<SystemMessage>) -> Self
fn from(messages: Vec<SystemMessage>) -> Self
Converts to this type from the input type.
Source§impl PartialEq for Instructions
impl PartialEq for Instructions
impl StructuralPartialEq for Instructions
Auto Trait Implementations§
impl Freeze for Instructions
impl RefUnwindSafe for Instructions
impl Send for Instructions
impl Sync for Instructions
impl Unpin for Instructions
impl UnsafeUnpin for Instructions
impl UnwindSafe for Instructions
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
impl<ST, DT> CastableFrom<ST, Initialized, Initialized> for DT
impl<ST, DT> CastableFrom<ST, Uninit, Uninit> for DT
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§fn equivalent(&self, key: &K) -> bool
fn equivalent(&self, key: &K) -> bool
Compare self to
key and return true if they are equal.