Spaces:
Build error
Build error
combox for model selection added
Browse files
app.py
CHANGED
|
@@ -37,9 +37,40 @@ body::before {
|
|
| 37 |
"""
|
| 38 |
|
| 39 |
|
| 40 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 41 |
|
| 42 |
def model_launch(input):
|
|
|
|
|
|
|
|
|
|
|
|
|
| 43 |
template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
|
| 44 |
prompt = template.format(
|
| 45 |
instruction=input,
|
|
@@ -49,9 +80,6 @@ def model_launch(input):
|
|
| 49 |
ind = out.index('Response') + len('Response')+2
|
| 50 |
return out[ind:]
|
| 51 |
|
| 52 |
-
import json
|
| 53 |
-
import gradio as gr
|
| 54 |
-
|
| 55 |
# Global variable to store loaded JSON data
|
| 56 |
loaded_data = {}
|
| 57 |
|
|
|
|
| 37 |
"""
|
| 38 |
|
| 39 |
|
| 40 |
+
# List of available models
|
| 41 |
+
available_models = [
|
| 42 |
+
"hf://ShebMichel/geobot_teacher-v0",
|
| 43 |
+
"hf://ShebMichel/geobot_teacher-v1"]
|
| 44 |
+
|
| 45 |
+
# Create a combobox for model selection
|
| 46 |
+
model_selector = widgets.Combobox(
|
| 47 |
+
options=available_models,
|
| 48 |
+
placeholder="Select a model",
|
| 49 |
+
description="Model:",
|
| 50 |
+
ensure_option=True
|
| 51 |
+
)
|
| 52 |
+
display(model_selector)
|
| 53 |
+
|
| 54 |
+
# Function to load the selected model
|
| 55 |
+
def load_model():
|
| 56 |
+
selected_model = model_selector.value
|
| 57 |
+
if selected_model:
|
| 58 |
+
geomodel_llm = keras_nlp.models.CausalLM.from_preset(selected_model)
|
| 59 |
+
return geomodel_llm
|
| 60 |
+
else:
|
| 61 |
+
print("Please select a model.")
|
| 62 |
+
return None
|
| 63 |
+
|
| 64 |
+
|
| 65 |
+
|
| 66 |
+
|
| 67 |
+
#geomodel_llm = keras_nlp.models.CausalLM.from_preset("hf://ShebMichel/geobot_teacher-v0")
|
| 68 |
|
| 69 |
def model_launch(input):
|
| 70 |
+
geomodel_llm = load_model()
|
| 71 |
+
if geomodel_llm is None:
|
| 72 |
+
return "No model selected."
|
| 73 |
+
|
| 74 |
template = "Instruction:\n{instruction}\n\nResponse:\n{response}"
|
| 75 |
prompt = template.format(
|
| 76 |
instruction=input,
|
|
|
|
| 80 |
ind = out.index('Response') + len('Response')+2
|
| 81 |
return out[ind:]
|
| 82 |
|
|
|
|
|
|
|
|
|
|
| 83 |
# Global variable to store loaded JSON data
|
| 84 |
loaded_data = {}
|
| 85 |
|