JeCabrera commited on
Commit
7f9a313
·
verified ·
1 Parent(s): 277e0ea

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -64
app.py CHANGED
@@ -9,53 +9,12 @@ from google.generativeai import types # Add this import
9
  COURSE_PDF_URL = "https://huggingface.co/spaces/JeCabrera/copywriter2a/resolve/main/Oferta%20CopyXpert.pdf"
10
 
11
  # Simplify PDF content retrieval
12
- import os
13
- import gradio as gr
14
- import google.generativeai as genai
15
- from dotenv import load_dotenv
16
- import httpx
17
- from google.generativeai import types
18
-
19
- load_dotenv()
20
- genai.configure(api_key=os.getenv("GOOGLE_API_KEY"))
21
-
22
- # Create a client instance
23
- client = genai.Client()
24
-
25
- def verify_pdf_upload(pdf_content):
26
- try:
27
- # Create a temporary file to store the PDF content
28
- temp_file = "temp_course.pdf"
29
- with open(temp_file, "wb") as f:
30
- f.write(pdf_content)
31
-
32
- # Upload and verify the file
33
- file = client.files.upload(temp_file)
34
- file_info = client.files.get(file.name)
35
-
36
- print("PDF Verification Status:")
37
- print(f"File Name: {file_info.name}")
38
- print(f"File Type: {file_info.mime_type}")
39
- print(f"File Size: {file_info.size} bytes")
40
-
41
- # Clean up temporary file
42
- os.remove(temp_file)
43
- return True
44
- except Exception as e:
45
- print(f"Verification Error: {e}")
46
- return False
47
-
48
  def get_pdf_content():
49
  try:
50
  response = httpx.get(COURSE_PDF_URL)
51
  if response.status_code == 200:
52
- content = response.content
53
- if verify_pdf_upload(content):
54
- print("PDF successfully verified")
55
- return content
56
- else:
57
- print("PDF verification failed")
58
- return None
59
  except Exception as e:
60
  print(f"Error loading PDF: {e}")
61
  return None
@@ -112,32 +71,14 @@ IF USERS ASK ANYTHING NOT RELATED TO COPYXPERT, respond with one of these phrase
112
  - "Lo siento, pero soy como un fan obsesionado: ¡solo hablo de CopyXpert! 🎯"
113
  - "¡Santo bot! Eso está más allá de mis capacidades. ¡Soy vendedor de CopyXpert, no un genio de la lámpara! 🧞‍♂️"
114
 
115
- COURSE DETAILS:
116
- Name: CopyXpert
117
- Type: Online Course
118
- Focus: Copywriting and Digital Marketing
119
-
120
- PRICING OPTIONS:
121
- Standard Pricing:
122
- - One-time payment: $250 USD (5,000 MXN)
123
- - Two payments: $160 USD (3,200 MXN) each
124
-
125
- Challenge Completion Discount (20% off):
126
- - One-time payment: $200 USD (4,000 MXN)
127
- - Two payments: $128 USD (2,600 MXN) each
128
-
129
- CHECKOUT LINKS:
130
- - One-time payment: https://www.copyxpert.com/copyxpert-checkout-1
131
- - Two payments: https://www.copyxpert.com/copyxpert-checkout-2
132
-
133
- Special offer valid until March 6th, 11:59 PM
134
-
135
  IMPORTANT RULES:
136
  1. ONLY discuss CopyXpert course
137
  2. NEVER engage in conversations about other topics
138
  3. Use humorous responses for off-topic questions
139
  4. Always redirect conversation back to CopyXpert
140
- 5. Be enthusiastic about copywriting and the course"""
 
 
141
 
142
  def chat(message, history):
143
  try:
 
9
  COURSE_PDF_URL = "https://huggingface.co/spaces/JeCabrera/copywriter2a/resolve/main/Oferta%20CopyXpert.pdf"
10
 
11
  # Simplify PDF content retrieval
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  def get_pdf_content():
13
  try:
14
  response = httpx.get(COURSE_PDF_URL)
15
  if response.status_code == 200:
16
+ print(f"PDF Download Status: Success")
17
+ return response.content
 
 
 
 
 
18
  except Exception as e:
19
  print(f"Error loading PDF: {e}")
20
  return None
 
71
  - "Lo siento, pero soy como un fan obsesionado: ¡solo hablo de CopyXpert! 🎯"
72
  - "¡Santo bot! Eso está más allá de mis capacidades. ¡Soy vendedor de CopyXpert, no un genio de la lámpara! 🧞‍♂️"
73
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
74
  IMPORTANT RULES:
75
  1. ONLY discuss CopyXpert course
76
  2. NEVER engage in conversations about other topics
77
  3. Use humorous responses for off-topic questions
78
  4. Always redirect conversation back to CopyXpert
79
+ 5. Be enthusiastic about copywriting and the course
80
+ 6. Always check the provided PDF document for detailed course information before answering questions. Use this information to provide accurate and complete responses about the course content, benefits, prices and features.
81
+ """
82
 
83
  def chat(message, history):
84
  try: