Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -43,6 +43,7 @@ body::before {
|
|
| 43 |
available_models = [
|
| 44 |
"hf://ShebMichel/geobot_teacher-v0",
|
| 45 |
"hf://ShebMichel/geobot_teacher-v1"]
|
|
|
|
| 46 |
|
| 47 |
# geomodel_llm = keras_nlp.models.CausalLM.from_preset("hf://ShebMichel/geobot_teacher-v0")
|
| 48 |
# Function to load the selected model
|
|
@@ -53,7 +54,7 @@ def load_model(model_name):
|
|
| 53 |
|
| 54 |
|
| 55 |
|
| 56 |
-
def model_launch(input,
|
| 57 |
return f"Model: {selected_output}\nResponse to: {input}"
|
| 58 |
# geomodel_llm=load_model(selected_model)
|
| 59 |
# template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
|
|
@@ -163,6 +164,12 @@ def submit_question(question_content):
|
|
| 163 |
def display_selected_model(selected_model):
|
| 164 |
return f"Selected Model: {selected_model}"
|
| 165 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 166 |
def clear_output():
|
| 167 |
return "", ""
|
| 168 |
|
|
@@ -202,17 +209,33 @@ with gr.Blocks() as iface:
|
|
| 202 |
model_dropdown = gr.Dropdown(
|
| 203 |
choices=available_models,
|
| 204 |
label="Select Model",
|
| 205 |
-
value=
|
| 206 |
# visible=False # Initially hidden
|
| 207 |
)
|
| 208 |
# Create a Textbox to display the selected model
|
| 209 |
-
selected_output = gr.Textbox(label="Selected Model", interactive=False)
|
| 210 |
# Set up an event to update the Textbox when a model is selected
|
| 211 |
-
model_dropdown.change(
|
| 212 |
-
|
| 213 |
-
|
| 214 |
-
|
| 215 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
#select_button = gr.Button("Select Model", variant="primary")
|
| 217 |
|
| 218 |
# Editable question text box
|
|
@@ -244,7 +267,7 @@ with gr.Blocks() as iface:
|
|
| 244 |
|
| 245 |
submit_button.click(
|
| 246 |
fn=model_launch,#submit_question, ## model_launch
|
| 247 |
-
inputs=[question_edit,
|
| 248 |
outputs=[model_response]
|
| 249 |
)
|
| 250 |
|
|
|
|
| 43 |
available_models = [
|
| 44 |
"hf://ShebMichel/geobot_teacher-v0",
|
| 45 |
"hf://ShebMichel/geobot_teacher-v1"]
|
| 46 |
+
first_model = available_models[0] # Set the first item as a global variable
|
| 47 |
|
| 48 |
# geomodel_llm = keras_nlp.models.CausalLM.from_preset("hf://ShebMichel/geobot_teacher-v0")
|
| 49 |
# Function to load the selected model
|
|
|
|
| 54 |
|
| 55 |
|
| 56 |
|
| 57 |
+
def model_launch(input,first_model):
|
| 58 |
return f"Model: {selected_output}\nResponse to: {input}"
|
| 59 |
# geomodel_llm=load_model(selected_model)
|
| 60 |
# template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
|
|
|
|
| 164 |
def display_selected_model(selected_model):
|
| 165 |
return f"Selected Model: {selected_model}"
|
| 166 |
|
| 167 |
+
# Function to update the global `first_model` whenever the dropdown changes
|
| 168 |
+
def update_first_model(selected_model):
|
| 169 |
+
global first_model
|
| 170 |
+
first_model = selected_model
|
| 171 |
+
return f"Selected Model: {first_model}"
|
| 172 |
+
|
| 173 |
def clear_output():
|
| 174 |
return "", ""
|
| 175 |
|
|
|
|
| 209 |
model_dropdown = gr.Dropdown(
|
| 210 |
choices=available_models,
|
| 211 |
label="Select Model",
|
| 212 |
+
value=first_model # Set initial selection to the first model
|
| 213 |
# visible=False # Initially hidden
|
| 214 |
)
|
| 215 |
# Create a Textbox to display the selected model
|
| 216 |
+
#selected_output = gr.Textbox(label="Selected Model", interactive=False)
|
| 217 |
# Set up an event to update the Textbox when a model is selected
|
| 218 |
+
# model_dropdown.change(
|
| 219 |
+
# fn=display_selected_model,
|
| 220 |
+
# inputs=model_dropdown,
|
| 221 |
+
# outputs=selected_output
|
| 222 |
+
# )
|
| 223 |
+
|
| 224 |
+
# # Create the dropdown for model selection
|
| 225 |
+
# model_dropdown = gr.Dropdown(
|
| 226 |
+
# choices=available_models,
|
| 227 |
+
# label="Select Model",
|
| 228 |
+
# value=first_model # Set initial selection to the first model
|
| 229 |
+
# )
|
| 230 |
+
# Textbox to display the current selected model
|
| 231 |
+
selected_output = gr.Textbox(label="Current Selected Model", value=f"Selected Model: {first_model}")
|
| 232 |
+
|
| 233 |
+
# Update the global `first_model` when dropdown changes and display it
|
| 234 |
+
model_dropdown.change(
|
| 235 |
+
fn=update_first_model,
|
| 236 |
+
inputs=model_dropdown,
|
| 237 |
+
outputs=selected_output
|
| 238 |
+
)
|
| 239 |
#select_button = gr.Button("Select Model", variant="primary")
|
| 240 |
|
| 241 |
# Editable question text box
|
|
|
|
| 267 |
|
| 268 |
submit_button.click(
|
| 269 |
fn=model_launch,#submit_question, ## model_launch
|
| 270 |
+
inputs=[question_edit, first_model], # Include the dropdown in inputs
|
| 271 |
outputs=[model_response]
|
| 272 |
)
|
| 273 |
|