Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -1,45 +1,16 @@
|
|
1 |
import gradio as gr
|
2 |
-
import
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
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 |
-
|
16 |
-
|
17 |
-
|
18 |
-
|
19 |
-
|
20 |
-
|
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 |
-
|
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)
|
|