Ryouko commited on
Commit
a094782
Β·
verified Β·
1 Parent(s): 743176d

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +39 -32
app.py CHANGED
@@ -98,18 +98,8 @@ def bot_streaming(message, history, api_key, model, system_prompt, temperature,
98
 
99
 
100
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
101
- gr.Markdown("""
102
- # πŸ€– Google Gemini API Multimodal Chat
103
-
104
- Chat with Google Gemini AI models. Supports text and image interactions.
105
-
106
- ## πŸš€ Quick Start:
107
- 1. Enter your Google AI API key
108
- 2. Choose a model
109
- 3. Start chatting!
110
-
111
- Enjoy your AI-powered conversation!
112
- """)
113
 
114
  api_key = gr.Textbox(label="API Key", type="password", placeholder="Enter your Google AI API key")
115
  model = gr.Dropdown(
@@ -130,28 +120,45 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
130
  )
131
  system_prompt = gr.Textbox(label="System Prompt", placeholder="Enter a system prompt (optional)")
132
 
133
- with gr.Row():
134
- chatbot = gr.ChatInterface(
135
- fn=bot_streaming,
136
- additional_inputs=[
137
- api_key, model, system_prompt, gr.Slider(minimum=0, maximum=1, value=0.7, step=0.1, label="Temperature"),
138
- gr.Slider(minimum=1, maximum=2048, value=1000, step=1, label="Max Tokens"), gr.Slider(minimum=0, maximum=1, value=0.95, step=0.01, label="Top P"),
139
- gr.Slider(minimum=1, maximum=40, value=40, step=1, label="Top K"),
140
- gr.Dropdown(label="Harassment", choices=["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"], value="BLOCK_MEDIUM_AND_ABOVE"),
141
- gr.Dropdown(label="Hate Speech", choices=["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"], value="BLOCK_MEDIUM_AND_ABOVE"),
142
- gr.Dropdown(label="Sexually Explicit", choices=["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"], value="BLOCK_MEDIUM_AND_ABOVE"),
143
- gr.Dropdown(label="Dangerous Content", choices=["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"], value="BLOCK_MEDIUM_AND_ABOVE")
144
- ],
145
- title="πŸ’¬ Chat with Google Gemini AI",
146
- description="Upload images or type your message to start the conversation.",
147
- retry_btn="πŸ”„ Retry",
148
- undo_btn="↩️ Undo",
149
- clear_btn="πŸ—‘οΈ Clear",
150
- multimodal=True,
151
- cache_examples=False,
152
- fill_height=True,
153
  )
154
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
155
  gr.Markdown("""
156
  ## πŸ”§ Settings:
157
  - Adjust basic parameters in the "Common Settings" section
 
98
 
99
 
100
  with gr.Blocks(theme=gr.themes.Soft()) as demo:
101
+ gr.Markdown("#πŸ’¬ Chat with Google Gemini AI ")
102
+ gr.Markdown("### Upload images or type your message to start the conversation.")
 
 
 
 
 
 
 
 
 
 
103
 
104
  api_key = gr.Textbox(label="API Key", type="password", placeholder="Enter your Google AI API key")
105
  model = gr.Dropdown(
 
120
  )
121
  system_prompt = gr.Textbox(label="System Prompt", placeholder="Enter a system prompt (optional)")
122
 
123
+ chatbot = gr.ChatInterface(
124
+ fn=bot_streaming,
125
+ additional_inputs=[
126
+ api_key, model, system_prompt, gr.Slider(minimum=0, maximum=1, value=0.7, step=0.1, label="Temperature"),
127
+ gr.Slider(minimum=1, maximum=2048, value=1000, step=1, label="Max Tokens"), gr.Slider(minimum=0, maximum=1, value=0.95, step=0.01, label="Top P"),
128
+ gr.Slider(minimum=1, maximum=40, value=40, step=1, label="Top K"),
129
+ gr.Dropdown(label="Harassment", choices=["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"], value="BLOCK_MEDIUM_AND_ABOVE"),
130
+ gr.Dropdown(label="Hate Speech", choices=["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"], value="BLOCK_MEDIUM_AND_ABOVE"),
131
+ gr.Dropdown(label="Sexually Explicit", choices=["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"], value="BLOCK_MEDIUM_AND_ABOVE"),
132
+ gr.Dropdown(label="Dangerous Content", choices=["BLOCK_NONE", "BLOCK_ONLY_HIGH", "BLOCK_MEDIUM_AND_ABOVE", "BLOCK_LOW_AND_ABOVE"], value="BLOCK_MEDIUM_AND_ABOVE")
133
+ ],
134
+ retry_btn="πŸ”„ Retry",
135
+ undo_btn="↩️ Undo",
136
+ clear_btn="πŸ—‘οΈ Clear",
137
+ multimodal=True,
138
+ cache_examples=False,
139
+ fill_height=True,
 
 
 
140
  )
141
 
142
+
143
+
144
+
145
+
146
+
147
+ gr.Markdown("""
148
+ # πŸ€– Google Gemini API Multimodal Chat
149
+
150
+ Chat with Google Gemini AI models. Supports text and image interactions.
151
+
152
+ ## πŸš€ Quick Start:
153
+ 1. Enter your Google AI API key
154
+ 2. Choose a model
155
+ 3. Start chatting!
156
+
157
+ Enjoy your AI-powered conversation!
158
+ """)
159
+
160
+
161
+
162
  gr.Markdown("""
163
  ## πŸ”§ Settings:
164
  - Adjust basic parameters in the "Common Settings" section