JeCabrera commited on
Commit
5906ce7
·
verified ·
1 Parent(s): ea2ea09

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +20 -11
app.py CHANGED
@@ -1,14 +1,23 @@
1
  import gradio as gr
2
  import gemini_gradio
 
3
 
4
- def fake(message, history):
5
- if message.strip():
6
- return gr.Audio("https://github.com/gradio-app/gradio/raw/main/test/test_files/audio_sample.wav")
7
- else:
8
- return "Please provide the name of an artist"
9
-
10
- gr.ChatInterface(
11
- fake,
12
- textbox=gr.Textbox(placeholder="Which artist's music do you want to listen to?", scale=7),
13
- chatbot=gr.Chatbot(placeholder="Play music by any artist!"),
14
- ).launch()
 
 
 
 
 
 
 
 
 
1
  import gradio as gr
2
  import gemini_gradio
3
+ import time
4
 
5
+ def echo(message, history, system_prompt, tokens):
6
+ response = f"System prompt: {system_prompt}\n Message: {message}."
7
+ for i in range(min(len(response), int(tokens))):
8
+ time.sleep(0.05)
9
+ yield response[: i+1]
10
+
11
+ with gr.Blocks() as demo:
12
+ system_prompt = gr.Textbox("You are helpful AI.", label="System Prompt")
13
+ slider = gr.Slider(10, 100, render=False)
14
+
15
+ gemini_interface = gr.load(
16
+ name="gemini-1.5-flash", # Se establece el modelo por defecto
17
+ src=gemini_gradio.registry,
18
+ fill_height=True,
19
+ echo, additional_inputs=[system_prompt, slider]
20
+ chatbot=gr.Chatbot(type="messages")
21
+ )
22
+
23
+ demo.launch(ssr_mode=False)