pub struct ContentGenerator { /* private fields */ }Expand description
Content generator that combines an LLM provider with business context.
Implementations§
Source§impl ContentGenerator
impl ContentGenerator
Sourcepub fn new(provider: Box<dyn LlmProvider>, business: BusinessProfile) -> Self
pub fn new(provider: Box<dyn LlmProvider>, business: BusinessProfile) -> Self
Create a new content generator.
Sourcepub async fn generate_reply(
&self,
tweet_text: &str,
tweet_author: &str,
mention_product: bool,
) -> Result<String, LlmError>
pub async fn generate_reply( &self, tweet_text: &str, tweet_author: &str, mention_product: bool, ) -> Result<String, LlmError>
Generate a reply to a tweet.
The reply will be conversational, helpful, and under 280 characters.
When mention_product is false, the system prompt explicitly forbids
mentioning the product name.
When archetype is provided, the prompt includes archetype-specific
guidance for varied output (e.g., ask a question, share experience).
Retries once with a stricter prompt if the first attempt is too long,
then truncates at a sentence boundary as a last resort.
Sourcepub async fn generate_reply_with_archetype(
&self,
tweet_text: &str,
tweet_author: &str,
mention_product: bool,
archetype: Option<ReplyArchetype>,
) -> Result<String, LlmError>
pub async fn generate_reply_with_archetype( &self, tweet_text: &str, tweet_author: &str, mention_product: bool, archetype: Option<ReplyArchetype>, ) -> Result<String, LlmError>
Generate a reply using a specific archetype for varied output.
Sourcepub async fn generate_tweet(&self, topic: &str) -> Result<String, LlmError>
pub async fn generate_tweet(&self, topic: &str) -> Result<String, LlmError>
Generate a standalone educational tweet.
The tweet will be informative, engaging, and under 280 characters.
Sourcepub async fn generate_tweet_with_format(
&self,
topic: &str,
format: Option<TweetFormat>,
) -> Result<String, LlmError>
pub async fn generate_tweet_with_format( &self, topic: &str, format: Option<TweetFormat>, ) -> Result<String, LlmError>
Generate a tweet using a specific format for varied structure.
Sourcepub async fn generate_thread(
&self,
topic: &str,
) -> Result<Vec<String>, LlmError>
pub async fn generate_thread( &self, topic: &str, ) -> Result<Vec<String>, LlmError>
Generate an educational thread of 5-8 tweets.
Each tweet in the thread will be under 280 characters. Retries up to 2 times if the LLM produces malformed output.
Sourcepub async fn generate_thread_with_structure(
&self,
topic: &str,
structure: Option<ThreadStructure>,
) -> Result<Vec<String>, LlmError>
pub async fn generate_thread_with_structure( &self, topic: &str, structure: Option<ThreadStructure>, ) -> Result<Vec<String>, LlmError>
Generate a thread using a specific structure for varied content.
Auto Trait Implementations§
impl Freeze for ContentGenerator
impl !RefUnwindSafe for ContentGenerator
impl Send for ContentGenerator
impl Sync for ContentGenerator
impl Unpin for ContentGenerator
impl UnsafeUnpin for ContentGenerator
impl !UnwindSafe for ContentGenerator
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
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>
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>
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