Skip to main content

PromptClient

Struct PromptClient 

Source
pub struct PromptClient { /* private fields */ }
Expand description

Client for managing AI prompt templates.

Implementations§

Source§

impl PromptClient

Source

pub fn new(api: ApiClient) -> Self

Create a new prompt client.

Source

pub async fn save_prompt( &self, prompt_name: &str, description: &str, prompt_template: &str, ) -> Result<()>

Creates or updates a prompt template (simplified method) This creates a new version or updates the latest version.

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn save_prompt_with_options( &self, prompt_name: &str, description: &str, prompt_template: &str, models: Option<&[String]>, version: Option<i32>, auto_increment: bool, ) -> Result<()>

Creates or updates a prompt template with full control over versioning and model associations.

§Arguments
  • prompt_name - The name of the prompt template
  • description - A description of what the prompt does
  • prompt_template - The template content with optional variable placeholders
  • models - Optional list of AI model names this prompt is compatible with (e.g., ["openai:gpt-4", "anthropic:sonnet-4.5"])
  • version - Specific version number to create or update, or None to update the latest version
  • auto_increment - If true, automatically creates a new version instead of updating existing
§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn update_prompt( &self, prompt_name: &str, version: i32, description: &str, prompt_template: &str, models: Option<&[String]>, ) -> Result<()>

Updates an existing prompt template at a specific version.

§Arguments
  • prompt_name - The name of the prompt template
  • version - The version number to update
  • description - A description of what the prompt does
  • prompt_template - The template content with optional variable placeholders
  • models - Optional list of AI model names this prompt is compatible with
§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn save_prompts( &self, prompts: &[PromptTemplate], new_version: bool, ) -> Result<()>

Creates multiple prompt templates in a single bulk operation.

§Arguments
  • prompts - List of prompt templates to create
  • new_version - If true, creates new versions for existing prompts; if false, updates existing versions
§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn get_prompt(&self, prompt_name: &str) -> Result<PromptTemplate>

Retrieves the latest version of a prompt template by name.

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn get_prompt_version( &self, prompt_name: &str, version: i32, ) -> Result<PromptTemplate>

Retrieves a specific version of a prompt template.

§Arguments
  • prompt_name - The name of the prompt template
  • version - The version number to retrieve
§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn get_all_prompt_versions( &self, prompt_name: &str, ) -> Result<Vec<PromptTemplate>>

Retrieves all versions of a specific prompt template.

§Arguments
  • prompt_name - The name of the prompt template
§Returns

List of all versions of the prompt template, ordered by version number.

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn get_prompts(&self) -> Result<Vec<PromptTemplate>>

Retrieves all prompt templates (latest versions only).

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.

Source

pub async fn delete_prompt(&self, prompt_name: &str) -> Result<()>

Deletes all versions of a prompt template.

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.

Source

pub async fn delete_prompt_version( &self, prompt_name: &str, version: i32, ) -> Result<()>

Deletes a specific version of a prompt template.

§Arguments
  • prompt_name - The name of the prompt template
  • version - The version number to delete
§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.

Source

pub async fn get_tags_for_prompt_template( &self, prompt_name: &str, ) -> Result<Vec<MetadataTag>>

Retrieves all tags associated with a prompt template.

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn update_tag_for_prompt_template( &self, prompt_name: &str, tags: &[MetadataTag], ) -> Result<()>

Adds or updates tags for a prompt template.

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, or an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status.

Source

pub async fn delete_tag_for_prompt_template( &self, prompt_name: &str, tags: &[MetadataTag], ) -> Result<()>

Deletes specific tags from a prompt template.

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Source

pub async fn test_prompt( &self, prompt_text: &str, variables: &HashMap<String, Value>, ai_integration: &str, text_complete_model: &str, temperature: f32, top_p: f32, stop_words: Option<&[String]>, ) -> Result<String>

Tests a prompt template by substituting variables and processing through the specified AI model.

This allows you to validate prompt templates before saving them or using them in workflows.

§Arguments
  • prompt_text - The text of the prompt template with variable placeholders
  • variables - A map containing variables to be replaced in the template
  • ai_integration - The name of the AI integration provider (e.g., “openai”)
  • text_complete_model - The AI model to use for completing text (e.g., “gpt-4”)
  • temperature - The randomness of the output, typically 0.0 to 1.0 (default is 0.1)
  • top_p - The nucleus sampling probability mass (default is 0.9)
  • stop_words - Optional list of words at which to stop generating further text
§Returns

The processed prompt text after variable substitution and AI model processing.

§Errors

Returns crate::error::ConductorError::Http if the request fails at the transport level, an crate::error::ConductorError::Auth/crate::error::ConductorError::Api/crate::error::ConductorError::Server variant if the server responds with a non-2xx status, or crate::error::ConductorError::Json if the response body can’t be deserialized.

Trait Implementations§

Source§

impl Clone for PromptClient

Source§

fn clone(&self) -> Self

Returns a duplicate of the value. Read more
1.0.0 (const: unstable) · Source§

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

Performs copy-assignment from source. 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> DynClone for T
where T: Clone,

Source§

fn __clone_box(&self, _: Private) -> *mut ()

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> 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 = !

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

fn try_from(value: U) -> Result<T, !>

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