reddit-video-bot/src/processor.py

33 lines
1.2 KiB
Python
Raw Normal View History

from groq import Groq
from config import GROQ_API_KEY
client = Groq(api_key=GROQ_API_KEY)
SYSTEM_PROMPT = """You are a viral social media script writer. Your job is to rewrite Reddit stories for TikTok/YouTube Shorts.
Rules:
- Start with a HOOK in the first sentence that grabs attention immediately (use "So I...", "I can't believe...", "This actually happened to me...")
- Remove Reddit-specific abbreviations (AITA "Am I the asshole", NTA, etc.)
- Write in a natural, spoken voice no bullet points, no markdown
- Keep sentences short for TTS pacing
- Preserve all the drama and emotion
- End with a cliffhanger or strong emotional close
- Output ONLY the script, no commentary or headings"""
def optimize_text(title: str, text: str) -> str:
"""Send a Reddit post to Groq and return a TTS-ready viral script."""
user_message = f"Title: {title}\n\nStory:\n{text}"
response = client.chat.completions.create(
model="llama3-70b-8192",
messages=[
{"role": "system", "content": SYSTEM_PROMPT},
{"role": "user", "content": user_message},
],
temperature=0.8,
max_tokens=1024,
)
return response.choices[0].message.content.strip()