Spaces:
Running
A newer version of the Gradio SDK is available:
6.3.0
Domain-Specific System Prompts in meeTARA
Current Architecture
1. Model Level (Core) - System Prompt
Location: core/meetara_lab_core.py β _get_system_prompt()
Config: config/agent_config.json β model.system_prompt.prompt
Current Behavior:
- ONE global system prompt used for ALL queries
- Defined in
agent_config.json:
{
"model": {
"system_prompt": {
"enabled": true,
"prompt": "You are meeTARA, an accurate AI assistant.\nIMPORTANT: For math/calculations, always verify your answer before responding.\nRespond in this format:\nπ― **Answer**: Direct answer (must be correct)\nπ **Details**: Key facts (2-3 bullets)\nβ‘ **Steps**: Show your work/calculation\nπ‘ **Note**: Any warnings (1 sentence)\nBe accurate first, concise second."
}
}
}
- Applied in ChatML format:
<|im_start|>system
{system_prompt}
<|im_end|>
<|im_start|>user
{query}
<|im_end|>
<|im_start|>assistant
Limitation: Same system prompt for all domains (healthcare, business, education, etc.)
2. Agent Level - Enhanced Instructions
Location: core/meetara_agent.py β run() method (line ~1384)
Config: config/agent_config.json β web_search.news_query_instructions
Current Behavior:
- Tool-specific instructions added to user prompt (NOT system prompt)
- Example: News query instructions added when web search is used for news:
{
"web_search": {
"news_query_instructions": {
"enabled": true,
"instruction_template": "CRITICAL INSTRUCTIONS FOR NEWS/HEADLINES QUERY:\n1. Extract and list the ACTUAL NEWS HEADLINES..."
}
}
}
- Applied as part of enhanced user prompt:
{query}
=== Tool Results ===
{search_results}
{instruction_text} β Added here (in user message, not system)
Current Domain Support:
- β
News/Headlines queries (via
news_query_instructions) - β No other domain-specific instructions currently
Domain Mapping Structure
Location: config/domain_mapping.json
Available Domain Categories:
healthcare(π₯) - Medical, wellness, healthdaily_life(π ) - Personal, family, everydaybusiness(πΌ) - Business, entrepreneurshipeducation(π) - Learning, skill developmentcreative(π¨) - Creative expression, artspsychology_wellness(π§) - Mental wellnesssports_recreation(β½) - Physical fitnesstechnology(π») - Technology, digital solutionslegal_financial(βοΈ) - Legal matters, financetravel_tourism(π§³) - Travel planningfood_cooking(π³) - Culinary arts- And more...
Domain Properties (Available but NOT Currently Used for System Prompts):
keywords- Keywords to detect domainemotional_context- Tone/style (e.g., "compassionate", "professional")description- Domain descriptionmodel_preference- Model type preference
Proposed: Domain-Specific System Prompts
Option 1: Agent-Level Domain Detection + Enhanced Instructions
How it works:
- Agent detects domain from query keywords (using
domain_mapping.json) - Agent adds domain-specific instructions to user prompt (similar to news queries)
- System prompt remains global
Pros:
- β Easy to implement
- β Non-invasive (doesn't change core)
- β Similar to existing news query pattern
Cons:
- β Instructions in user prompt (weaker than system prompt)
- β Not as effective as system-level prompts
Option 2: Core-Level Domain-Specific System Prompts
How it works:
- Agent detects domain and passes domain info to Core
- Core selects domain-specific system prompt from config
- Core applies domain-specific system prompt to model
Pros:
- β More effective (system prompt is stronger than user instructions)
- β Proper separation (domain detection in agent, prompt selection in core)
- β Domain-specific behavior baked into model context
Cons:
- β Requires changes to Core API
- β More complex implementation
Implementation Recommendations
Recommended Approach: Hybrid (Option 1 + Option 2)
Agent Level:
- Detect domain from query keywords (using
domain_mapping.json) - Add domain-specific context instructions to user prompt (for tool results)
- Detect domain from query keywords (using
Core Level:
- Add domain-specific system prompt enhancement
- Optionally prepend domain context to base system prompt
Example Domain System Prompts Structure:
{
"model": {
"system_prompt": {
"enabled": true,
"base_prompt": "You are meeTARA, an accurate AI assistant...",
"domain_specific_prompts": {
"healthcare": {
"enabled": true,
"enhancement": "You are responding to a healthcare/medical query. Be compassionate, professional, and include appropriate medical disclaimers. Always remind users to consult healthcare professionals for medical advice.",
"append_mode": true
},
"business": {
"enabled": true,
"enhancement": "You are responding to a business query. Be professional, data-driven, and focus on actionable insights. Include relevant business metrics and considerations.",
"append_mode": true
},
"legal_financial": {
"enabled": true,
"enhancement": "You are responding to a legal or financial query. Be precise, cite sources when possible, and include appropriate disclaimers about not providing legal/financial advice.",
"append_mode": true
}
}
}
}
}
Flow:
User Query β Agent detects domain β
β Agent: Adds domain-specific instructions to user prompt (for tool results)
β Core: Enhances system prompt with domain context
β Model: Generates response with domain-aware context
Next Steps
To implement domain-specific system prompts:
- Add domain detection function (uses
domain_mapping.jsonkeywords) - Extend
agent_config.jsonwithdomain_specific_promptssection - Modify Core
_get_system_prompt()to accept domain parameter - Modify Agent
run()to:- Detect domain
- Pass domain to Core
- Add domain-specific instructions to user prompt (for tool results)
Would you like me to implement this?