santanche's picture
refactor (model): replacing phi3 by phi4-mini
f369a7d

Save and Load Configurations

Saving Your Setup

  1. Configure data sources and agents
  2. Click "Save Config" button (top right)
  3. JSON file downloads: pubsub-config-2026-02-01.json

What gets saved:

  • All data sources (labels + content)
  • All agents (complete setup)
  • User question
  • Timestamp

Loading a Configuration

  1. Click "Load Config" button (top right)
  2. Select a saved JSON file
  3. Everything is restored automatically!

Use cases:

  • Save templates for common workflows
  • Share configurations with teammates
  • Version control your pipelines
  • Quick switch between different setups

Example workflow:

# Save your SQL analysis pipeline
β†’ Configure agents for SQL generation
β†’ Click "Save Config"
β†’ File: sql-analysis-pipeline.json

# Later or on different computer:
β†’ Click "Load Config"
β†’ Select sql-analysis-pipeline.json
β†’ Everything restored, ready to use!

See CONFIGURATION_GUIDE.md for details.

Case Insensitive Examples

Topics Are Case Insensitive

Agent 1:
- Subscribe: "START"
- Publish: "analyzed"

Agent 2:
- Subscribe: "ANALYZED"  ← Matches "analyzed" from Agent 1!
- Publish: "Done"

Agent 3:
- Subscribe: "done"  ← Matches "Done" from Agent 2!

Placeholders Are Case Insensitive

Prompt 1: "Question: {QUESTION}"
Prompt 2: "Question: {question}"
Prompt 3: "Question: {QuEsTiOn}"

All three get the same user question!

Data Sources Are Case Insensitive

Data Source Label: "MyData"

These all work:
- {MyData}
- {mydata}
- {MYDATA}
- {myData}
```# Quick Start Guide - Enhanced Pub/Sub System

## New Features Overview

### 1. Dynamic Data Sources (No Default Schema)
- **Start fresh**: No default data sources loaded
- **Add on demand**: Click "Add Data Source" to create
- Each data source has:
  - **Label**: Reference name (e.g., "Schema", "Context", "Rules")
  - **Content**: Manual text input
  - **File Upload**: Optional .txt or .csv file upload
- Use data source in prompts: `{Label}` **case insensitive** (e.g., `{schema}`, `{SCHEMA}`, `{Schema}` all work)

### 2. Case Insensitive References
- **Placeholders**: `{question}`, `{QUESTION}`, `{Question}` all work
- **Data sources**: `{schema}`, `{Schema}`, `{SCHEMA}` all match the same source  
- **Topics**: Subscribing to "start", "START", "Start" all match the same topic
- **Benefit**: No more errors from capitalization mismatches!

### 3. Three Specialized Models
- **phi4-mini**: General-purpose tasks (3.8B params)
- **MedAIBase/MedGemma1.5:4b**: Medical/healthcare (4B params)
- **deepseek-coder:1.3b**: Code generation and analysis (1.3B params)

### 4. Save/Load Configuration
- **Save Config**: Export entire setup as JSON file
- **Load Config**: Import previously saved configurations
- **Share workflows**: Send config files to teammates
- **Version control**: Track configs in Git

### 4. Show Result Checkbox
- **No more FINAL topic** required
- Each agent has a "Show result" checkbox
- **Multiple agents** can show results
- Results are **concatenated** in Final Result box with agent names as separators

### 5. Optional Publish Topic
- Publish Topic field is now **optional**
- Leave empty if agent shouldn't publish to bus
- Useful for final agents that only display results

## How to Use

### Step 1: Set Up Data Sources

Click "Add Data Source" to create data sources:

**Example 1: Database Schema**
- Label: `Schema`
- Content: 

Tables:

  • users (id, name, email)
  • orders (id, user_id, total)

**Example 2: Business Rules**
- Label: `Rules`
- Content or Upload File: company_policies.txt

**Example 3: Sample Data**
- Label: `SampleData`
- Upload: sales_data.csv

### Step 2: Enter User Question

In the "User Question" box:

What are the top 10 customers by total order value?


### Step 3: Configure Agents

**Agent 1: Query Generator**
- Title: `SQL Generator`
- Prompt:

User wants to know: {QUESTION}

Database schema: {schema}

Generate a SQL query to answer this question.

Note: Used `{QUESTION}` and `{schema}` in different cases - both work!
- Model: `phi4-mini`
- Subscribe: `START`
- Publish: `SQL_QUERY` *(optional - leave empty if not needed)*
- β˜‘ Show result

**Agent 2: Query Explainer** *(if you published from Agent 1)*
- Title: `Explainer`
- Prompt:

Explain this SQL query in simple terms: {input}

Original question: {question}

- Model: `phi4-mini`
- Subscribe: `SQL_QUERY`
- Publish: *(leave empty)*
- β˜‘ Show result

### Step 4: Execute

Click "Execute Pipeline" and see both results in the Final Result box:

--- SQL Generator ---

SELECT u.name, SUM(o.total) as total_value FROM users u JOIN orders o ON u.id = o.user_id GROUP BY u.id, u.name ORDER BY total_value DESC LIMIT 10

--- Explainer ---

This query finds the top 10 customers by combining user and order data...


## Data Source Examples

### Medical Analysis with Multiple Sources

**Data Source 1:**
- Label: `Symptoms`
- Content: Upload patient_symptoms.txt

**Data Source 2:**
- Label: `Guidelines`
- Content: Upload medical_guidelines.pdf (as text)

**Data Source 3:**
- Label: `History`  
- Content:

Patient: 45 year old male Previous conditions: Hypertension, Diabetes Type 2 Current medications: Metformin, Lisinopril


**Agent Prompt (using MedGemma):**

Patient history: {History}

Current symptoms: {Symptoms}

Clinical guidelines: {Guidelines}

Based on all available information, provide preliminary assessment.

- **Model**: MedAIBase/MedGemma1.5:4b

### Multi-Document Analysis

**Data Source 1: Report1**
- Upload: quarterly_report_q1.txt

**Data Source 2: Report2**
- Upload: quarterly_report_q2.txt

**Data Source 3: Report3**
- Upload: quarterly_report_q3.txt

**Agent Prompt:**

Compare these three quarterly reports:

Q1: {Report1} Q2: {Report2}
Q3: {Report3}

Identify trends and key changes across quarters.


### Code Analysis with DeepSeek Coder

**Data Source: CodeFile**
- Upload: buggy_function.py

**User Question**: "Find and fix bugs in this code"

**Agent 1: Bug Detector**

Analyze this code for bugs and issues: {CodeFile}

List all bugs found.

- **Model**: deepseek-coder:1.3b

**Agent 2: Code Fixer**

Fix these bugs: {input}

Original code: {CodeFile}

Provide corrected code.

- **Model**: deepseek-coder:1.3b

## Using File Uploads

### Text Files (.txt)
- Uploaded content is appended to existing content
- Separator added automatically: `--- Uploaded File ---`

### CSV Files (.csv)
- Uploaded as plain text
- Agents can parse and process the CSV content

### Combining Manual + File Content
1. Type some context in the Content box
2. Upload a file
3. Both are concatenated together

Example:

Manual content: "This is sales data for 2024"

--- Uploaded File ---

Product,Sales,Region Widget,1000,North Gadget,1500,South ...


## Agent Configuration Patterns

### Pattern 1: Analysis Only (No Publishing)

Agent: Data Analyzer Subscribe: START Publish: (empty) β˜‘ Show result

Perfect for final analysis agents.

### Pattern 2: Pipeline with Multiple Displays

Agent 1: Extractor Subscribe: START Publish: EXTRACTED β˜‘ Show result ← See extracted data

Agent 2: Processor
Subscribe: EXTRACTED Publish: PROCESSED β˜‘ Show result ← See processed data

Agent 3: Summarizer Subscribe: PROCESSED Publish: (empty) β˜‘ Show result ← See final summary

All three results appear in Final Result box!

### Pattern 3: Conditional Display

Agent 1: Classifier Subscribe: START Publish: CLASSIFIED ☐ Don't show (internal step)

Agent 2: Handler Subscribe: CLASSIFIED
Publish: (empty) β˜‘ Show result ← Only show final result


## Prompt Placeholder Reference

| Placeholder | Contains | Case Sensitive? | When to Use |
|------------|----------|-----------------|-------------|
| `{question}` | User's input question | **NO** - `{QUESTION}`, `{Question}` work too | First agent, or any agent needing original question |
| `{input}` | Message from subscribed topic | **NO** - `{INPUT}`, `{Input}` work too | Middle/end agents in chain |
| `{YourLabel}` | Content from data source | **NO** - `{yourlabel}`, `{YOURLABEL}` work too | Any agent needing that data |

### Example Using Mixed Cases:

User asked: {QUESTION}

Previous analysis: {Input}

Reference data: {schema} {RULES} {context}

Generate final response considering all information above.


All placeholders work regardless of capitalization!

## Tips and Best Practices

### Data Source Organization
1. **Use clear labels**: "Schema" not "s", "Context" not "c1"
2. **One concern per source**: Separate schema, rules, examples
3. **Reusable sources**: Multiple agents can reference same data source

### Show Result Strategy
1. **Debug mode**: Check all agents to see intermediate results
2. **Production mode**: Only check final agent(s)
3. **Comparison**: Check multiple agents to compare approaches

### Optional Publishing
- **Last agent**: Usually doesn't need to publish
- **Dead-end branches**: Agents that don't trigger others
- **Display-only**: Agents that just show results

### File Upload Tips
1. Keep files relatively small (< 1MB recommended)
2. Use .txt for unstructured text
3. Use .csv for tabular data
4. Files are read as plain text (not executed)

## Common Workflows

### Workflow 1: SQL Generation from Question + Schema

**Data Sources:**
- Schema: `{Schema}`

**User Question:** "Find top customers"

**Agents:**
1. Analyzer β†’ Publish: ANALYZED
2. SQL Generator (uses {Schema}, {input}) β†’ Show β˜‘

### Workflow 2: Medical Diagnosis with Multiple Data

**Data Sources:**
- Symptoms: Upload patient file
- History: Manual text
- Guidelines: Upload reference

**User Question:** "Preliminary assessment?"

**Agents:**
1. Symptom Extractor (uses {Symptoms}) β†’ Publish: EXTRACTED
2. Analyzer (uses {input}, {History}, {Guidelines}) β†’ Show β˜‘

### Workflow 3: Multi-Document Synthesis

**Data Sources:**
- Doc1, Doc2, Doc3: Upload files

**Agents:**
1. Extractor (uses {Doc1}, {Doc2}, {Doc3}) β†’ Publish: EXTRACTED, Show β˜‘
2. Synthesizer (uses {input}) β†’ Show β˜‘

Both extraction and synthesis appear in Final Result!

## Troubleshooting

**Q: Data source not replaced in prompt**
- Check label exists in data sources
- Case doesn't matter: `{Schema}`, `{schema}`, `{SCHEMA}` all work
- Use curly braces: `{Label}` not just `Label`

**Q: Topics not matching**
- Topics are case insensitive now!
- "START", "start", "Start" all match
- Check for typos in topic names

**Q: Lost my configuration**
- Use Save Config regularly
- Saved configs can be reloaded anytime
- Consider version controlling config files

**Q: Multiple results not showing**
- Ensure "Show result" is checked for each agent
- Results appear in order of execution

**Q: Agent not receiving data**
- Check Subscribe Topic matches previous Publish Topic
- Remember: Publish Topic is optional for last agents

**Q: File upload not working**
- Check file is .txt or .csv
- Content appends to existing text
- Large files may take time to load