Spaces:
Paused
Paused
Updated Nightly channel description
Browse files- Tabs/Gemini_Chabot_Nightly.py +5 -1
- app.py +5 -79
Tabs/Gemini_Chabot_Nightly.py
CHANGED
@@ -11,13 +11,17 @@ load_dotenv()
|
|
11 |
GEMINI_API_KEY_NIGHTLY = os.getenv("GEMINI_API_KEY_NIGHTLY")
|
12 |
model_name = "gemini-1.5-flash"
|
13 |
|
14 |
-
TITLE_NIGHTLY = """<h1 align="center">🎮Chat with Gemini 1.5🔥 --
|
15 |
NOTICE_NIGHTLY = """
|
16 |
Notices 📜:
|
17 |
- This app is still in development (extreme unstable)
|
18 |
- Some features may not work as expected
|
19 |
- Currently the chatbot only support text and images
|
20 |
"""
|
|
|
|
|
|
|
|
|
21 |
|
22 |
def upload_to_gemini(path, mime_type=None):
|
23 |
file = genai.upload_file(path, mime_type=mime_type)
|
|
|
11 |
GEMINI_API_KEY_NIGHTLY = os.getenv("GEMINI_API_KEY_NIGHTLY")
|
12 |
model_name = "gemini-1.5-flash"
|
13 |
|
14 |
+
TITLE_NIGHTLY = """<h1 align="center">🎮Chat with Gemini 1.5🔥 -- Nightly</h1>"""
|
15 |
NOTICE_NIGHTLY = """
|
16 |
Notices 📜:
|
17 |
- This app is still in development (extreme unstable)
|
18 |
- Some features may not work as expected
|
19 |
- Currently the chatbot only support text and images
|
20 |
"""
|
21 |
+
ERROR_NIGHTLY = """
|
22 |
+
Known errors ⚠️:
|
23 |
+
- Error when submit messages from uploading files.
|
24 |
+
"""
|
25 |
|
26 |
def upload_to_gemini(path, mime_type=None):
|
27 |
file = genai.upload_file(path, mime_type=mime_type)
|
app.py
CHANGED
@@ -10,7 +10,7 @@ import google.generativeai as genai
|
|
10 |
import gradio as gr
|
11 |
from PIL import Image
|
12 |
from dotenv import load_dotenv
|
13 |
-
from Tabs.Gemini_Chabot_Nightly import TITLE_NIGHTLY, NOTICE_NIGHTLY, gemini_chatbot_stable
|
14 |
|
15 |
load_dotenv()
|
16 |
|
@@ -161,82 +161,6 @@ bot_inputs = [
|
|
161 |
]
|
162 |
# ============================== Stable - END ==============================
|
163 |
|
164 |
-
# # ============================== Nightly - START ==============================
|
165 |
-
# """
|
166 |
-
# References:
|
167 |
-
# - https://medium.com/latinxinai/simple-chatbot-gradio-google-gemini-api-4ce02fbaf09f
|
168 |
-
# """
|
169 |
-
# GEMINI_API_KEY_NIGHTLY = os.getenv("GEMINI_API_KEY_NIGHTLY")
|
170 |
-
# model_nightly_name = "gemini-1.5-flash"
|
171 |
-
|
172 |
-
|
173 |
-
# def transform_history(history):
|
174 |
-
# new_history = []
|
175 |
-
# for user_msg, model_msg in history:
|
176 |
-
# new_history.append({"role": "user", "parts": [{"text": user_msg}]})
|
177 |
-
# new_history.append({"role": "model", "parts": [{"text": model_msg}]})
|
178 |
-
# return new_history
|
179 |
-
|
180 |
-
|
181 |
-
# def upload_to_gemini(path, mime_type=None):
|
182 |
-
# file = genai.upload_file(path, mime_type=mime_type)
|
183 |
-
# print(f"Uploaded file '{file.display_name}' as: {file.uri}")
|
184 |
-
# return file
|
185 |
-
|
186 |
-
|
187 |
-
# def chatbot_nightly(message, history):
|
188 |
-
# print(type(message))
|
189 |
-
# print(message)
|
190 |
-
# message_text = message["text"]
|
191 |
-
# message_files = message["files"]
|
192 |
-
# if message_files and isinstance(message_files, list):
|
193 |
-
# image_uris = [upload_to_gemini(file_path) for file_path in message_files]
|
194 |
-
# message_content = [{"text": message_text}] + image_uris
|
195 |
-
# else:
|
196 |
-
# message_content = {"text": message_text}
|
197 |
-
# genai.configure(api_key=GEMINI_API_KEY_NIGHTLY)
|
198 |
-
# model_nightly = genai.GenerativeModel(
|
199 |
-
# model_nightly_name,
|
200 |
-
# safety_settings=[
|
201 |
-
# {
|
202 |
-
# "category": "HARM_CATEGORY_HARASSMENT",
|
203 |
-
# "threshold": "BLOCK_NONE"
|
204 |
-
# },
|
205 |
-
# {
|
206 |
-
# "category": "HARM_CATEGORY_HATE_SPEECH",
|
207 |
-
# "threshold": "BLOCK_NONE"
|
208 |
-
# },
|
209 |
-
# {
|
210 |
-
# "category": "HARM_CATEGORY_SEXUALLY_EXPLICIT",
|
211 |
-
# "threshold": "BLOCK_NONE"
|
212 |
-
# },
|
213 |
-
# {
|
214 |
-
# "category": "HARM_CATEGORY_DANGEROUS_CONTENT",
|
215 |
-
# "threshold": "BLOCK_NONE"
|
216 |
-
# },
|
217 |
-
# ],
|
218 |
-
# generation_config={
|
219 |
-
# "temperature": 1,
|
220 |
-
# "top_p": 0.95,
|
221 |
-
# "top_k": 64,
|
222 |
-
# "max_output_tokens": 8192,
|
223 |
-
# "response_mime_type": "text/plain",
|
224 |
-
# }
|
225 |
-
# )
|
226 |
-
|
227 |
-
# global chat
|
228 |
-
# chat = model_nightly.start_chat(history=[])
|
229 |
-
# chat.history = transform_history(history)
|
230 |
-
# response_nightly = chat.send_message(message_content)
|
231 |
-
# response_nightly.resolve()
|
232 |
-
|
233 |
-
# for i in range(len(response_nightly.text)):
|
234 |
-
# time.sleep(0.05)
|
235 |
-
# yield response_nightly.text[:i + 1]
|
236 |
-
|
237 |
-
|
238 |
-
# # ============================== Nightly - END ==============================
|
239 |
-
|
240 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
241 |
# ============================== Stable - START ==============================
|
242 |
with gr.Tab("Chat with Gemini 1.5 Flash"):
|
@@ -288,8 +212,10 @@ with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
|
288 |
|
289 |
# ============================== Nightly - START ==============================
|
290 |
with gr.Tab("Nightly -- Chat with Gemini 1.5"):
|
291 |
-
gr.
|
292 |
-
|
|
|
|
|
293 |
gemini_chatbot_stable.render()
|
294 |
# ============================== Nightly - END ==============================
|
295 |
|
|
|
10 |
import gradio as gr
|
11 |
from PIL import Image
|
12 |
from dotenv import load_dotenv
|
13 |
+
from Tabs.Gemini_Chabot_Nightly import TITLE_NIGHTLY, NOTICE_NIGHTLY, ERROR_NIGHTLY, gemini_chatbot_stable
|
14 |
|
15 |
load_dotenv()
|
16 |
|
|
|
161 |
]
|
162 |
# ============================== Stable - END ==============================
|
163 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
164 |
with gr.Blocks(theme=gr.themes.Soft()) as demo:
|
165 |
# ============================== Stable - START ==============================
|
166 |
with gr.Tab("Chat with Gemini 1.5 Flash"):
|
|
|
212 |
|
213 |
# ============================== Nightly - START ==============================
|
214 |
with gr.Tab("Nightly -- Chat with Gemini 1.5"):
|
215 |
+
with gr.Row():
|
216 |
+
gr.HTML(TITLE_NIGHTLY)
|
217 |
+
gr.Markdown(NOTICE_NIGHTLY)
|
218 |
+
gr.Markdown(ERROR_NIGHTLY)
|
219 |
gemini_chatbot_stable.render()
|
220 |
# ============================== Nightly - END ==============================
|
221 |
|