Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -259,6 +259,57 @@ def create_and_save_file(content, file_type="md", prompt=None, is_image=False, s
|
|
259 |
|
260 |
return filename
|
261 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
262 |
# 🎈 Let's modify the main app to be more fun!
|
263 |
def main():
|
264 |
st.title("🐙Git🌌Cosmos💫 - Azure Cosmos DB and Github Agent")
|
@@ -281,16 +332,34 @@ def main():
|
|
281 |
if 'cloned_doc' not in st.session_state:
|
282 |
st.session_state.cloned_doc = None
|
283 |
|
284 |
-
|
|
|
285 |
try:
|
286 |
query_params = st.query_params
|
287 |
-
query = (query_params.get('q') or query_params.get('query') or [''])
|
288 |
-
if query:
|
289 |
-
#
|
290 |
-
|
291 |
-
|
292 |
-
|
|
|
|
|
|
|
293 |
st.markdown(' ')
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
294 |
|
295 |
# 🔐 Automatic Login
|
296 |
if Key:
|
|
|
259 |
|
260 |
return filename
|
261 |
|
262 |
+
|
263 |
+
|
264 |
+
# 🔍Search Glossary
|
265 |
+
# @st.cache_resource
|
266 |
+
def search_glossary(query):
|
267 |
+
all=""
|
268 |
+
st.markdown(f"- {query}")
|
269 |
+
|
270 |
+
# 🔍Run 1 - ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM
|
271 |
+
client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
272 |
+
response2 = client.predict(
|
273 |
+
query, # str in 'parameter_13' Textbox component
|
274 |
+
#"mistralai/Mixtral-8x7B-Instruct-v0.1", # Literal['mistralai/Mixtral-8x7B-Instruct-v0.1', 'mistralai/Mistral-7B-Instruct-v0.2', 'google/gemma-7b-it', 'None'] in 'LLM Model' Dropdown component
|
275 |
+
#"mistralai/Mistral-7B-Instruct-v0.2", # Literal['mistralai/Mixtral-8x7B-Instruct-v0.1', 'mistralai/Mistral-7B-Instruct-v0.2', 'google/gemma-7b-it', 'None'] in 'LLM Model' Dropdown component
|
276 |
+
"google/gemma-7b-it", # Literal['mistralai/Mixtral-8x7B-Instruct-v0.1', 'mistralai/Mistral-7B-Instruct-v0.2', 'google/gemma-7b-it', 'None'] in 'LLM Model' Dropdown component
|
277 |
+
True, # bool in 'Stream output' Checkbox component
|
278 |
+
api_name="/ask_llm"
|
279 |
+
)
|
280 |
+
st.write('🔍Run of Multi-Agent System Paper Summary Spec is Complete')
|
281 |
+
st.markdown(response2)
|
282 |
+
|
283 |
+
# ArXiv searcher ~-<>-~ Paper References - Update with RAG
|
284 |
+
client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
285 |
+
response1 = client.predict(
|
286 |
+
query,
|
287 |
+
10,
|
288 |
+
"Semantic Search - up to 10 Mar 2024", # Literal['Semantic Search - up to 10 Mar 2024', 'Arxiv Search - Latest - (EXPERIMENTAL)'] in 'Search Source' Dropdown component
|
289 |
+
"mistralai/Mixtral-8x7B-Instruct-v0.1", # Literal['mistralai/Mixtral-8x7B-Instruct-v0.1', 'mistralai/Mistral-7B-Instruct-v0.2', 'google/gemma-7b-it', 'None'] in 'LLM Model' Dropdown component
|
290 |
+
api_name="/update_with_rag_md"
|
291 |
+
)
|
292 |
+
st.write('🔍Run of Multi-Agent System Paper References is Complete')
|
293 |
+
responseall = response2 + response1[0] + response1[1]
|
294 |
+
st.markdown(responseall)
|
295 |
+
return responseall
|
296 |
+
|
297 |
+
def display_content_or_image(query):
|
298 |
+
for category, terms in transhuman_glossary.items():
|
299 |
+
for term in terms:
|
300 |
+
if query.lower() in term.lower():
|
301 |
+
st.subheader(f"Found in {category}:")
|
302 |
+
st.write(term)
|
303 |
+
return True # Return after finding and displaying the first match
|
304 |
+
image_dir = "images" # Example directory where images are stored
|
305 |
+
image_path = f"{image_dir}/{query}.png" # Construct image path with query
|
306 |
+
if os.path.exists(image_path):
|
307 |
+
st.image(image_path, caption=f"Image for {query}")
|
308 |
+
return True
|
309 |
+
st.warning("No matching content or image found.")
|
310 |
+
return False
|
311 |
+
|
312 |
+
|
313 |
# 🎈 Let's modify the main app to be more fun!
|
314 |
def main():
|
315 |
st.title("🐙Git🌌Cosmos💫 - Azure Cosmos DB and Github Agent")
|
|
|
332 |
if 'cloned_doc' not in st.session_state:
|
333 |
st.session_state.cloned_doc = None
|
334 |
|
335 |
+
|
336 |
+
# ⚙️q= Run ArXiv search from query parameters
|
337 |
try:
|
338 |
query_params = st.query_params
|
339 |
+
query = (query_params.get('q') or query_params.get('query') or [''])
|
340 |
+
if len(query) > 1:
|
341 |
+
#result = search_arxiv(query)
|
342 |
+
result2 = search_glossary(result)
|
343 |
+
|
344 |
+
filesearch = PromptPrefix + query
|
345 |
+
st.markdown(filesearch)
|
346 |
+
process_text(filesearch)
|
347 |
+
except:
|
348 |
st.markdown(' ')
|
349 |
+
|
350 |
+
if 'action' in st.query_params:
|
351 |
+
action = st.query_params()['action'][0] # Get the first (or only) 'action' parameter
|
352 |
+
if action == 'show_message':
|
353 |
+
st.success("Showing a message because 'action=show_message' was found in the URL.")
|
354 |
+
elif action == 'clear':
|
355 |
+
clear_query_params()
|
356 |
+
#st.rerun()
|
357 |
+
|
358 |
+
if 'query' in st.query_params:
|
359 |
+
query = st.query_params['query'][0] # Get the query parameter
|
360 |
+
# Display content or image based on the query
|
361 |
+
display_content_or_image(query)
|
362 |
+
|
363 |
|
364 |
# 🔐 Automatic Login
|
365 |
if Key:
|