Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -311,11 +311,20 @@ def archive_current_container(database_name, container_name, client):
|
|
311 |
except Exception as e:
|
312 |
return f"An error occurred while archiving data: {str(e)} π’"
|
313 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
314 |
|
315 |
# π Search glossary - Finding needles in digital haystacks
|
316 |
def search_glossary(query):
|
317 |
st.markdown(f"### π SearchGlossary for: {query}")
|
318 |
-
model_options = ['mistralai/Mixtral-8x7B-Instruct-v0.1', 'mistralai/Mistral-7B-Instruct-v0.2'
|
319 |
model_choice = st.selectbox('π§ Select LLM Model', options=model_options, index=1, key=f"model_choice_{id(query)}")
|
320 |
database_options = ['Semantic Search', 'Arxiv Search - Latest - (EXPERIMENTAL)']
|
321 |
database_choice = st.selectbox('π Select Database', options=database_options, index=0, key=f"database_choice_{id(query)}")
|
@@ -368,33 +377,32 @@ def search_glossary(query):
|
|
368 |
#st.code(response2[1], language="python", line_numbers=True, wrap_lines=True)
|
369 |
|
370 |
|
371 |
-
# Persist AI Results to Markdown Files
|
372 |
try:
|
373 |
-
filename =
|
374 |
create_file(filename, query, result)
|
375 |
-
|
376 |
except:
|
377 |
st.markdown('1 error')
|
378 |
try:
|
379 |
-
filename =
|
380 |
create_file(filename, query, result2)
|
381 |
-
|
382 |
except:
|
383 |
-
st.markdown('2 error')
|
384 |
try:
|
385 |
-
filename =
|
386 |
create_file(filename, query, response2[0])
|
387 |
-
|
388 |
except:
|
389 |
st.markdown('3 error')
|
390 |
try:
|
391 |
-
filename =
|
392 |
create_file(filename, query, response2[1])
|
393 |
-
|
394 |
except:
|
395 |
st.markdown('4 error')
|
396 |
|
397 |
-
|
398 |
return result, result2, response2
|
399 |
|
400 |
|
|
|
311 |
except Exception as e:
|
312 |
return f"An error occurred while archiving data: {str(e)} π’"
|
313 |
|
314 |
+
def gen_AI_IO_filename(display_query, output):
|
315 |
+
# Get current time in Central Time Zone
|
316 |
+
now_central = datetime.now(pytz.timezone("America/Chicago"))
|
317 |
+
timestamp = now_central.strftime("%Y-%m-%d-%I-%M-%S-%p")
|
318 |
+
|
319 |
+
# Limit output to first 180 characters and clean up any invalid filename characters
|
320 |
+
output_snippet = re.sub(r'[^A-Za-z0-9]+', '_', output[:180])
|
321 |
+
filename = f"{timestamp} - {display_query} - {output_snippet}.md"
|
322 |
+
return filename
|
323 |
|
324 |
# π Search glossary - Finding needles in digital haystacks
|
325 |
def search_glossary(query):
|
326 |
st.markdown(f"### π SearchGlossary for: {query}")
|
327 |
+
model_options = ['mistralai/Mixtral-8x7B-Instruct-v0.1', 'mistralai/Mistral-7B-Instruct-v0.2']
|
328 |
model_choice = st.selectbox('π§ Select LLM Model', options=model_options, index=1, key=f"model_choice_{id(query)}")
|
329 |
database_options = ['Semantic Search', 'Arxiv Search - Latest - (EXPERIMENTAL)']
|
330 |
database_choice = st.selectbox('π Select Database', options=database_options, index=0, key=f"database_choice_{id(query)}")
|
|
|
377 |
#st.code(response2[1], language="python", line_numbers=True, wrap_lines=True)
|
378 |
|
379 |
|
380 |
+
# β
Persist AI Results to Markdown Files
|
381 |
try:
|
382 |
+
filename = gen_AI_IO_filename(display_query, result)
|
383 |
create_file(filename, query, result)
|
384 |
+
st.markdown(f"β
File saved as: `{filename}`")
|
385 |
except:
|
386 |
st.markdown('1 error')
|
387 |
try:
|
388 |
+
filename = gen_AI_IO_filename(display_query, result2)
|
389 |
create_file(filename, query, result2)
|
390 |
+
st.markdown(f"β
File saved as: `{filename}`")
|
391 |
except:
|
392 |
+
st.markdown('2 error')
|
393 |
try:
|
394 |
+
filename = gen_AI_IO_filename(display_query, response2[0])
|
395 |
create_file(filename, query, response2[0])
|
396 |
+
st.markdown(f"β
File saved as: `{filename}`")
|
397 |
except:
|
398 |
st.markdown('3 error')
|
399 |
try:
|
400 |
+
filename = gen_AI_IO_filename(display_query, response2[1])
|
401 |
create_file(filename, query, response2[1])
|
402 |
+
st.markdown(f"β
File saved as: `{filename}`")
|
403 |
except:
|
404 |
st.markdown('4 error')
|
405 |
|
|
|
406 |
return result, result2, response2
|
407 |
|
408 |
|