Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -44,43 +44,20 @@ available_models = [
|
|
| 44 |
"hf://ShebMichel/geobot_teacher-v0",
|
| 45 |
"hf://ShebMichel/geobot_teacher-v1"]
|
| 46 |
|
| 47 |
-
# Create a combobox for model selection
|
| 48 |
-
# model_selector = widgets.Combobox(
|
| 49 |
-
# options=available_models,
|
| 50 |
-
# placeholder="Select a model",
|
| 51 |
-
# description="Model:",
|
| 52 |
-
# ensure_option=True
|
| 53 |
-
# )
|
| 54 |
-
# display(model_selector)
|
| 55 |
-
|
| 56 |
-
|
| 57 |
-
# Dropdown widget instead of Combobox for better compatibility
|
| 58 |
-
model_selector = widgets.Dropdown(
|
| 59 |
-
options=available_models,
|
| 60 |
-
description="Model:"
|
| 61 |
-
)
|
| 62 |
-
display(model_selector)
|
| 63 |
|
| 64 |
# Function to load the selected model
|
| 65 |
-
def load_model():
|
| 66 |
-
|
| 67 |
-
|
| 68 |
-
|
| 69 |
-
|
| 70 |
-
|
| 71 |
-
print("Please select a model.")
|
| 72 |
-
return None
|
| 73 |
-
|
| 74 |
|
| 75 |
|
| 76 |
|
| 77 |
#geomodel_llm = keras_nlp.models.CausalLM.from_preset("hf://ShebMichel/geobot_teacher-v0")
|
| 78 |
|
| 79 |
def model_launch(input):
|
| 80 |
-
geomodel_llm = load_model()
|
| 81 |
-
if geomodel_llm is None:
|
| 82 |
-
return "No model selected."
|
| 83 |
-
|
| 84 |
template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
|
| 85 |
prompt = template.format(
|
| 86 |
instruction=input,
|
|
@@ -236,6 +213,13 @@ with gr.Blocks() as iface:
|
|
| 236 |
|
| 237 |
# Submit button - Passes selected question to the model
|
| 238 |
with gr.Row():
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 239 |
submit_button = gr.Button("Submit", interactive=False)
|
| 240 |
clear_button = gr.Button("Clear", interactive=False)
|
| 241 |
|
|
|
|
| 44 |
"hf://ShebMichel/geobot_teacher-v0",
|
| 45 |
"hf://ShebMichel/geobot_teacher-v1"]
|
| 46 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 47 |
|
| 48 |
# Function to load the selected model
|
| 49 |
+
def load_model(model_name):
|
| 50 |
+
# tokenizer = AutoTokenizer.from_pretrained(model_name)
|
| 51 |
+
# model = AutoModelForCausalLM.from_pretrained(model_name)
|
| 52 |
+
# generator = pipeline("text-generation", model=model, tokenizer=tokenizer)
|
| 53 |
+
geomodel_llm = keras_nlp.models.CausalLM.from_preset(model_name)
|
| 54 |
+
return geomodel_llm
|
|
|
|
|
|
|
|
|
|
| 55 |
|
| 56 |
|
| 57 |
|
| 58 |
#geomodel_llm = keras_nlp.models.CausalLM.from_preset("hf://ShebMichel/geobot_teacher-v0")
|
| 59 |
|
| 60 |
def model_launch(input):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
|
| 62 |
prompt = template.format(
|
| 63 |
instruction=input,
|
|
|
|
| 213 |
|
| 214 |
# Submit button - Passes selected question to the model
|
| 215 |
with gr.Row():
|
| 216 |
+
with gr.Row():
|
| 217 |
+
with gr.Column(scale=2):
|
| 218 |
+
model_dropdown = gr.Dropdown(
|
| 219 |
+
choices=available_models,
|
| 220 |
+
label="Select Model",
|
| 221 |
+
value=None
|
| 222 |
+
)
|
| 223 |
submit_button = gr.Button("Submit", interactive=False)
|
| 224 |
clear_button = gr.Button("Clear", interactive=False)
|
| 225 |
|