Liu Hong Yuan Tom
commited on
Update app.py
Browse files
app.py
CHANGED
|
@@ -84,6 +84,7 @@ def user(text_prompt: str, chatbot: CHAT_HISTORY):
|
|
| 84 |
|
| 85 |
def bot(
|
| 86 |
google_key: str,
|
|
|
|
| 87 |
files: Optional[List[str]],
|
| 88 |
temperature: float,
|
| 89 |
max_output_tokens: int,
|
|
@@ -114,14 +115,14 @@ def bot(
|
|
| 114 |
if chatbot[-1][0] and isinstance(chatbot[-1][0], str) \
|
| 115 |
else []
|
| 116 |
image_prompt = [Image.open(file).convert('RGB') for file in files]
|
| 117 |
-
model = genai.GenerativeModel(
|
| 118 |
response = model.generate_content(
|
| 119 |
text_prompt + image_prompt,
|
| 120 |
stream=True,
|
| 121 |
generation_config=generation_config)
|
| 122 |
else:
|
| 123 |
messages = preprocess_chat_history(chatbot)
|
| 124 |
-
model = genai.GenerativeModel(
|
| 125 |
response = model.generate_content(
|
| 126 |
messages,
|
| 127 |
stream=True,
|
|
@@ -136,6 +137,15 @@ def bot(
|
|
| 136 |
time.sleep(0.01)
|
| 137 |
yield chatbot
|
| 138 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 139 |
|
| 140 |
google_key_component = gr.Textbox(
|
| 141 |
label="GOOGLE API KEY",
|
|
@@ -224,6 +234,7 @@ user_inputs = [
|
|
| 224 |
|
| 225 |
bot_inputs = [
|
| 226 |
google_key_component,
|
|
|
|
| 227 |
upload_button_component,
|
| 228 |
temperature_component,
|
| 229 |
max_output_tokens_component,
|
|
|
|
| 84 |
|
| 85 |
def bot(
|
| 86 |
google_key: str,
|
| 87 |
+
model_name: str,
|
| 88 |
files: Optional[List[str]],
|
| 89 |
temperature: float,
|
| 90 |
max_output_tokens: int,
|
|
|
|
| 115 |
if chatbot[-1][0] and isinstance(chatbot[-1][0], str) \
|
| 116 |
else []
|
| 117 |
image_prompt = [Image.open(file).convert('RGB') for file in files]
|
| 118 |
+
model = genai.GenerativeModel(model_name)
|
| 119 |
response = model.generate_content(
|
| 120 |
text_prompt + image_prompt,
|
| 121 |
stream=True,
|
| 122 |
generation_config=generation_config)
|
| 123 |
else:
|
| 124 |
messages = preprocess_chat_history(chatbot)
|
| 125 |
+
model = genai.GenerativeModel(model_name)
|
| 126 |
response = model.generate_content(
|
| 127 |
messages,
|
| 128 |
stream=True,
|
|
|
|
| 137 |
time.sleep(0.01)
|
| 138 |
yield chatbot
|
| 139 |
|
| 140 |
+
model_selection = gr.Dropdown(
|
| 141 |
+
["gemini-1.0-pro",
|
| 142 |
+
"gemini-1.5-flash",
|
| 143 |
+
"gemini-1.5-pro",
|
| 144 |
+
"gemini-1.5-pro-exp-0801"
|
| 145 |
+
],
|
| 146 |
+
label="Select Gemini Model",
|
| 147 |
+
value="gemini-1.5-pro"
|
| 148 |
+
)
|
| 149 |
|
| 150 |
google_key_component = gr.Textbox(
|
| 151 |
label="GOOGLE API KEY",
|
|
|
|
| 234 |
|
| 235 |
bot_inputs = [
|
| 236 |
google_key_component,
|
| 237 |
+
model_selection,
|
| 238 |
upload_button_component,
|
| 239 |
temperature_component,
|
| 240 |
max_output_tokens_component,
|