awacke1 commited on
Commit
8ee509b
Β·
verified Β·
1 Parent(s): 0b98b49

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +80 -80
app.py CHANGED
@@ -228,92 +228,92 @@ def search_glossary(query):
228
 
229
 
230
  # Run Button with Emoji
231
- if st.button("πŸš€ Run"):
232
-
233
- # πŸ•΅οΈβ€β™‚οΈ Searching the glossary for: query
234
- all_results = ""
235
- st.markdown(f"- {query}")
236
-
237
- # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM
238
- #database_choice Literal['Semantic Search', 'Arxiv Search - Latest - (EXPERIMENTAL)'] Default: "Semantic Search"
239
- #llm_model_picked Literal['mistralai/Mixtral-8x7B-Instruct-v0.1', 'mistralai/Mistral-7B-Instruct-v0.2', 'google/gemma-7b-it', 'None'] Default: "mistralai/Mistral-7B-Instruct-v0.2"
240
- client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
241
-
242
-
243
- # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
244
- result = client.predict(
245
- prompt=query,
246
- llm_model_picked="mistralai/Mixtral-8x7B-Instruct-v0.1",
247
- stream_outputs=True,
248
- api_name="/ask_llm"
249
- )
250
- st.markdown(result)
251
- st.code(result, language="python", line_numbers=True)
252
-
253
- # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
254
- result2 = client.predict(
255
- prompt=query,
256
- llm_model_picked="mistralai/Mistral-7B-Instruct-v0.2",
257
- stream_outputs=True,
258
- api_name="/ask_llm"
259
- )
260
- st.markdown(result2)
261
- st.code(result2, language="python", line_numbers=True)
262
-
263
- # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
264
- result3 = client.predict(
265
- prompt=query,
266
- llm_model_picked="google/gemma-7b-it",
267
- stream_outputs=True,
268
- api_name="/ask_llm"
269
- )
270
- st.markdown(result3)
271
- st.code(result3, language="python", line_numbers=True)
272
 
273
-
274
- # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /update_with_rag_md
275
- response2 = client.predict(
276
- message=query, # str in 'parameter_13' Textbox component
277
- llm_results_use=10,
278
- database_choice="Semantic Search",
279
- llm_model_picked="mistralai/Mistral-7B-Instruct-v0.2",
280
- api_name="/update_with_rag_md"
281
- ) # update_with_rag_md Returns tuple of 2 elements [0] str The output value that appears in the "value_14" Markdown component. [1] str
282
-
283
- st.markdown(response2[0])
284
- st.code(response2[0], language="python", line_numbers=True, wrap_lines=True)
285
-
286
- st.markdown(response2[1])
287
- st.code(response2[1], language="python", line_numbers=True, wrap_lines=True)
288
 
289
- # When saving results, pass the container
290
- try:
291
- save_to_cosmos_db(st.session_state.cosmos_container, query, result, result)
292
- save_to_cosmos_db(st.session_state.cosmos_container, query, result2, result2)
293
- save_to_cosmos_db(st.session_state.cosmos_container, query, result3, result3)
294
- save_to_cosmos_db(st.session_state.cosmos_container, query, response2[0], response2[0])
295
- save_to_cosmos_db(st.session_state.cosmos_container, query, response2[1], response2[1])
296
- except exceptions.CosmosHttpResponseError as e:
297
- return False, f"HTTP error occurred: {str(e)} 🚨"
298
- except Exception as e:
299
- return False, f"An unexpected error occurred: {str(e)} 😱"
300
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
301
 
302
- try:
303
- # Aggregate hyperlinks and show with emojis
304
- hyperlinks = extract_hyperlinks([response1, response2])
305
- st.markdown("### πŸ”— Aggregated Hyperlinks")
306
- for link in hyperlinks:
307
- st.markdown(f"πŸ”— [{link}]({link})")
308
 
309
- # Show responses in a code format with line numbers
310
- st.markdown("### πŸ“œ Response Outputs with Line Numbers")
311
- st.code(f"Response 1: \n{format_with_line_numbers(response1)}\n\nResponse 2: \n{format_with_line_numbers(response2)}", language="json")
312
- except exceptions.CosmosHttpResponseError as e:
313
- return False, f"HTTP error occurred: {str(e)} 🚨"
314
- except Exception as e:
315
- return False, f"An unexpected error occurred: {str(e)} 😱"
 
 
 
 
316
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
317
 
318
 
319
 
 
228
 
229
 
230
  # Run Button with Emoji
231
+ #if st.button("πŸš€ Run"):
232
+
233
+ # πŸ•΅οΈβ€β™‚οΈ Searching the glossary for: query
234
+ all_results = ""
235
+ st.markdown(f"- {query}")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
236
 
237
+ # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM
238
+ #database_choice Literal['Semantic Search', 'Arxiv Search - Latest - (EXPERIMENTAL)'] Default: "Semantic Search"
239
+ #llm_model_picked Literal['mistralai/Mixtral-8x7B-Instruct-v0.1', 'mistralai/Mistral-7B-Instruct-v0.2', 'google/gemma-7b-it', 'None'] Default: "mistralai/Mistral-7B-Instruct-v0.2"
240
+ client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
 
 
 
 
 
 
 
 
 
 
 
241
 
 
 
 
 
 
 
 
 
 
 
 
242
 
243
+ # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
244
+ result = client.predict(
245
+ prompt=query,
246
+ llm_model_picked="mistralai/Mixtral-8x7B-Instruct-v0.1",
247
+ stream_outputs=True,
248
+ api_name="/ask_llm"
249
+ )
250
+ st.markdown(result)
251
+ st.code(result, language="python", line_numbers=True)
252
+
253
+ # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
254
+ result2 = client.predict(
255
+ prompt=query,
256
+ llm_model_picked="mistralai/Mistral-7B-Instruct-v0.2",
257
+ stream_outputs=True,
258
+ api_name="/ask_llm"
259
+ )
260
+ st.markdown(result2)
261
+ st.code(result2, language="python", line_numbers=True)
262
+
263
+ # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
264
+ result3 = client.predict(
265
+ prompt=query,
266
+ llm_model_picked="google/gemma-7b-it",
267
+ stream_outputs=True,
268
+ api_name="/ask_llm"
269
+ )
270
+ st.markdown(result3)
271
+ st.code(result3, language="python", line_numbers=True)
272
 
 
 
 
 
 
 
273
 
274
+ # πŸ” ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /update_with_rag_md
275
+ response2 = client.predict(
276
+ message=query, # str in 'parameter_13' Textbox component
277
+ llm_results_use=10,
278
+ database_choice="Semantic Search",
279
+ llm_model_picked="mistralai/Mistral-7B-Instruct-v0.2",
280
+ api_name="/update_with_rag_md"
281
+ ) # update_with_rag_md Returns tuple of 2 elements [0] str The output value that appears in the "value_14" Markdown component. [1] str
282
+
283
+ st.markdown(response2[0])
284
+ st.code(response2[0], language="python", line_numbers=True, wrap_lines=True)
285
 
286
+ st.markdown(response2[1])
287
+ st.code(response2[1], language="python", line_numbers=True, wrap_lines=True)
288
+
289
+ # When saving results, pass the container
290
+ try:
291
+ save_to_cosmos_db(st.session_state.cosmos_container, query, result, result)
292
+ save_to_cosmos_db(st.session_state.cosmos_container, query, result2, result2)
293
+ save_to_cosmos_db(st.session_state.cosmos_container, query, result3, result3)
294
+ save_to_cosmos_db(st.session_state.cosmos_container, query, response2[0], response2[0])
295
+ save_to_cosmos_db(st.session_state.cosmos_container, query, response2[1], response2[1])
296
+ except exceptions.CosmosHttpResponseError as e:
297
+ return False, f"HTTP error occurred: {str(e)} 🚨"
298
+ except Exception as e:
299
+ return False, f"An unexpected error occurred: {str(e)} 😱"
300
+
301
+
302
+ try:
303
+ # Aggregate hyperlinks and show with emojis
304
+ hyperlinks = extract_hyperlinks([response1, response2])
305
+ st.markdown("### πŸ”— Aggregated Hyperlinks")
306
+ for link in hyperlinks:
307
+ st.markdown(f"πŸ”— [{link}]({link})")
308
+
309
+ # Show responses in a code format with line numbers
310
+ st.markdown("### πŸ“œ Response Outputs with Line Numbers")
311
+ st.code(f"Response 1: \n{format_with_line_numbers(response1)}\n\nResponse 2: \n{format_with_line_numbers(response2)}", language="json")
312
+ except exceptions.CosmosHttpResponseError as e:
313
+ return False, f"HTTP error occurred: {str(e)} 🚨"
314
+ except Exception as e:
315
+ return False, f"An unexpected error occurred: {str(e)} 😱"
316
+
317
 
318
 
319