Spaces:
Sleeping
Sleeping
revert default model, use additional environ variable to default it
Browse files- streamlit_app.py +13 -7
streamlit_app.py
CHANGED
|
@@ -225,7 +225,9 @@ with st.sidebar:
|
|
| 225 |
st.session_state['model'] = model = st.selectbox(
|
| 226 |
"Model:",
|
| 227 |
options=OPENAI_MODELS + list(OPEN_MODELS.keys()),
|
| 228 |
-
index=OPENAI_MODELS.index(
|
|
|
|
|
|
|
| 229 |
placeholder="Select model",
|
| 230 |
help="Select the LLM model:",
|
| 231 |
disabled=st.session_state['doc_id'] is not None or st.session_state['uploaded']
|
|
@@ -313,8 +315,8 @@ with st.sidebar:
|
|
| 313 |
disabled=uploaded_file is not None)
|
| 314 |
if chunk_size == -1:
|
| 315 |
context_size = st.slider("Context size", 3, 20, value=10,
|
| 316 |
-
|
| 317 |
-
|
| 318 |
else:
|
| 319 |
context_size = st.slider("Context size", 3, 10, value=4,
|
| 320 |
help="Number of chunks to consider when answering a question",
|
|
@@ -363,17 +365,20 @@ if uploaded_file and not st.session_state.loaded_embeddings:
|
|
| 363 |
|
| 364 |
# timestamp = datetime.utcnow()
|
| 365 |
|
|
|
|
| 366 |
def rgb_to_hex(rgb):
|
| 367 |
return "#{:02x}{:02x}{:02x}".format(*rgb)
|
| 368 |
|
|
|
|
| 369 |
def generate_color_gradient(num_elements):
|
| 370 |
# Define warm and cold colors in RGB format
|
| 371 |
warm_color = (255, 165, 0) # Orange
|
| 372 |
-
cold_color = (0, 0, 255)
|
| 373 |
|
| 374 |
# Generate a linear gradient of colors
|
| 375 |
color_gradient = [
|
| 376 |
-
rgb_to_hex(tuple(int(warm * (1 - i/num_elements) + cold * (i/num_elements)) for warm, cold in
|
|
|
|
| 377 |
for i in range(num_elements)
|
| 378 |
]
|
| 379 |
|
|
@@ -427,7 +432,7 @@ with right_column:
|
|
| 427 |
context_size=context_size)
|
| 428 |
annotations = [
|
| 429 |
GrobidAggregationProcessor.box_to_dict(coo) for coo in [c.split(",") for coord in
|
| 430 |
-
|
| 431 |
]
|
| 432 |
gradients = generate_color_gradient(len(annotations))
|
| 433 |
for i, color in enumerate(gradients):
|
|
@@ -465,6 +470,7 @@ with right_column:
|
|
| 465 |
with left_column:
|
| 466 |
if st.session_state['binary']:
|
| 467 |
if st.session_state['should_show_annotations']:
|
| 468 |
-
pdf_viewer(input=st.session_state['binary'], width=600, height=800,
|
|
|
|
| 469 |
else:
|
| 470 |
pdf_viewer(input=st.session_state['binary'], width=600, height=800)
|
|
|
|
| 225 |
st.session_state['model'] = model = st.selectbox(
|
| 226 |
"Model:",
|
| 227 |
options=OPENAI_MODELS + list(OPEN_MODELS.keys()),
|
| 228 |
+
index=(OPENAI_MODELS + list(OPEN_MODELS.keys())).index(
|
| 229 |
+
"zephyr-7b-beta") if "DEFAULT_MODEL" not in os.environ or not os.environ["DEFAULT_MODEL"] else (
|
| 230 |
+
OPENAI_MODELS + list(OPEN_MODELS.keys())).index(os.environ["DEFAULT_MODEL"]),
|
| 231 |
placeholder="Select model",
|
| 232 |
help="Select the LLM model:",
|
| 233 |
disabled=st.session_state['doc_id'] is not None or st.session_state['uploaded']
|
|
|
|
| 315 |
disabled=uploaded_file is not None)
|
| 316 |
if chunk_size == -1:
|
| 317 |
context_size = st.slider("Context size", 3, 20, value=10,
|
| 318 |
+
help="Number of paragraphs to consider when answering a question",
|
| 319 |
+
disabled=not uploaded_file)
|
| 320 |
else:
|
| 321 |
context_size = st.slider("Context size", 3, 10, value=4,
|
| 322 |
help="Number of chunks to consider when answering a question",
|
|
|
|
| 365 |
|
| 366 |
# timestamp = datetime.utcnow()
|
| 367 |
|
| 368 |
+
|
| 369 |
def rgb_to_hex(rgb):
|
| 370 |
return "#{:02x}{:02x}{:02x}".format(*rgb)
|
| 371 |
|
| 372 |
+
|
| 373 |
def generate_color_gradient(num_elements):
|
| 374 |
# Define warm and cold colors in RGB format
|
| 375 |
warm_color = (255, 165, 0) # Orange
|
| 376 |
+
cold_color = (0, 0, 255) # Blue
|
| 377 |
|
| 378 |
# Generate a linear gradient of colors
|
| 379 |
color_gradient = [
|
| 380 |
+
rgb_to_hex(tuple(int(warm * (1 - i / num_elements) + cold * (i / num_elements)) for warm, cold in
|
| 381 |
+
zip(warm_color, cold_color)))
|
| 382 |
for i in range(num_elements)
|
| 383 |
]
|
| 384 |
|
|
|
|
| 432 |
context_size=context_size)
|
| 433 |
annotations = [
|
| 434 |
GrobidAggregationProcessor.box_to_dict(coo) for coo in [c.split(",") for coord in
|
| 435 |
+
coordinates for c in coord]
|
| 436 |
]
|
| 437 |
gradients = generate_color_gradient(len(annotations))
|
| 438 |
for i, color in enumerate(gradients):
|
|
|
|
| 470 |
with left_column:
|
| 471 |
if st.session_state['binary']:
|
| 472 |
if st.session_state['should_show_annotations']:
|
| 473 |
+
pdf_viewer(input=st.session_state['binary'], width=600, height=800,
|
| 474 |
+
annotations=st.session_state['annotations'])
|
| 475 |
else:
|
| 476 |
pdf_viewer(input=st.session_state['binary'], width=600, height=800)
|