| # Pub/Sub Multi-Agent System - Example Configurations |
|
|
| **Note**: This deployment includes **phi4-mini** (general purpose), **MedAIBase/MedGemma1.5:4b** (medical/healthcare), and **deepseek-coder:1.3b** (coding) models. |
|
|
| **Important**: Use `{question}` in prompts to access the user's question, `{schema}` for database schema, and `{input}` for messages from subscribed topics (all case insensitive). |
|
|
| ## Example 1: Natural Language to SQL Pipeline (using phi4-mini) |
|
|
| ### Agent 1: Question Analyzer |
| - **Title**: Question Analyzer |
| - **Prompt**: |
| ``` |
| Given this database schema: |
| {schema} |
| |
| User question: {question} |
| |
| Analyze the question and identify: |
| 1. What tables are needed |
| 2. What columns are needed |
| 3. What the user wants to retrieve |
| |
| Respond with a clear analysis. |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: START |
| - **Publish Topic**: QUESTION_ANALYZED |
| |
| ### Agent 2: SQL Generator |
| - **Title**: SQL Generator |
| - **Prompt**: |
| ``` |
| Based on this analysis: |
| {input} |
| |
| Database schema: |
| {schema} |
| |
| Original question: {question} |
| |
| Generate a SQL query that answers the user's question. |
| Return ONLY the SQL query, no explanation. |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: QUESTION_ANALYZED |
| - **Publish Topic**: SQL_GENERATED |
| |
| ### Agent 3: SQL Validator |
| - **Title**: SQL Validator |
| - **Prompt**: |
| ``` |
| Check if this SQL query is valid and correct: |
| {input} |
| |
| Schema: |
| {schema} |
| |
| If valid, return "VALID: " followed by the query. |
| If invalid, return "INVALID: " followed by the corrected query. |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: SQL_GENERATED |
| - **Publish Topic**: FINAL |
|
|
| --- |
|
|
| ## Example 2: Medical Symptom Analysis (Using MedGemma) |
|
|
| **User Question**: "Patient has fever, cough, and shortness of breath for 3 days" |
|
|
| ### Agent 1: Symptom Extractor |
| - **Title**: Symptom Extractor |
| - **Prompt**: |
| ``` |
| Patient report: {question} |
| |
| Extract all symptoms mentioned in the patient report. |
| List them clearly and concisely. |
| ``` |
| - **Model**: MedAIBase/MedGemma1.5:4b |
| - **Subscribe Topic**: START |
| - **Publish Topic**: SYMPTOMS_EXTRACTED |
| |
| ### Agent 2: Preliminary Assessment |
| - **Title**: Preliminary Assessment |
| - **Prompt**: |
| ``` |
| Based on these symptoms: |
| {input} |
| |
| Provide a preliminary medical assessment including: |
| 1. Possible conditions |
| 2. Severity level |
| 3. Recommended next steps |
| |
| Note: This is for educational purposes only, not medical advice. |
| ``` |
| - **Model**: MedAIBase/MedGemma1.5:4b |
| - **Subscribe Topic**: SYMPTOMS_EXTRACTED |
| - **Publish Topic**: FINAL |
| - **Subscribe Topic**: SYMPTOMS_EXTRACTED |
| - **Publish Topic**: ASSESSMENT_COMPLETE |
|
|
| --- |
|
|
| ## Example 3: Code Review and Debugging (Using DeepSeek Coder) |
|
|
| **User Question**: "Review this Python function for bugs" |
|
|
| **Data Source:** |
| - Label: `Code` |
| - Content: |
| ```python |
| def calculate_average(numbers): |
| total = 0 |
| for num in numbers: |
| total += num |
| return total / len(numbers) |
| ``` |
|
|
| ### Agent 1: Bug Detector |
| - **Title**: Bug Detector |
| - **Prompt**: |
| ``` |
| Review this code for bugs: |
| |
| {Code} |
| |
| Identify any bugs, edge cases, or potential issues. |
| ``` |
| - **Model**: deepseek-coder:1.3b |
| - **Subscribe Topic**: START |
| - **Publish Topic**: BUGS_FOUND |
| |
| ### Agent 2: Code Fixer |
| - **Title**: Code Fixer |
| - **Prompt**: |
| ``` |
| Based on these identified issues: |
| {input} |
| |
| Original code: |
| {Code} |
| |
| Provide the corrected code with fixes for all issues. |
| ``` |
| - **Model**: deepseek-coder:1.3b |
| - **Subscribe Topic**: BUGS_FOUND |
| - **Publish Topic**: FINAL |
|
|
| --- |
|
|
| ## Example 4: Research Paper Analysis |
|
|
| ### Agent 1: Abstract Analyzer |
| - **Title**: Abstract Analyzer |
| - **Prompt**: |
| ``` |
| Paper abstract: {input} |
| |
| Analyze the abstract and extract: |
| 1. Main research question |
| 2. Methodology |
| 3. Key findings |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: START |
| - **Publish Topic**: ABSTRACT_ANALYZED |
| |
| ### Agent 2: Methodology Reviewer |
| - **Title**: Methodology Reviewer |
| - **Prompt**: |
| ``` |
| Based on this analysis: |
| {input} |
| |
| Evaluate the research methodology: |
| 1. Is it appropriate for the research question? |
| 2. What are the strengths? |
| 3. What are potential limitations? |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: ABSTRACT_ANALYZED |
| - **Publish Topic**: METHODOLOGY_REVIEWED |
| |
| ### Agent 3: Summary Generator |
| - **Title**: Summary Generator |
| - **Prompt**: |
| ``` |
| Based on this methodology review: |
| {input} |
| |
| Generate a comprehensive summary of the paper suitable for a literature review. |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: METHODOLOGY_REVIEWED |
| - **Publish Topic**: SUMMARY_COMPLETE |
| |
| --- |
| |
| ## Example 5: Content Moderation Pipeline (using phi4-mini) |
| |
| ### Agent 1: Content Classifier |
| - **Title**: Content Classifier |
| - **Prompt**: |
| ``` |
| Content: {input} |
| |
| Classify this content into one of these categories: |
| - SAFE |
| - NEEDS_REVIEW |
| - INAPPROPRIATE |
|
|
| Provide classification and brief reasoning. |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: START |
| - **Publish Topic**: CLASSIFIED |
| |
| ### Agent 2: Detailed Review (only for NEEDS_REVIEW) |
| - **Title**: Detailed Reviewer |
| - **Prompt**: |
| ``` |
| Classification result: {input} |
|
|
| If the content was marked as NEEDS_REVIEW, provide: |
| 1. Specific concerns |
| 2. Severity level (low/medium/high) |
| 3. Recommended action |
| |
| If not NEEDS_REVIEW, just respond "NO REVIEW NEEDED" |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: CLASSIFIED |
| - **Publish Topic**: REVIEW_COMPLETE |
| |
| --- |
| |
| ## Example 5: Medical Symptom Analysis (phi4-mini can handle basic medical tasks) |
| |
| ### Agent 1: Symptom Categorizer |
| - **Title**: Symptom Categorizer |
| - **Prompt**: |
| ``` |
| Patient symptoms: {input} |
|
|
| Categorize these symptoms by body system: |
| - Cardiovascular |
| - Respiratory |
| - Neurological |
| - Gastrointestinal |
| - Other |
|
|
| List each symptom under its appropriate category. |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: START |
| - **Publish Topic**: SYMPTOMS_CATEGORIZED |
| |
| ### Agent 2: Diagnostic Reasoning |
| - **Title**: Diagnostic Reasoning |
| - **Prompt**: |
| ``` |
| Categorized symptoms: |
| {input} |
|
|
| Based on these symptoms, provide: |
| 1. Most likely differential diagnoses (top 3) |
| 2. Supporting evidence for each |
| 3. Recommended diagnostic tests |
|
|
| Note: This is for educational purposes only. |
| ``` |
| - **Model**: phi4-mini |
| - **Subscribe Topic**: SYMPTOMS_CATEGORIZED |
| - **Publish Topic**: DIAGNOSIS_COMPLETE |
| |
| --- |
| |
| ## Tips for Creating Effective Agents |
| |
| 1. **Clear Subscribe/Publish Topics**: Use descriptive names like "SQL_GENERATED" not just "STEP2" |
| |
| 2. **Prompt Placeholders**: |
| - Use `{question}` for the user's input question |
| - Use `{input}` for the message from the subscribed topic |
| - Use `{schema}` to access the database schema |
| - All three can be used together in any prompt |
| |
| 3. **Model Selection**: |
| - **phi4-mini**: Versatile general-purpose model - text analysis, SQL, reasoning, classification |
| - **cniongolo/biomistral**: Medical and scientific tasks - diagnosis, clinical reasoning, biomedical analysis |
| |
| 4. **Final Results**: |
| - Publish to topic "FINAL" to display results in the Final Result box |
| - Only the last agent in your chain should publish to FINAL |
| |
| 4. **Chain Design**: |
| - Start simple with 2-3 agents |
| - Each agent should have ONE clear purpose |
| - Test each agent individually first |
| |
| 5. **Error Handling**: |
| - If an agent has no subscribers for its publish topic, the chain stops |
| - Make sure START has at least one subscriber |
| - Check that all topics form a connected chain |
| |
| 6. **Debugging**: |
| - Watch the execution log carefully |
| - Check which topics have subscribers |
| - Verify message flow through the bus |
| |