meetara / DOMAIN_SYSTEM_PROMPTS.md
rameshbasina's picture
Add domain-specific system prompts documentation in DOMAIN_SYSTEM_PROMPTS.md
6656de9

A newer version of the Gradio SDK is available: 6.3.0

Upgrade

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:

  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:

{
  "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?