ameerazam08 commited on
Commit
f2d7c4e
1 Parent(s): e2d8169

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +10 -4
app.py CHANGED
@@ -10,11 +10,11 @@ print("google-generativeai:", genai.__version__)
10
 
11
  GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
12
 
13
- TITLE = """<h1 align="center">Gemini Playground 😎</h1>"""
14
- SUBTITLE = """<h2 align="center">Play with Gemini Pro and Gemini Pro Vision API 🖇️</h2>"""
15
  DUPLICATE = """
16
  <div style="text-align: center; display: flex; justify-content: center; align-items: center;">
17
- <a href="https://huggingface.co/spaces/SkalskiP/ChatGemini?duplicate=true">
18
  <img src="https://bit.ly/3gLdBN6" alt="Duplicate Space" style="margin-right: 10px;">
19
  </a>
20
  <span>Duplicate the Space and run securely with your
@@ -44,6 +44,7 @@ def user(text_prompt: str, chatbot: List[Tuple[str, str]]):
44
 
45
  def bot(
46
  google_key: str,
 
47
  image_prompt: Optional[Image.Image],
48
  temperature: float,
49
  max_output_tokens: int,
@@ -68,7 +69,7 @@ def bot(
68
  top_p=top_p)
69
 
70
  if image_prompt is None:
71
- model = genai.GenerativeModel('gemini-pro')
72
  response = model.generate_content(
73
  text_prompt,
74
  stream=True,
@@ -103,6 +104,9 @@ google_key_component = gr.Textbox(
103
  )
104
 
105
  image_prompt_component = gr.Image(type="pil", label="Image", scale=1)
 
 
 
106
  chatbot_component = gr.Chatbot(
107
  label='Gemini',
108
  bubble_full_width=False,
@@ -178,6 +182,7 @@ user_inputs = [
178
 
179
  bot_inputs = [
180
  google_key_component,
 
181
  image_prompt_component,
182
  temperature_component,
183
  max_output_tokens_component,
@@ -195,6 +200,7 @@ with gr.Blocks() as demo:
195
  google_key_component.render()
196
  with gr.Row():
197
  image_prompt_component.render()
 
198
  chatbot_component.render()
199
  text_prompt_component.render()
200
  run_button_component.render()
 
10
 
11
  GOOGLE_API_KEY = os.environ.get("GOOGLE_API_KEY")
12
 
13
+ TITLE = """<h1 align="center">🕹️ Google Gemini Playground 🔥</h1>"""
14
+ SUBTITLE = """<h2 align="center">Play with Gemini Text and Vision Model API 🖇️</h2>"""
15
  DUPLICATE = """
16
  <div style="text-align: center; display: flex; justify-content: center; align-items: center;">
17
+ <a href="https://huggingface.co/spaces/ameerazam08/Gemini-All-in-One?logs=container&duplicate=true">
18
  <img src="https://bit.ly/3gLdBN6" alt="Duplicate Space" style="margin-right: 10px;">
19
  </a>
20
  <span>Duplicate the Space and run securely with your
 
44
 
45
  def bot(
46
  google_key: str,
47
+ model_name: str,
48
  image_prompt: Optional[Image.Image],
49
  temperature: float,
50
  max_output_tokens: int,
 
69
  top_p=top_p)
70
 
71
  if image_prompt is None:
72
+ model = genai.GenerativeModel(model_name)
73
  response = model.generate_content(
74
  text_prompt,
75
  stream=True,
 
104
  )
105
 
106
  image_prompt_component = gr.Image(type="pil", label="Image", scale=1)
107
+
108
+ model_selection = gr.Dropdown(["gemini-1.0-pro", "gemini-pro-vision","gemini-1.5-flash-latest", "gemini-1.5-pro-latest","gemini-1.0-pro-001"],label="Select Gemini Model",value="gemini-1.0-pro")
109
+
110
  chatbot_component = gr.Chatbot(
111
  label='Gemini',
112
  bubble_full_width=False,
 
182
 
183
  bot_inputs = [
184
  google_key_component,
185
+ model_selection,
186
  image_prompt_component,
187
  temperature_component,
188
  max_output_tokens_component,
 
200
  google_key_component.render()
201
  with gr.Row():
202
  image_prompt_component.render()
203
+ model_selection.render()
204
  chatbot_component.render()
205
  text_prompt_component.render()
206
  run_button_component.render()