JeCabrera commited on
Commit
504b672
verified
1 Parent(s): 8f65bf0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +12 -41
app.py CHANGED
@@ -1,45 +1,16 @@
1
  import gradio as gr
2
- import google.generativeai as genai
3
 
4
- # Crear un modelo generativo
5
- model = genai.GenerativeModel("gemini-1.5-flash")
6
-
7
- # Funci贸n para procesar el PDF y generar una respuesta
8
- def process_pdf(file):
9
- # Subir el archivo PDF local (usando filepath)
10
- sample_pdf = genai.upload_file(file.name) # file.name ser谩 la ruta del archivo
11
-
12
- # Crear el prompt para la API
13
- prompt = "Give me a summary of this pdf file."
14
 
15
- # Generar contenido a partir del PDF subido
16
- response = model.generate_content([prompt, sample_pdf])
17
-
18
- return response.text
19
-
20
- # Definir la interfaz de usuario en Gradio
21
- def chatbot_interface(user_input, history):
22
- # Procesar el archivo PDF
23
- response_text = process_pdf(user_input)
24
-
25
- # Actualizar el historial del chatbot
26
- history.append((user_input.name, response_text))
27
-
28
- return history, history
29
-
30
- # Crear la app de Gradio
31
- app = gr.Interface(
32
- fn=chatbot_interface,
33
- inputs=[
34
- gr.File(file_count="single", type="filepath", label="Upload PDF Document"), # Cambi茅 'file' por 'filepath'
35
- gr.State(), # Mantener el estado del historial
36
- ],
37
- outputs=[
38
- gr.Chatbot(),
39
- gr.State(),
40
- ],
41
- live=True
42
- )
43
 
44
- # Lanzar la app
45
- app.launch()
 
1
  import gradio as gr
2
+ import gemini_gradio
3
 
4
+ with gr.Blocks(fill_height=True) as demo:
5
+ # Centrado con HTML
6
+ gr.Markdown("<h1 style='text-align:center;'>CopyMaster</h1>") # T铆tulo centrado
7
+ gr.Markdown("<h3 style='text-align:center;'>El escritor de ventas que nunca duerme, siempre listo para conectar, cautivar y convencer a tu audiencia.</h3>") # Subt铆tulo centrado
 
 
 
 
 
 
8
 
9
+ gemini_interface = gr.load(
10
+ name="gemini-1.5-flash", # Se establece el modelo por defecto
11
+ src=gemini_gradio.registry,
12
+ fill_height=True,
13
+ chatbot=gr.Chatbot(type="messages")
14
+ )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
 
16
+ demo.launch(ssr_mode=False)