Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -1,14 +1,40 @@
|
|
1 |
import gradio as gr
|
2 |
import gemini_gradio
|
|
|
3 |
|
4 |
-
|
5 |
-
|
6 |
-
|
7 |
-
|
8 |
-
|
9 |
-
|
10 |
-
|
11 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
12 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
13 |
|
14 |
-
demo.launch(
|
|
|
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()
|