File size: 7,372 Bytes
1d41764 f369a7d e57db30 c0d38ea ef3dd30 f369a7d 1d41764 e57db30 1d41764 f369a7d 1d41764 e57db30 1d41764 f369a7d 1d41764 f369a7d 1d41764 e57db30 1d41764 854bdac 1d41764 e57db30 1d41764 e57db30 1d41764 854bdac 1d41764 854bdac e57db30 1d41764 c0d38ea 1d41764 f369a7d 1d41764 f369a7d 1d41764 f369a7d 1d41764 f369a7d 1d41764 f369a7d 1d41764 f369a7d 1d41764 f369a7d 1d41764 ef3dd30 1d41764 ef3dd30 1d41764 ef3dd30 1d41764 f369a7d 1d41764 ef3dd30 1d41764 ef3dd30 1d41764 ef3dd30 1d41764 ef3dd30 1d41764 ef3dd30 1d41764 f369a7d ef3dd30 1d41764 e57db30 1d41764 e57db30 1d41764 f369a7d c0d38ea e57db30 1d41764 | 1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 | # 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
|