Update app.py
Browse files
app.py
CHANGED
@@ -27,11 +27,44 @@ OPENROUTER_MODELS = [
|
|
27 |
# ββ Sidebar controls βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
28 |
with st.sidebar:
|
29 |
st.subheader("Model & Generation Settings")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
30 |
model_choice = st.selectbox("OpenRouter model", OPENROUTER_MODELS, index=0)
|
31 |
custom_model = st.text_input("Custom model id (optional)", placeholder="e.g. meta-llama/llama-3.1-8b-instruct")
|
32 |
-
temperature = st.slider("Temperature", 0.0, 1.0, 0.1, 0.05)
|
33 |
-
top_p = st.slider("Top-p", 0.0, 1.0, 0.5, 0.05)
|
34 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
35 |
st.markdown("### Ontology (labels)")
|
36 |
labels_text = st.text_area(
|
37 |
"Comma-separated labels",
|
@@ -42,7 +75,6 @@ with st.sidebar:
|
|
42 |
"Relationships (comma-separated)",
|
43 |
value="Relation between any pair of Entities",
|
44 |
)
|
45 |
-
|
46 |
# ββ Helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
47 |
def parse_labels(text: str):
|
48 |
return [lbl.strip() for lbl in text.split(",") if lbl.strip()] or [
|
|
|
27 |
# ββ Sidebar controls βββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
28 |
with st.sidebar:
|
29 |
st.subheader("Model & Generation Settings")
|
30 |
+
|
31 |
+
# Model choices
|
32 |
+
OPENROUTER_MODELS = [
|
33 |
+
"openai/gpt-oss-20b:free",
|
34 |
+
"moonshotai/kimi-k2:free",
|
35 |
+
"google/gemini-2.0-flash-exp:free",
|
36 |
+
"google/gemma-3-27b-it:free",
|
37 |
+
]
|
38 |
model_choice = st.selectbox("OpenRouter model", OPENROUTER_MODELS, index=0)
|
39 |
custom_model = st.text_input("Custom model id (optional)", placeholder="e.g. meta-llama/llama-3.1-8b-instruct")
|
|
|
|
|
40 |
|
41 |
+
st.markdown("### Preset")
|
42 |
+
PRESETS = {
|
43 |
+
"Extractive (stable)": {"temperature": 0.1, "top_p": 0.9, "desc": "Most deterministic; best for IE"},
|
44 |
+
"Balanced": {"temperature": 0.2, "top_p": 0.9, "desc": "Slightly more recall"},
|
45 |
+
"Exploratory": {"temperature": 0.4, "top_p": 0.95, "desc": "More ideas; may add noise"},
|
46 |
+
}
|
47 |
+
preset_names = list(PRESETS.keys())
|
48 |
+
preset = st.selectbox("Choose a preset", preset_names, index=0,
|
49 |
+
help=PRESETS[preset_names[0]]["desc"])
|
50 |
+
|
51 |
+
# Apply preset button updates the sliders below
|
52 |
+
if st.button("Apply preset"):
|
53 |
+
st.session_state.temperature = PRESETS[preset]["temperature"]
|
54 |
+
st.session_state.top_p = PRESETS[preset]["top_p"]
|
55 |
+
st.toast(f"Applied: {preset}", icon="β
")
|
56 |
+
|
57 |
+
# Sliders are bound to session state so the button can set them
|
58 |
+
temperature = st.slider(
|
59 |
+
"Temperature", 0.0, 1.0, key="temperature", step=0.05,
|
60 |
+
help="Lower = more deterministic; higher = more variety"
|
61 |
+
)
|
62 |
+
top_p = st.slider(
|
63 |
+
"Top-p", 0.0, 1.0, key="top_p", step=0.05,
|
64 |
+
help="Nucleus sampling threshold; 0.9 is a good default"
|
65 |
+
)
|
66 |
+
|
67 |
+
# Ontology controls
|
68 |
st.markdown("### Ontology (labels)")
|
69 |
labels_text = st.text_area(
|
70 |
"Comma-separated labels",
|
|
|
75 |
"Relationships (comma-separated)",
|
76 |
value="Relation between any pair of Entities",
|
77 |
)
|
|
|
78 |
# ββ Helpers ββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββββ
|
79 |
def parse_labels(text: str):
|
80 |
return [lbl.strip() for lbl in text.split(",") if lbl.strip()] or [
|