Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,12 +19,15 @@ logger = logging.getLogger(__name__)
|
|
| 19 |
|
| 20 |
CSV_FILE = "repo_ids.csv"
|
| 21 |
CHATBOT_SYSTEM_PROMPT = (
|
| 22 |
-
"You are a helpful assistant
|
| 23 |
-
"
|
| 24 |
-
"
|
| 25 |
-
"
|
|
|
|
|
|
|
|
|
|
| 26 |
)
|
| 27 |
-
CHATBOT_INITIAL_MESSAGE = "Hello!
|
| 28 |
|
| 29 |
# --- Helper Functions (Logic) ---
|
| 30 |
|
|
@@ -427,6 +430,53 @@ def create_ui() -> gr.Blocks:
|
|
| 427 |
.gr-dataframe tbody tr:hover {
|
| 428 |
background-color: rgba(102, 126, 234, 0.05);
|
| 429 |
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 430 |
"""
|
| 431 |
|
| 432 |
with gr.Blocks(
|
|
@@ -569,7 +619,7 @@ def create_ui() -> gr.Blocks:
|
|
| 569 |
df_output = gr.Dataframe(
|
| 570 |
headers=["Repository", "Strengths", "Weaknesses", "Speciality", "Relevance"],
|
| 571 |
wrap=True,
|
| 572 |
-
interactive=False
|
| 573 |
)
|
| 574 |
|
| 575 |
# --- Chatbot Tab ---
|
|
|
|
| 19 |
|
| 20 |
CSV_FILE = "repo_ids.csv"
|
| 21 |
CHATBOT_SYSTEM_PROMPT = (
|
| 22 |
+
"You are a helpful assistant whose ONLY job is to gather information about the user's ideal repository requirements. "
|
| 23 |
+
"DO NOT suggest any specific repositories or give repository recommendations. "
|
| 24 |
+
"Your role is to ask clarifying questions to understand exactly what the user is looking for. "
|
| 25 |
+
"Ask about their use case, preferred programming language, specific features needed, project type, etc. "
|
| 26 |
+
"When you feel you have gathered enough detailed information about their requirements, "
|
| 27 |
+
"tell the user: 'I think I have enough information about your requirements. Please click the Extract Keywords button to search for repositories.' "
|
| 28 |
+
"Focus on understanding their needs, not providing solutions."
|
| 29 |
)
|
| 30 |
+
CHATBOT_INITIAL_MESSAGE = "Hello! I'm here to help you define your ideal Hugging Face repository requirements. I won't suggest specific repos - my job is to understand exactly what you're looking for. Tell me about your project: What type of application are you building? What's your use case?"
|
| 31 |
|
| 32 |
# --- Helper Functions (Logic) ---
|
| 33 |
|
|
|
|
| 430 |
.gr-dataframe tbody tr:hover {
|
| 431 |
background-color: rgba(102, 126, 234, 0.05);
|
| 432 |
}
|
| 433 |
+
|
| 434 |
+
/* JavaScript for auto-scroll to top on tab change */
|
| 435 |
+
<script>
|
| 436 |
+
document.addEventListener('DOMContentLoaded', function() {
|
| 437 |
+
// Function to scroll to top
|
| 438 |
+
function scrollToTop() {
|
| 439 |
+
window.scrollTo({
|
| 440 |
+
top: 0,
|
| 441 |
+
behavior: 'smooth'
|
| 442 |
+
});
|
| 443 |
+
}
|
| 444 |
+
|
| 445 |
+
// Observer for tab changes
|
| 446 |
+
const observer = new MutationObserver(function(mutations) {
|
| 447 |
+
mutations.forEach(function(mutation) {
|
| 448 |
+
if (mutation.type === 'attributes' && mutation.attributeName === 'class') {
|
| 449 |
+
const target = mutation.target;
|
| 450 |
+
if (target.classList && target.classList.contains('selected')) {
|
| 451 |
+
// Tab was selected, scroll to top
|
| 452 |
+
setTimeout(scrollToTop, 100);
|
| 453 |
+
}
|
| 454 |
+
}
|
| 455 |
+
});
|
| 456 |
+
});
|
| 457 |
+
|
| 458 |
+
// Observe tab navigation buttons
|
| 459 |
+
const tabButtons = document.querySelectorAll('.gr-tab-nav button');
|
| 460 |
+
tabButtons.forEach(button => {
|
| 461 |
+
observer.observe(button, { attributes: true });
|
| 462 |
+
|
| 463 |
+
// Also add click listener for immediate scroll
|
| 464 |
+
button.addEventListener('click', function() {
|
| 465 |
+
setTimeout(scrollToTop, 150);
|
| 466 |
+
});
|
| 467 |
+
});
|
| 468 |
+
|
| 469 |
+
// Listen for programmatic tab changes (button-triggered navigation)
|
| 470 |
+
let lastSelectedTab = null;
|
| 471 |
+
setInterval(function() {
|
| 472 |
+
const currentSelectedTab = document.querySelector('.gr-tab-nav button.selected');
|
| 473 |
+
if (currentSelectedTab && currentSelectedTab !== lastSelectedTab) {
|
| 474 |
+
lastSelectedTab = currentSelectedTab;
|
| 475 |
+
scrollToTop();
|
| 476 |
+
}
|
| 477 |
+
}, 200);
|
| 478 |
+
});
|
| 479 |
+
</script>
|
| 480 |
"""
|
| 481 |
|
| 482 |
with gr.Blocks(
|
|
|
|
| 619 |
df_output = gr.Dataframe(
|
| 620 |
headers=["Repository", "Strengths", "Weaknesses", "Speciality", "Relevance"],
|
| 621 |
wrap=True,
|
| 622 |
+
interactive=False
|
| 623 |
)
|
| 624 |
|
| 625 |
# --- Chatbot Tab ---
|