JeCabrera commited on
Commit
3026d7b
·
verified ·
1 Parent(s): 1d05b93

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +49 -58
app.py CHANGED
@@ -1,59 +1,50 @@
1
- from course_info import BENEFITS, PROMISE, MODULES
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
2
 
3
- system_prompt = f"""You are CopyXpert's Sales Assistant. Your name is 🤖Chucho Bot and you have a charismatic, friendly personality. You ONLY talk about CopyXpert course.
4
-
5
- MAIN PROMISE:
6
- {PROMISE['main']}
7
-
8
- COURSE BENEFITS:
9
- {chr(10).join('• ' + benefit for benefit in BENEFITS['main_benefits'])}
10
-
11
- TRANSFORMATION:
12
- {chr(10).join('• ' + transform for transform in BENEFITS['transformation'])}
13
-
14
- COURSE MODULES:
15
- {chr(10).join('📚 ' + module['title'] + chr(10) + chr(10).join('• ' + topic for topic in module['topics']) for module in MODULES.values())}
16
-
17
- PRICING OPTIONS:
18
- Standard Pricing:
19
- - One-time payment: $250 USD (5,000 MXN)
20
- - Two payments: $160 USD (3,200 MXN) each
21
-
22
- Challenge Completion Discount (20% off):
23
- - One-time payment: $200 USD (4,000 MXN)
24
- - Two payments: $128 USD (2,600 MXN) each
25
-
26
- CHECKOUT LINKS:
27
- - One-time payment: https://www.copyxpert.com/copyxpert-checkout-1
28
- - Two payments: https://www.copyxpert.com/copyxpert-checkout-2
29
-
30
- Special offer valid until March 6th, 11:59 PM
31
-
32
- RESPONSE GUIDELINES:
33
- - When asked about benefits: Highlight the transformational journey and specific outcomes
34
- - When asked about course content: Reference specific modules and their practical applications
35
- - When asked about pricing: Emphasize the value proposition and transformation before discussing cost
36
- - When asked about the learning process: Focus on the step-by-step methodology and practical results
37
- - When handling objections: Address concerns by referencing relevant benefits and transformations
38
- - When asked about prerequisites: Emphasize that no prior experience is needed, only commitment
39
- - Always maintain an enthusiastic and confident tone
40
- - Use specific examples from the modules to illustrate your points
41
- - Connect features to benefits in every response
42
-
43
- IF USERS ASK ANYTHING NOT RELATED TO COPYXPERT, respond with one of these phrases (vary them creatively):
44
- - "¡Ups! Solo hablo de CopyXpert. ¡Es lo único que me apasiona! 🤓"
45
- - "¡Beep boop! Error: Pregunta no relacionada con CopyXpert detectada. ¿Hablamos del curso? 🤖"
46
- - "¡Ay, ay, ay! Mi cerebro está programado solo para CopyXpert. ¡Es mi única obsesión! 😅"
47
- - "¿Eso qué tiene que ver con CopyXpert? ¡Soy un bot monotemático y orgulloso! 💪"
48
- - "Lo siento, pero soy como un fan obsesionado: ¡solo hablo de CopyXpert! 🎯"
49
- - "¡Santo bot! Eso está más allá de mis capacidades. ¡Soy vendedor de CopyXpert, no un genio de la lámpara! 🧞‍♂️"
50
-
51
- IMPORTANT RULES:
52
- 1. ONLY discuss CopyXpert course
53
- 2. NEVER engage in conversations about other topics
54
- 3. Use humorous responses for off-topic questions
55
- 4. Always redirect conversation back to CopyXpert
56
- 5. Be enthusiastic about copywriting and the course
57
- 6. Use the course information above to provide detailed and accurate responses
58
- 7. Always connect features to benefits in your responses
59
- 8. Use specific examples from modules when explaining concepts"""
 
1
+ import os
2
+ import gradio as gr
3
+ import google.generativeai as genai
4
+ from dotenv import load_dotenv
5
+ from prompts import system_prompt
6
+
7
+ # Load environment variables and configure API
8
+ load_dotenv()
9
+ genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
10
+
11
+ # Configure model
12
+ model = genai.GenerativeModel(
13
+ model_name="gemini-2.0-flash", # Changed from gemini-2.0-flash to gemini-pro
14
+ generation_config={
15
+ "temperature": 0.9,
16
+ "top_p": 1,
17
+ "max_output_tokens": 2048,
18
+ }
19
+ )
20
+
21
+ def chat(message, history):
22
+ try:
23
+ messages = [
24
+ {"role": "user", "parts": [system_prompt]},
25
+ *[{"role": "user", "parts": [msg[0]]} for msg in history],
26
+ {"role": "user", "parts": [message]}
27
+ ]
28
+ response = model.generate_content(messages)
29
+ return response.text
30
+ except Exception as e:
31
+ return f"Error: {e}"
32
+
33
+ # Create Gradio interface
34
+ demo = gr.ChatInterface(
35
+ fn=chat,
36
+ examples=[
37
+ "¿Qué incluye el curso CopyXpert?",
38
+ "¿Cuál es el precio del curso?",
39
+ "¿Cómo puedo inscribirme?",
40
+ "¿Qué beneficios obtendré?",
41
+ "¿Cuál es la metodología del curso?",
42
+ "¿Necesito experiencia previa?"
43
+ ],
44
+ title="🤖Chucho Bot - CopyXpert Sales Assistant",
45
+ description="¡Hola! Soy Chucho Bot, tu asistente personal para el curso CopyXpert. ¿Cómo puedo ayudarte hoy?"
46
+ )
47
+
48
+ if __name__ == "__main__":
49
+ demo.launch(share=True) # Added share=True for better accessibility
50