Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -196,9 +196,9 @@ def save_to_cosmos_db(query, response1, response2):
|
|
196 |
else:
|
197 |
st.error("Cosmos DB is not initialized.")
|
198 |
|
199 |
-
|
|
|
200 |
def search_glossary(query):
|
201 |
-
# π Searching the glossaryβuncovering secrets of the universe! π΅οΈββοΈ
|
202 |
st.markdown(f"### π Search Glossary for: `{query}`")
|
203 |
|
204 |
# Dropdown for model selection
|
@@ -209,12 +209,85 @@ def search_glossary(query):
|
|
209 |
database_options = ['Semantic Search', 'Arxiv Search - Latest - (EXPERIMENTAL)']
|
210 |
database_choice = st.selectbox('π Select Database', options=database_options, index=0)
|
211 |
|
|
|
|
|
212 |
# Run Button with Emoji
|
213 |
if st.button("π Run"):
|
214 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
215 |
client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
216 |
|
217 |
-
#
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
218 |
|
219 |
# π€ Function to process text input
|
220 |
def process_text(text_input):
|
|
|
196 |
else:
|
197 |
st.error("Cosmos DB is not initialized.")
|
198 |
|
199 |
+
|
200 |
+
# Add dropdowns for model and database choices
|
201 |
def search_glossary(query):
|
|
|
202 |
st.markdown(f"### π Search Glossary for: `{query}`")
|
203 |
|
204 |
# Dropdown for model selection
|
|
|
209 |
database_options = ['Semantic Search', 'Arxiv Search - Latest - (EXPERIMENTAL)']
|
210 |
database_choice = st.selectbox('π Select Database', options=database_options, index=0)
|
211 |
|
212 |
+
|
213 |
+
|
214 |
# Run Button with Emoji
|
215 |
if st.button("π Run"):
|
216 |
+
|
217 |
+
# π΅οΈββοΈ Searching the glossary for: query
|
218 |
+
all_results = ""
|
219 |
+
st.markdown(f"- {query}")
|
220 |
+
|
221 |
+
# π ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM
|
222 |
+
#database_choice Literal['Semantic Search', 'Arxiv Search - Latest - (EXPERIMENTAL)'] Default: "Semantic Search"
|
223 |
+
#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"
|
224 |
client = Client("awacke1/Arxiv-Paper-Search-And-QA-RAG-Pattern")
|
225 |
+
|
226 |
+
|
227 |
+
# π ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
|
228 |
+
result = client.predict(
|
229 |
+
prompt=query,
|
230 |
+
llm_model_picked="mistralai/Mixtral-8x7B-Instruct-v0.1",
|
231 |
+
stream_outputs=True,
|
232 |
+
api_name="/ask_llm"
|
233 |
+
)
|
234 |
+
st.markdown(result)
|
235 |
+
st.code(result, language="python", line_numbers=True)
|
236 |
+
save_to_cosmos_db(query, result, result) # Save both responses to Cosmos DB
|
237 |
+
|
238 |
+
# π ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
|
239 |
+
result2 = client.predict(
|
240 |
+
prompt=query,
|
241 |
+
llm_model_picked="mistralai/Mistral-7B-Instruct-v0.2",
|
242 |
+
stream_outputs=True,
|
243 |
+
api_name="/ask_llm"
|
244 |
+
)
|
245 |
+
st.markdown(result2)
|
246 |
+
st.code(result2, language="python", line_numbers=True)
|
247 |
+
save_to_cosmos_db(query, result2, result2) # Save both responses to Cosmos DB
|
248 |
+
|
249 |
+
# π ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /ask_llm
|
250 |
+
result3 = client.predict(
|
251 |
+
prompt=query,
|
252 |
+
llm_model_picked="google/gemma-7b-it",
|
253 |
+
stream_outputs=True,
|
254 |
+
api_name="/ask_llm"
|
255 |
+
)
|
256 |
+
st.markdown(result3)
|
257 |
+
st.code(result3, language="python", line_numbers=True)
|
258 |
+
save_to_cosmos_db(query, result3, result3) # Save both responses to Cosmos DB
|
259 |
+
|
260 |
+
|
261 |
+
# π ArXiv RAG researcher expert ~-<>-~ Paper Summary & Ask LLM - api_name: /update_with_rag_md
|
262 |
+
response2 = client.predict(
|
263 |
+
message=query, # str in 'parameter_13' Textbox component
|
264 |
+
llm_results_use=10,
|
265 |
+
database_choice="Semantic Search",
|
266 |
+
llm_model_picked="mistralai/Mistral-7B-Instruct-v0.2",
|
267 |
+
api_name="/update_with_rag_md"
|
268 |
+
) # update_with_rag_md Returns tuple of 2 elements [0] str The output value that appears in the "value_14" Markdown component. [1] str
|
269 |
+
|
270 |
+
st.markdown(response2[0])
|
271 |
+
st.code(response2[0], language="python", line_numbers=True, wrap_lines=True)
|
272 |
+
save_to_cosmos_db(query, response2[0], response2[0]) # Save both responses to Cosmos DB
|
273 |
+
|
274 |
+
st.markdown(response2[1])
|
275 |
+
st.code(response2[1], language="python", line_numbers=True, wrap_lines=True)
|
276 |
+
save_to_cosmos_db(query, response2[1], response2[1]) # Save both responses to Cosmos DB
|
277 |
+
|
278 |
|
279 |
+
# Aggregate hyperlinks and show with emojis
|
280 |
+
hyperlinks = extract_hyperlinks([response1, response2])
|
281 |
+
st.markdown("### π Aggregated Hyperlinks")
|
282 |
+
for link in hyperlinks:
|
283 |
+
st.markdown(f"π [{link}]({link})")
|
284 |
+
|
285 |
+
# Show responses in a code format with line numbers
|
286 |
+
st.markdown("### π Response Outputs with Line Numbers")
|
287 |
+
st.code(f"Response 1: \n{format_with_line_numbers(response1)}\n\nResponse 2: \n{format_with_line_numbers(response2)}", language="json")
|
288 |
+
|
289 |
+
|
290 |
+
|
291 |
|
292 |
# π€ Function to process text input
|
293 |
def process_text(text_input):
|