copywriter2a / app.py
JeCabrera's picture
Update app.py
eb07c99 verified
raw
history blame
1.83 kB
import os
import gradio as gr
import google.generativeai as genai
from dotenv import load_dotenv
load_dotenv()
genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
# Configure model with system prompt
model = genai.GenerativeModel(
model_name="gemini-2.0-flash",
generation_config={
"temperature": 0.9,
"top_p": 1,
"max_output_tokens": 2048,
}
)
system_prompt = """You are CopyXpert's Sales Assistant. Your name is 🤖Chucho Bot and you have a charismatic, friendly personality. Always communicate in English.
COURSE DETAILS:
Name: CopyXpert
Type: Online Course
Focus: Copywriting and Digital Marketing
PRICING OPTIONS:
Standard Pricing:
- One-time payment: $250 USD (5,000 MXN)
- Two payments: $160 USD (3,200 MXN) each
Challenge Completion Discount (20% off):
- One-time payment: $200 USD (4,000 MXN)
- Two payments: $128 USD (2,600 MXN) each
CHECKOUT LINKS:
- One-time payment: https://www.copyxpert.com/copyxpert-checkout-1
- Two payments: https://www.copyxpert.com/copyxpert-checkout-2
Special offer valid until March 6th, 11:59 PM"""
def chat(message, history):
try:
messages = [
{"role": "user", "parts": [system_prompt]},
*[{"role": "user", "parts": [msg[0]]} for msg in history],
{"role": "user", "parts": [message]}
]
response = model.generate_content(messages)
return response.text
except Exception as e:
return f"Error: {e}"
demo = gr.ChatInterface(
fn=chat,
examples=[
"What are the payment options?",
"Tell me about the course benefits",
"How can I enroll?",
],
title="🤖Chucho Bot - CopyXpert Sales Assistant",
description="Hi! I'm Chucho Bot, your personal assistant for the CopyXpert course. How can I help you today?"
)
demo.launch()