riabayonaor commited on
Commit
80b8320
verified
1 Parent(s): b0d3a61

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +16 -5
app.py CHANGED
@@ -1,21 +1,32 @@
1
  import os
2
- import google.generativeai as genai
3
  import gradio as gr
 
 
4
 
 
5
  gemini_api_key = os.getenv("GEMINI_API_KEY")
 
 
6
  genai.configure(api_key=gemini_api_key)
 
 
7
  model = genai.GenerativeModel('gemini-pro')
8
 
9
  def chat_with_model(user_input):
 
10
  response = model.generate_content(user_input)
11
  return response.text
12
 
13
- chat_interface = gr.Interface(
 
14
  fn=chat_with_model,
15
- inputs=gr.inputs.Textbox(lines=2, placeholder="Enter your message here..."),
16
  outputs="text",
17
  title="Chatbot Demo",
18
- description="This is a chatbot demo using a generative model from Google's generative AI. Enter your message and get a response."
19
  )
20
 
21
- chat_interface.launch()
 
 
 
 
1
  import os
 
2
  import gradio as gr
3
+ # Asumiendo que 'google.generativeai' es un paquete v谩lido y est谩 instalado correctamente.
4
+ import google.generativeai as genai
5
 
6
+ # Obteniendo la API KEY del entorno
7
  gemini_api_key = os.getenv("GEMINI_API_KEY")
8
+
9
+ # Configuraci贸n de la API KEY para el uso de genai
10
  genai.configure(api_key=gemini_api_key)
11
+
12
+ # Inicializaci贸n del modelo
13
  model = genai.GenerativeModel('gemini-pro')
14
 
15
  def chat_with_model(user_input):
16
+ # Generaci贸n de contenido usando el modelo configurado
17
  response = model.generate_content(user_input)
18
  return response.text
19
 
20
+ # Definici贸n de la interfaz de Gradio
21
+ interface = gr.Interface(
22
  fn=chat_with_model,
23
+ inputs=gr.Textbox(lines=2, placeholder="Enter your message here..."),
24
  outputs="text",
25
  title="Chatbot Demo",
26
+ description="This is a chatbot demo using a generative model. Enter your message and get a response."
27
  )
28
 
29
+ # Ejecuci贸n de la interfaz
30
+ if __name__ == "__main__":
31
+ interface.launch()
32
+