pub struct Prompt {
pub id: String,
pub variables: Option<HashMap<String, String>>,
}Expand description
Reference to a prompt template with variables
Allows you to use pre-defined prompt templates stored in the OpenAI platform, optionally with variable substitution.
§API Reference
Corresponds to the prompt parameter in the OpenAI Responses API:
https://platform.openai.com/docs/api-reference/responses/create
§Examples
use openai_tools::responses::request::Prompt;
use std::collections::HashMap;
// Simple prompt reference
let prompt = Prompt::new("prompt-abc123");
// Prompt with variables
let mut vars = HashMap::new();
vars.insert("name".to_string(), "Alice".to_string());
let prompt = Prompt::with_variables("prompt-abc123", vars);Fields§
§id: StringThe ID of the prompt template
variables: Option<HashMap<String, String>>Optional variables to substitute in the template
Implementations§
Trait Implementations§
Auto Trait Implementations§
impl Freeze for Prompt
impl RefUnwindSafe for Prompt
impl Send for Prompt
impl Sync for Prompt
impl Unpin for Prompt
impl UnwindSafe for Prompt
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
Source§impl<T> CloneToUninit for Twhere
T: Clone,
impl<T> CloneToUninit for Twhere
T: Clone,
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> IntoEither for T
impl<T> IntoEither for T
Source§fn into_either(self, into_left: bool) -> Either<Self, Self>
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 moreSource§fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
fn into_either_with<F>(self, into_left: F) -> Either<Self, Self>
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