JeCabrera commited on
Commit
becced4
·
verified ·
1 Parent(s): 068d590

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -36
app.py CHANGED
@@ -1,4 +1,4 @@
1
- TITLE = """<h1 align="center">Gemini Playground 💬</h1>"""
2
  SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision</h2>"""
3
 
4
  import os
@@ -57,9 +57,6 @@ def user(text_prompt: str, chatbot: CHAT_HISTORY):
57
 
58
  def bot(
59
  files: Optional[List[str]],
60
- temperature: float,
61
- top_k: int,
62
- top_p: float,
63
  model_choice: str,
64
  chatbot: CHAT_HISTORY
65
  ):
@@ -69,10 +66,10 @@ def bot(
69
  # Configurar la API con la clave
70
  genai.configure(api_key=GOOGLE_API_KEY)
71
  generation_config = genai.types.GenerationConfig(
72
- temperature=temperature,
73
  max_output_tokens=8192, # Fijar el límite de tokens a 8,192
74
- top_k=top_k,
75
- top_p=top_p
76
  )
77
 
78
  text_prompt = [chatbot[-1][0]] if chatbot and chatbot[-1][0] and isinstance(chatbot[-1][0], str) else []
@@ -101,27 +98,6 @@ upload_button_component = gr.UploadButton(
101
  label="Upload Images", file_count="multiple", file_types=["image"], scale=1
102
  )
103
  run_button_component = gr.Button(value="Run", variant="primary", scale=1)
104
- temperature_component = gr.Slider(
105
- minimum=0,
106
- maximum=1.0,
107
- value=0.4,
108
- step=0.05,
109
- label="Temperature",
110
- )
111
- top_k_component = gr.Slider(
112
- minimum=1,
113
- maximum=40,
114
- value=32,
115
- step=1,
116
- label="Top-K",
117
- )
118
- top_p_component = gr.Slider(
119
- minimum=0,
120
- maximum=1,
121
- value=1,
122
- step=0.01,
123
- label="Top-P",
124
- )
125
  model_choice_component = gr.Dropdown(
126
  choices=["gemini-1.5-flash", "gemini-2.0-flash-exp", "gemini-1.5-pro"],
127
  value="gemini-1.5-flash",
@@ -136,9 +112,6 @@ user_inputs = [
136
 
137
  bot_inputs = [
138
  upload_button_component,
139
- temperature_component,
140
- top_k_component,
141
- top_p_component,
142
  model_choice_component,
143
  chatbot_component
144
  ]
@@ -152,11 +125,7 @@ with gr.Blocks() as demo:
152
  text_prompt_component.render()
153
  upload_button_component.render()
154
  run_button_component.render()
155
- with gr.Accordion("Personaliza tu bot", open=False):
156
- temperature_component.render()
157
- top_k_component.render()
158
- top_p_component.render()
159
- model_choice_component.render()
160
 
161
  run_button_component.click(
162
  fn=user,
 
1
+ TITLE = """<h1 align="center">Gemini Playground ✨</h1>"""
2
  SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision</h2>"""
3
 
4
  import os
 
57
 
58
  def bot(
59
  files: Optional[List[str]],
 
 
 
60
  model_choice: str,
61
  chatbot: CHAT_HISTORY
62
  ):
 
66
  # Configurar la API con la clave
67
  genai.configure(api_key=GOOGLE_API_KEY)
68
  generation_config = genai.types.GenerationConfig(
69
+ temperature=0.7, # Valor predeterminado
70
  max_output_tokens=8192, # Fijar el límite de tokens a 8,192
71
+ top_k=10, # Valor predeterminado
72
+ top_p=0.9 # Valor predeterminado
73
  )
74
 
75
  text_prompt = [chatbot[-1][0]] if chatbot and chatbot[-1][0] and isinstance(chatbot[-1][0], str) else []
 
98
  label="Upload Images", file_count="multiple", file_types=["image"], scale=1
99
  )
100
  run_button_component = gr.Button(value="Run", variant="primary", scale=1)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
101
  model_choice_component = gr.Dropdown(
102
  choices=["gemini-1.5-flash", "gemini-2.0-flash-exp", "gemini-1.5-pro"],
103
  value="gemini-1.5-flash",
 
112
 
113
  bot_inputs = [
114
  upload_button_component,
 
 
 
115
  model_choice_component,
116
  chatbot_component
117
  ]
 
125
  text_prompt_component.render()
126
  upload_button_component.render()
127
  run_button_component.render()
128
+ model_choice_component.render()
 
 
 
 
129
 
130
  run_button_component.click(
131
  fn=user,