import gradio as gr import requests import os API_KEY = os.getenv("groc_api_key") API_URL = "https://api.groq.com/openai/v1/chat/completions" def generate_post(topic, tone, audience, length): prompt = f""" Write a high-quality LinkedIn post. Topic: {topic} Tone: {tone} Audience: {audience} Length: {length} Make it: - Engaging with strong hook 🔥 - Human and storytelling style - Add emojis naturally 😄🚀💡 - End with hashtags (5-8) """ headers = { "Authorization": f"Bearer {API_KEY}", "Content-Type": "application/json" } payload = { "model": "llama-3.1-8b-instant", "messages": [{"role": "user", "content": prompt}], "temperature": 0.8 } res = requests.post(API_URL, headers=headers, json=payload) if res.status_code == 200: return res.json()["choices"][0]["message"]["content"] return res.text # 🎨 CLEAN MODERN UI (NO BROKEN CSS) with gr.Blocks(theme=gr.themes.Soft()) as demo: gr.Markdown("""
Create viral posts in seconds with AI