Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -297,11 +297,19 @@ css = """
|
|
297 |
}
|
298 |
"""
|
299 |
|
300 |
-
# Create the main chat interface -
|
301 |
-
|
302 |
-
fn=chat_interface,
|
303 |
title="π€ RAGtim Bot - Markdown Knowledge Base",
|
304 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
305 |
**Complete Markdown Knowledge Base**: This Hugging Face Space loads all markdown files from Raktim Mondol's portfolio with **{len(bot.knowledge_base)} knowledge sections**.
|
306 |
|
307 |
**Loaded Markdown Files:**
|
@@ -333,66 +341,99 @@ iface = gr.ChatInterface(
|
|
333 |
- Contact information and collaboration opportunities
|
334 |
|
335 |
**Note**: This demo shows search results from the complete markdown knowledge base. In hybrid mode, these results are passed to DeepSeek LLM for natural response generation.
|
336 |
-
"""
|
337 |
-
|
338 |
-
|
339 |
-
"Tell me about BioFusionNet in detail",
|
340 |
-
"What are his LLM and RAG expertise?",
|
341 |
-
"Describe his statistical methods and biostatistics work",
|
342 |
-
"What programming languages and frameworks does he use?",
|
343 |
-
"Tell me about his educational background",
|
344 |
-
"What is his current position at UNSW?",
|
345 |
-
"How can I contact Raktim for collaboration?",
|
346 |
-
"What awards and recognition has he received?",
|
347 |
-
"Explain his multimodal AI research",
|
348 |
-
"What is hist2RNA and its impact?",
|
349 |
-
"Tell me about his teaching experience"
|
350 |
-
],
|
351 |
-
css=css,
|
352 |
-
theme=gr.themes.Soft(
|
353 |
-
primary_hue="green",
|
354 |
-
secondary_hue="blue",
|
355 |
-
neutral_hue="slate"
|
356 |
-
),
|
357 |
-
# FIXED: Use type='messages' and remove deprecated parameters
|
358 |
-
type='messages',
|
359 |
-
chatbot=gr.Chatbot(
|
360 |
height=600,
|
361 |
show_label=False,
|
362 |
-
container=True
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
372 |
|
373 |
# Create API interface for search-only functionality
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
384 |
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
392 |
|
393 |
-
# Combine interfaces
|
394 |
demo = gr.TabbedInterface(
|
395 |
-
[
|
396 |
["π¬ Markdown Chat", "π Search API", "π Stats API"],
|
397 |
title="π€ RAGtim Bot - Complete Markdown Knowledge Base"
|
398 |
)
|
|
|
297 |
}
|
298 |
"""
|
299 |
|
300 |
+
# Create the main chat interface - UPDATED FOR GRADIO 5.34.0
|
301 |
+
with gr.Blocks(
|
|
|
302 |
title="π€ RAGtim Bot - Markdown Knowledge Base",
|
303 |
+
css=css,
|
304 |
+
theme=gr.themes.Soft(
|
305 |
+
primary_hue="green",
|
306 |
+
secondary_hue="blue",
|
307 |
+
neutral_hue="slate"
|
308 |
+
)
|
309 |
+
) as chat_demo:
|
310 |
+
gr.Markdown(f"""
|
311 |
+
# π€ RAGtim Bot - Markdown Knowledge Base
|
312 |
+
|
313 |
**Complete Markdown Knowledge Base**: This Hugging Face Space loads all markdown files from Raktim Mondol's portfolio with **{len(bot.knowledge_base)} knowledge sections**.
|
314 |
|
315 |
**Loaded Markdown Files:**
|
|
|
341 |
- Contact information and collaboration opportunities
|
342 |
|
343 |
**Note**: This demo shows search results from the complete markdown knowledge base. In hybrid mode, these results are passed to DeepSeek LLM for natural response generation.
|
344 |
+
""")
|
345 |
+
|
346 |
+
chatbot = gr.Chatbot(
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
347 |
height=600,
|
348 |
show_label=False,
|
349 |
+
container=True,
|
350 |
+
type="messages"
|
351 |
+
)
|
352 |
+
|
353 |
+
with gr.Row():
|
354 |
+
msg = gr.Textbox(
|
355 |
+
placeholder="Ask me anything about Raktim Mondol's research, skills, experience, publications...",
|
356 |
+
container=False,
|
357 |
+
scale=7,
|
358 |
+
show_label=False
|
359 |
+
)
|
360 |
+
submit_btn = gr.Button("Search Knowledge Base", scale=1)
|
361 |
+
|
362 |
+
# Example buttons
|
363 |
+
with gr.Row():
|
364 |
+
examples = [
|
365 |
+
"What is Raktim's research about?",
|
366 |
+
"Tell me about BioFusionNet in detail",
|
367 |
+
"What are his LLM and RAG expertise?",
|
368 |
+
"Describe his statistical methods and biostatistics work"
|
369 |
+
]
|
370 |
+
for example in examples:
|
371 |
+
gr.Button(example, size="sm").click(
|
372 |
+
lambda x=example: x, outputs=msg
|
373 |
+
)
|
374 |
+
|
375 |
+
def respond(message, history):
|
376 |
+
if not message.strip():
|
377 |
+
return history, ""
|
378 |
+
|
379 |
+
# Add user message to history
|
380 |
+
history.append({"role": "user", "content": message})
|
381 |
+
|
382 |
+
# Get bot response
|
383 |
+
bot_response = chat_interface(message, history)
|
384 |
+
|
385 |
+
# Add bot response to history
|
386 |
+
history.append({"role": "assistant", "content": bot_response})
|
387 |
+
|
388 |
+
return history, ""
|
389 |
+
|
390 |
+
submit_btn.click(respond, [msg, chatbot], [chatbot, msg])
|
391 |
+
msg.submit(respond, [msg, chatbot], [chatbot, msg])
|
392 |
|
393 |
# Create API interface for search-only functionality
|
394 |
+
with gr.Blocks(title="π Search API") as search_demo:
|
395 |
+
gr.Markdown("# π Markdown Knowledge Base Search API")
|
396 |
+
gr.Markdown("Direct access to semantic search across all loaded markdown files")
|
397 |
+
|
398 |
+
with gr.Row():
|
399 |
+
search_input = gr.Textbox(
|
400 |
+
label="Search Query",
|
401 |
+
placeholder="Enter your search query about Raktim Mondol..."
|
402 |
+
)
|
403 |
+
top_k_slider = gr.Slider(
|
404 |
+
minimum=1,
|
405 |
+
maximum=15,
|
406 |
+
value=5,
|
407 |
+
step=1,
|
408 |
+
label="Top K Results"
|
409 |
+
)
|
410 |
+
|
411 |
+
search_output = gr.JSON(label="Markdown Knowledge Base Search Results")
|
412 |
+
search_btn = gr.Button("Search")
|
413 |
+
|
414 |
+
search_btn.click(
|
415 |
+
search_only_api,
|
416 |
+
inputs=[search_input, top_k_slider],
|
417 |
+
outputs=search_output
|
418 |
+
)
|
419 |
|
420 |
+
# Create stats interface
|
421 |
+
with gr.Blocks(title="π Stats API") as stats_demo:
|
422 |
+
gr.Markdown("# π Knowledge Base Stats")
|
423 |
+
gr.Markdown("Detailed statistics about the loaded markdown knowledge base")
|
424 |
+
|
425 |
+
stats_output = gr.JSON(label="Markdown Knowledge Base Statistics")
|
426 |
+
stats_btn = gr.Button("Get Statistics")
|
427 |
+
|
428 |
+
stats_btn.click(
|
429 |
+
get_stats_api,
|
430 |
+
inputs=[],
|
431 |
+
outputs=stats_output
|
432 |
+
)
|
433 |
|
434 |
+
# Combine interfaces using TabbedInterface
|
435 |
demo = gr.TabbedInterface(
|
436 |
+
[chat_demo, search_demo, stats_demo],
|
437 |
["π¬ Markdown Chat", "π Search API", "π Stats API"],
|
438 |
title="π€ RAGtim Bot - Complete Markdown Knowledge Base"
|
439 |
)
|