# 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`: ```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: ```json { "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:** 1. `healthcare` (šŸ„) - Medical, wellness, health 2. `daily_life` (šŸ ) - Personal, family, everyday 3. `business` (šŸ’¼) - Business, entrepreneurship 4. `education` (šŸ“š) - Learning, skill development 5. `creative` (šŸŽØ) - Creative expression, arts 6. `psychology_wellness` (🧘) - Mental wellness 7. `sports_recreation` (⚽) - Physical fitness 8. `technology` (šŸ’») - Technology, digital solutions 9. `legal_financial` (āš–ļø) - Legal matters, finance 10. `travel_tourism` (🧳) - Travel planning 11. `food_cooking` (šŸ³) - Culinary arts 12. And more... **Domain Properties (Available but NOT Currently Used for System Prompts):** - `keywords` - Keywords to detect domain - `emotional_context` - Tone/style (e.g., "compassionate", "professional") - `description` - Domain description - `model_preference` - Model type preference --- ## Proposed: Domain-Specific System Prompts ### Option 1: Agent-Level Domain Detection + Enhanced Instructions **How it works:** 1. Agent detects domain from query keywords (using `domain_mapping.json`) 2. Agent adds domain-specific instructions to user prompt (similar to news queries) 3. 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:** 1. Agent detects domain and passes domain info to Core 2. Core selects domain-specific system prompt from config 3. 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)** 1. **Agent Level:** - Detect domain from query keywords (using `domain_mapping.json`) - Add domain-specific context instructions to user prompt (for tool results) 2. **Core Level:** - Add domain-specific system prompt enhancement - Optionally prepend domain context to base system prompt **Example Domain System Prompts Structure:** ```json { "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: 1. **Add domain detection function** (uses `domain_mapping.json` keywords) 2. **Extend `agent_config.json`** with `domain_specific_prompts` section 3. **Modify Core `_get_system_prompt()`** to accept domain parameter 4. **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?