Spaces:
Running
Running
| # 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? | |