Spaces:
Sleeping
Sleeping
Girish Jeswani commited on
Commit ·
8cd1bc5
1
Parent(s): b6bf0ee
update advisor name
Browse files- README.md +2 -2
- multi_llm_chatbot_backend/app/api/routes.py +2 -2
- multi_llm_chatbot_backend/app/api/routes_old.py +1 -1
- multi_llm_chatbot_backend/app/core/context_manager.py +1 -1
- multi_llm_chatbot_backend/app/core/improved_orchestrator.py +2 -2
- multi_llm_chatbot_backend/app/llm/gemini_client.py +2 -2
- multi_llm_chatbot_backend/app/llm/improved_ollama_client.py +2 -2
- multi_llm_chatbot_backend/app/llm/short_ollama_client.py +2 -2
- multi_llm_chatbot_backend/app/models/default_personas.py +1 -1
- multi_llm_chatbot_backend/app/tests/debug_rag.py +2 -2
- multi_llm_chatbot_backend/app/tests/test_rag_system.py +1 -1
- phd-advisor-frontend/src/data/advisors.js +3 -3
README.md
CHANGED
|
@@ -4,7 +4,7 @@ An AI-powered academic guidance system that provides personalized advice through
|
|
| 4 |
|
| 5 |
## Features
|
| 6 |
|
| 7 |
-
- **Multiple AI Advisor Personas**: Chat with specialized advisors including
|
| 8 |
- **Document Upload Support**: Upload PDFs, Word documents, and text files to provide context for your questions
|
| 9 |
- **Multi-LLM Backend**: Supports both Gemini API and Ollama models with seamless provider switching
|
| 10 |
- **Real-time Chat Interface**: Modern, responsive chat interface with advisor-specific styling
|
|
@@ -83,7 +83,7 @@ The application will open at `http://localhost:3000`
|
|
| 83 |
|
| 84 |
## Advisor Personas
|
| 85 |
|
| 86 |
-
###
|
| 87 |
- **Focus**: Research design, validity, sampling, methodological rigor
|
| 88 |
- **Style**: Precise, analytical, methodology-focused
|
| 89 |
- **Best for**: Research design questions, data collection methods, validity concerns
|
|
|
|
| 4 |
|
| 5 |
## Features
|
| 6 |
|
| 7 |
+
- **Multiple AI Advisor Personas**: Chat with specialized advisors including Methodologist (methodology expert), Theorist (conceptual frameworks), and Pragmatist (action-focused guidance)
|
| 8 |
- **Document Upload Support**: Upload PDFs, Word documents, and text files to provide context for your questions
|
| 9 |
- **Multi-LLM Backend**: Supports both Gemini API and Ollama models with seamless provider switching
|
| 10 |
- **Real-time Chat Interface**: Modern, responsive chat interface with advisor-specific styling
|
|
|
|
| 83 |
|
| 84 |
## Advisor Personas
|
| 85 |
|
| 86 |
+
### Methodologist - Research Methodology Expert
|
| 87 |
- **Focus**: Research design, validity, sampling, methodological rigor
|
| 88 |
- **Style**: Precise, analytical, methodology-focused
|
| 89 |
- **Best for**: Research design questions, data collection methods, validity concerns
|
multi_llm_chatbot_backend/app/api/routes.py
CHANGED
|
@@ -127,7 +127,7 @@ def _is_valid_response(response: str, persona_id: str) -> bool:
|
|
| 127 |
def _get_persona_fallback(persona_id: str) -> str:
|
| 128 |
"""Get persona-specific fallback responses"""
|
| 129 |
fallbacks = {
|
| 130 |
-
"
|
| 131 |
"theorist": "Consider the theoretical framework underlying your approach. What assumptions guide your thinking?",
|
| 132 |
"pragmatist": "Let's break this down into actionable steps. What's the most important thing you need to decide today?"
|
| 133 |
}
|
|
@@ -479,7 +479,7 @@ async def search_documents(request: Request, query: str = Body(..., embed=True),
|
|
| 479 |
|
| 480 |
# Get persona context for search enhancement
|
| 481 |
persona_contexts = {
|
| 482 |
-
"
|
| 483 |
"theorist": "theory theoretical framework conceptual",
|
| 484 |
"pragmatist": "practical application implementation"
|
| 485 |
}
|
|
|
|
| 127 |
def _get_persona_fallback(persona_id: str) -> str:
|
| 128 |
"""Get persona-specific fallback responses"""
|
| 129 |
fallbacks = {
|
| 130 |
+
"methodologist": "Focus on ensuring your methodology aligns with your research question. What specific method are you considering?",
|
| 131 |
"theorist": "Consider the theoretical framework underlying your approach. What assumptions guide your thinking?",
|
| 132 |
"pragmatist": "Let's break this down into actionable steps. What's the most important thing you need to decide today?"
|
| 133 |
}
|
|
|
|
| 479 |
|
| 480 |
# Get persona context for search enhancement
|
| 481 |
persona_contexts = {
|
| 482 |
+
"methodologist": "methodology research design analysis",
|
| 483 |
"theorist": "theory theoretical framework conceptual",
|
| 484 |
"pragmatist": "practical application implementation"
|
| 485 |
}
|
multi_llm_chatbot_backend/app/api/routes_old.py
CHANGED
|
@@ -95,7 +95,7 @@ def _is_valid_response(response: str, persona_id: str) -> bool:
|
|
| 95 |
def _get_persona_fallback(persona_id: str) -> str:
|
| 96 |
"""Get persona-specific fallback responses"""
|
| 97 |
fallbacks = {
|
| 98 |
-
"
|
| 99 |
"theorist": "Consider the theoretical framework underlying your approach. What assumptions guide your thinking?",
|
| 100 |
"pragmatist": "Let's break this down into actionable steps. What's the most important thing you need to decide today?"
|
| 101 |
}
|
|
|
|
| 95 |
def _get_persona_fallback(persona_id: str) -> str:
|
| 96 |
"""Get persona-specific fallback responses"""
|
| 97 |
fallbacks = {
|
| 98 |
+
"methodologist": "Focus on ensuring your methodology aligns with your research question. What specific method are you considering?",
|
| 99 |
"theorist": "Consider the theoretical framework underlying your approach. What assumptions guide your thinking?",
|
| 100 |
"pragmatist": "Let's break this down into actionable steps. What's the most important thing you need to decide today?"
|
| 101 |
}
|
multi_llm_chatbot_backend/app/core/context_manager.py
CHANGED
|
@@ -167,7 +167,7 @@ class ContextManager:
|
|
| 167 |
"role": "user",
|
| 168 |
"parts": [{"text": content}]
|
| 169 |
})
|
| 170 |
-
elif role in ['assistant', '
|
| 171 |
formatted.append({
|
| 172 |
"role": "model",
|
| 173 |
"parts": [{"text": content}]
|
|
|
|
| 167 |
"role": "user",
|
| 168 |
"parts": [{"text": content}]
|
| 169 |
})
|
| 170 |
+
elif role in ['assistant', 'methodologist', 'theorist', 'pragmatist']:
|
| 171 |
formatted.append({
|
| 172 |
"role": "model",
|
| 173 |
"parts": [{"text": content}]
|
multi_llm_chatbot_backend/app/core/improved_orchestrator.py
CHANGED
|
@@ -305,7 +305,7 @@ class ImprovedChatOrchestrator:
|
|
| 305 |
def _get_fallback_response(self, persona_id: str) -> str:
|
| 306 |
"""Get persona-specific fallback response"""
|
| 307 |
fallbacks = {
|
| 308 |
-
"
|
| 309 |
"theorist": "I'd like to explore the theoretical foundation of your work. What conceptual framework guides your research?",
|
| 310 |
"pragmatist": "Let's take a practical approach. What's the most pressing decision you need to make about your research right now?"
|
| 311 |
}
|
|
@@ -345,7 +345,7 @@ class ImprovedChatOrchestrator:
|
|
| 345 |
based on their specialization
|
| 346 |
"""
|
| 347 |
persona_keywords = {
|
| 348 |
-
"
|
| 349 |
"theorist": "theory theoretical framework conceptual model literature review philosophy epistemology ontology paradigm abstract concepts",
|
| 350 |
"pragmatist": "practical application implementation action steps next steps recommendation solution strategy timeline concrete advice"
|
| 351 |
}
|
|
|
|
| 305 |
def _get_fallback_response(self, persona_id: str) -> str:
|
| 306 |
"""Get persona-specific fallback response"""
|
| 307 |
fallbacks = {
|
| 308 |
+
"methodologist": "Let's focus on your research methodology. What specific methodological approach are you considering?",
|
| 309 |
"theorist": "I'd like to explore the theoretical foundation of your work. What conceptual framework guides your research?",
|
| 310 |
"pragmatist": "Let's take a practical approach. What's the most pressing decision you need to make about your research right now?"
|
| 311 |
}
|
|
|
|
| 345 |
based on their specialization
|
| 346 |
"""
|
| 347 |
persona_keywords = {
|
| 348 |
+
"methodologist": "methodology research design analysis methods data collection sampling validity reliability statistical approach quantitative qualitative",
|
| 349 |
"theorist": "theory theoretical framework conceptual model literature review philosophy epistemology ontology paradigm abstract concepts",
|
| 350 |
"pragmatist": "practical application implementation action steps next steps recommendation solution strategy timeline concrete advice"
|
| 351 |
}
|
multi_llm_chatbot_backend/app/llm/gemini_client.py
CHANGED
|
@@ -113,8 +113,8 @@ class GeminiClient(LLMClient):
|
|
| 113 |
"""Clean up Gemini responses"""
|
| 114 |
# Remove common prefixes that indicate AI confusion
|
| 115 |
prefixes_to_remove = [
|
| 116 |
-
"Dr.
|
| 117 |
-
"
|
| 118 |
"As Dr.", "Here's my response:", "Response:", "Assistant:",
|
| 119 |
"Here are 2-3 sentence", "Here's an expansion of the advice:",
|
| 120 |
]
|
|
|
|
| 113 |
"""Clean up Gemini responses"""
|
| 114 |
# Remove common prefixes that indicate AI confusion
|
| 115 |
prefixes_to_remove = [
|
| 116 |
+
"Dr. Methodologist:", "Dr. Theorist:", "Dr. Pragmatist:",
|
| 117 |
+
"Methodologist Advisor:", "Theorist Advisor:", "Pragmatist Advisor:",
|
| 118 |
"As Dr.", "Here's my response:", "Response:", "Assistant:",
|
| 119 |
"Here are 2-3 sentence", "Here's an expansion of the advice:",
|
| 120 |
]
|
multi_llm_chatbot_backend/app/llm/improved_ollama_client.py
CHANGED
|
@@ -71,8 +71,8 @@ class ImprovedOllamaClient(LLMClient):
|
|
| 71 |
# Remove common prefixes that indicate AI confusion
|
| 72 |
prefixes_to_remove = [
|
| 73 |
"Here are 2-3 sentence", "Here's an expansion", "Assistant:",
|
| 74 |
-
"Dr.
|
| 75 |
-
"
|
| 76 |
]
|
| 77 |
|
| 78 |
for prefix in prefixes_to_remove:
|
|
|
|
| 71 |
# Remove common prefixes that indicate AI confusion
|
| 72 |
prefixes_to_remove = [
|
| 73 |
"Here are 2-3 sentence", "Here's an expansion", "Assistant:",
|
| 74 |
+
"Dr. Methodologist:", "Dr. Theorist:", "Dr. Pragmatist:",
|
| 75 |
+
"Methodologist Advisor:", "Theorist Advisor:", "Pragmatist Advisor:",
|
| 76 |
]
|
| 77 |
|
| 78 |
for prefix in prefixes_to_remove:
|
multi_llm_chatbot_backend/app/llm/short_ollama_client.py
CHANGED
|
@@ -62,8 +62,8 @@ class ShortResponseOllamaClient(LLMClient):
|
|
| 62 |
# Remove common prefixes
|
| 63 |
prefixes_to_remove = [
|
| 64 |
"Here are 2-3 sentence", "Here's an expansion", "Assistant:",
|
| 65 |
-
"Dr.
|
| 66 |
-
"
|
| 67 |
]
|
| 68 |
|
| 69 |
for prefix in prefixes_to_remove:
|
|
|
|
| 62 |
# Remove common prefixes
|
| 63 |
prefixes_to_remove = [
|
| 64 |
"Here are 2-3 sentence", "Here's an expansion", "Assistant:",
|
| 65 |
+
"Dr. Methodologist:", "Dr. Theorist:", "Dr. Pragmatist:",
|
| 66 |
+
"Methodologist Advisor:", "Theorist Advisor:", "Pragmatist Advisor:",
|
| 67 |
]
|
| 68 |
|
| 69 |
for prefix in prefixes_to_remove:
|
multi_llm_chatbot_backend/app/models/default_personas.py
CHANGED
|
@@ -2,7 +2,7 @@ from app.models.persona import Persona
|
|
| 2 |
|
| 3 |
# Registry of default personas
|
| 4 |
DEFAULT_PERSONAS = {
|
| 5 |
-
"
|
| 6 |
"name": "Methodical Advisor",
|
| 7 |
"system_prompt": "You are a highly methodical PhD advisor. Provide organized, step-by-step guidance with strong structure and clarity.",
|
| 8 |
"default_temperature": 5
|
|
|
|
| 2 |
|
| 3 |
# Registry of default personas
|
| 4 |
DEFAULT_PERSONAS = {
|
| 5 |
+
"methodologist": {
|
| 6 |
"name": "Methodical Advisor",
|
| 7 |
"system_prompt": "You are a highly methodical PhD advisor. Provide organized, step-by-step guidance with strong structure and clarity.",
|
| 8 |
"default_temperature": 5
|
multi_llm_chatbot_backend/app/tests/debug_rag.py
CHANGED
|
@@ -16,7 +16,7 @@ def test_direct_search():
|
|
| 16 |
print("🔍 Testing direct document search...")
|
| 17 |
|
| 18 |
test_queries = [
|
| 19 |
-
{"query": "research methodology approach", "persona": "
|
| 20 |
{"query": "theoretical framework theory", "persona": "theorist"},
|
| 21 |
{"query": "practical steps implementation", "persona": "pragmatist"}
|
| 22 |
]
|
|
@@ -55,7 +55,7 @@ def test_single_persona_chat():
|
|
| 55 |
"""Test individual persona chat to isolate issues"""
|
| 56 |
print("\n💬 Testing individual persona chat...")
|
| 57 |
|
| 58 |
-
personas = ["
|
| 59 |
query = "What research methodology should I use based on the uploaded document?"
|
| 60 |
|
| 61 |
for persona in personas:
|
|
|
|
| 16 |
print("🔍 Testing direct document search...")
|
| 17 |
|
| 18 |
test_queries = [
|
| 19 |
+
{"query": "research methodology approach", "persona": "methodologist"},
|
| 20 |
{"query": "theoretical framework theory", "persona": "theorist"},
|
| 21 |
{"query": "practical steps implementation", "persona": "pragmatist"}
|
| 22 |
]
|
|
|
|
| 55 |
"""Test individual persona chat to isolate issues"""
|
| 56 |
print("\n💬 Testing individual persona chat...")
|
| 57 |
|
| 58 |
+
personas = ["methodologist", "theorist", "pragmatist"]
|
| 59 |
query = "What research methodology should I use based on the uploaded document?"
|
| 60 |
|
| 61 |
for persona in personas:
|
multi_llm_chatbot_backend/app/tests/test_rag_system.py
CHANGED
|
@@ -65,7 +65,7 @@ def test_rag_system():
|
|
| 65 |
print("🔍 Test 3: Testing direct document search...")
|
| 66 |
|
| 67 |
search_queries = [
|
| 68 |
-
{"query": "What methodology should I use?", "persona": "
|
| 69 |
{"query": "What is the theoretical framework?", "persona": "theorist"},
|
| 70 |
{"query": "What are the next steps?", "persona": "pragmatist"}
|
| 71 |
]
|
|
|
|
| 65 |
print("🔍 Test 3: Testing direct document search...")
|
| 66 |
|
| 67 |
search_queries = [
|
| 68 |
+
{"query": "What methodology should I use?", "persona": "methodologist"},
|
| 69 |
{"query": "What is the theoretical framework?", "persona": "theorist"},
|
| 70 |
{"query": "What are the next steps?", "persona": "pragmatist"}
|
| 71 |
]
|
phd-advisor-frontend/src/data/advisors.js
CHANGED
|
@@ -1,8 +1,8 @@
|
|
| 1 |
import { BookOpen, Target, Brain } from 'lucide-react';
|
| 2 |
|
| 3 |
export const advisors = {
|
| 4 |
-
|
| 5 |
-
name: '
|
| 6 |
role: 'Methodical Advisor',
|
| 7 |
// Light theme colors
|
| 8 |
color: '#3B82F6',
|
|
@@ -53,7 +53,7 @@ export const getAdvisorColors = (advisorId, isDark = false) => {
|
|
| 53 |
// For text that needs to be readable on colored backgrounds
|
| 54 |
textColor: isDark ? '#F9FAFB' :
|
| 55 |
advisor.color === '#10B981' ? '#047857' : // Darker green for pragmatist
|
| 56 |
-
advisor.color === '#3B82F6' ? '#1D4ED8' : // Darker blue for
|
| 57 |
advisor.color === '#8B5CF6' ? '#7C3AED' : // Darker purple for theorist
|
| 58 |
'#374151' // fallback
|
| 59 |
};
|
|
|
|
| 1 |
import { BookOpen, Target, Brain } from 'lucide-react';
|
| 2 |
|
| 3 |
export const advisors = {
|
| 4 |
+
methodologist: {
|
| 5 |
+
name: 'Methodologist',
|
| 6 |
role: 'Methodical Advisor',
|
| 7 |
// Light theme colors
|
| 8 |
color: '#3B82F6',
|
|
|
|
| 53 |
// For text that needs to be readable on colored backgrounds
|
| 54 |
textColor: isDark ? '#F9FAFB' :
|
| 55 |
advisor.color === '#10B981' ? '#047857' : // Darker green for pragmatist
|
| 56 |
+
advisor.color === '#3B82F6' ? '#1D4ED8' : // Darker blue for methodologist
|
| 57 |
advisor.color === '#8B5CF6' ? '#7C3AED' : // Darker purple for theorist
|
| 58 |
'#374151' // fallback
|
| 59 |
};
|