JeCabrera commited on
Commit
5b495fa
verified
1 Parent(s): 48be0c5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +35 -9
app.py CHANGED
@@ -1,14 +1,40 @@
1
  import gradio as gr
2
  import gemini_gradio
 
3
 
4
- with gr.Blocks(fill_height=True) as demo:
5
- gr.Markdown("**Note:** You need to use a SambaNova API key from [SambaNova Cloud](https://cloud.sambanova.ai/).")
6
-
7
- gemini_interface = gr.load(
8
- name="gemini-1.5-flash", # Se establece el modelo por defecto
9
- src=gemini_gradio.registry,
10
- fill_height=True,
11
- chatbot=gr.Chatbot(type="messages")
 
 
 
 
 
 
 
 
 
12
  )
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
13
 
14
- demo.launch(ssr_mode=False)
 
1
  import gradio as gr
2
  import gemini_gradio
3
+ import genai # Si es necesario, asegurarte de que este tambi茅n est茅 instalado
4
 
5
+ # Configuraci贸n del modelo Gemini
6
+ generation_config = {
7
+ "temperature": 1,
8
+ "top_p": 0.95,
9
+ "top_k": 40,
10
+ "max_output_tokens": 8192,
11
+ "response_mime_type": "text/plain",
12
+ }
13
+
14
+ GOOGLE_API_KEY = "your_google_api_key_here" # Aseg煤rate de agregar tu API Key
15
+
16
+ # Configuraci贸n del modelo en gemini_gradio
17
+ def configure_model():
18
+ genai.configure(api_key=GOOGLE_API_KEY) # Configura la API Key
19
+ model = genai.GenerativeModel(
20
+ model_name="gemini-1.5-flash",
21
+ generation_config=generation_config
22
  )
23
+ return model
24
+
25
+ # Funci贸n que genera la respuesta usando el modelo configurado
26
+ def generate_response(input_text):
27
+ model = configure_model() # Cargar el modelo con los par谩metros configurados
28
+ response = model.generate(input_text) # Generar la respuesta
29
+ return response.text # Ajusta seg煤n la estructura de la respuesta del modelo
30
+
31
+ # Integraci贸n con la interfaz Gradio
32
+ with gr.Blocks() as demo:
33
+ gr.Markdown("**Gemini Model with Custom Parameters**")
34
+
35
+ input_text = gr.Textbox(label="Enter Text", placeholder="Type here...")
36
+ output_text = gr.Textbox(label="Generated Response")
37
+
38
+ input_text.submit(generate_response, inputs=input_text, outputs=output_text)
39
 
40
+ demo.launch()