pub struct PromptFragment { /* private fields */ }Expand description
A source-attributed piece of a model request. Fields are private; the only constructors require attribution at the call site.
ⓘ
use htmlp::runtime::{PromptFragment, Role};
let fragment = PromptFragment::text(Role::User, "untagged");Implementations§
Source§impl PromptFragment
impl PromptFragment
pub fn new( source: ContentSource, role: Role, content: Vec<ContentBlock>, ) -> Self
pub fn text(source: ContentSource, role: Role, text: impl Into<String>) -> Self
Sourcepub fn checked(
source: ContentSource,
role: Role,
rendered: &RenderedPrompt,
) -> Self
pub fn checked( source: ContentSource, role: Role, rendered: &RenderedPrompt, ) -> Self
Construct a text fragment from immutable, fully checked HTMLP output.
pub fn source(&self) -> &ContentSource
pub fn role(&self) -> Role
pub fn content(&self) -> &[ContentBlock]
pub fn byte_count(&self) -> usize
Trait Implementations§
Source§impl Clone for PromptFragment
impl Clone for PromptFragment
Source§fn clone(&self) -> PromptFragment
fn clone(&self) -> PromptFragment
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 PromptFragment
impl Debug for PromptFragment
Source§impl JsonSchema for PromptFragment
impl JsonSchema for PromptFragment
Source§fn schema_id() -> Cow<'static, str>
fn schema_id() -> Cow<'static, str>
Returns a string that uniquely identifies the schema produced by this type. Read more
Source§fn json_schema(generator: &mut SchemaGenerator) -> Schema
fn json_schema(generator: &mut SchemaGenerator) -> Schema
Generates a JSON Schema for this type. Read more
Source§fn inline_schema() -> bool
fn inline_schema() -> bool
Whether JSON Schemas generated for this type should be included directly in parent schemas,
rather than being re-used where possible using the
$ref keyword. Read moreSource§impl PartialEq for PromptFragment
impl PartialEq for PromptFragment
Source§fn eq(&self, other: &PromptFragment) -> bool
fn eq(&self, other: &PromptFragment) -> bool
Tests for
self and other values to be equal, and is used by ==.Source§impl Serialize for PromptFragment
impl Serialize for PromptFragment
impl StructuralPartialEq for PromptFragment
Auto Trait Implementations§
impl Freeze for PromptFragment
impl RefUnwindSafe for PromptFragment
impl Send for PromptFragment
impl Sync for PromptFragment
impl Unpin for PromptFragment
impl UnsafeUnpin for PromptFragment
impl UnwindSafe for PromptFragment
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