Skip to content

Commit

Permalink
swarms docs ui chat gradio
Browse files Browse the repository at this point in the history
  • Loading branch information
kyegomez committed Feb 17, 2025
1 parent 123713b commit 506d116
Show file tree
Hide file tree
Showing 13 changed files with 1,960 additions and 26 deletions.
5 changes: 5 additions & 0 deletions docs/mkdocs.yml
Original file line number Diff line number Diff line change
Expand Up @@ -227,6 +227,11 @@ nav:
- Meme Agent Builder: "swarms/examples/meme_agents.md"
- Multi-Agent Collaboration:
- Swarms DAO: "swarms/examples/swarms_dao.md"

- Swarms UI:
- Overview: "swarms/ui/main.md"


- Contributors:
- Bounty Program: "corporate/bounty_program.md"
- Contributing:
Expand Down
1 change: 0 additions & 1 deletion docs/requirements.txt
Original file line number Diff line number Diff line change
Expand Up @@ -30,7 +30,6 @@ pygments~=2.19
pymdown-extensions~=10.14

# Requirements for plugins
babel~=2.16
colorama~=0.4
paginate~=0.5
regex>=2022.4
281 changes: 281 additions & 0 deletions docs/swarms/ui/main.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,281 @@
Below is a revised version of the Swarms Chat UI documentation. It improves the flow, adds detailed examples for every use case, and clarifies the installation and usage instructions for a more reliable experience.

---

# Swarms Chat UI Documentation

The Swarms Chat interface provides a customizable, multi-agent chat experience using Gradio. It supports various specialized AI agents—from finance to healthcare and news analysis—by leveraging Swarms models.

---

## Table of Contents

1. [Installation](#installation)
2. [Quick Start](#quick-start)
3. [Parameters Overview](#parameters-overview)
4. [Specialized Agents](#specialized-agents)
- [Finance Agents](#finance-agents)
- [Healthcare Agents](#healthcare-agents)
- [News & Research Agents](#news--research-agents)
5. [Swarms Integration Features](#swarms-integration-features)
6. [Usage Examples](#usage-examples)
- [Finance Agent Example](#finance-agent-example)
- [Healthcare Agent Example](#healthcare-agent-example)
- [News Analysis Agent Example](#news-analysis-agent-example)
7. [Setup and Deployment](#setup-and-deployment)
8. [Best Practices](#best-practices)
9. [Notes](#notes)

---

## Installation

Make sure you have Python 3.7+ installed, then install the required packages using pip:

```bash
pip install gradio ai-gradio swarms
```

---

## Quick Start

Below is a minimal example to get the Swarms Chat interface up and running. Customize the agent, title, and description as needed.

```python
import gradio as gr
import ai_gradio

# Create and launch a Swarms Chat interface
gr.load(
name='swarms:gpt-4-turbo', # Model identifier (supports OpenAI and others)
src=ai_gradio.registry, # Source module for model configurations
agent_name="Stock-Analysis-Agent", # Example agent from Finance category
title='Swarms Chat',
description='Chat with an AI agent powered by Swarms'
).launch()
```

---

## Parameters Overview

When configuring your interface, consider the following parameters:

- **`name` (str):**
Model identifier (e.g., `'swarms:gpt-4-turbo'`) that specifies which Swarms model to use.

- **`src` (module):**
The source module (typically `ai_gradio.registry`) that contains model configurations.

- **`agent_name` (str):**
The name of the specialized agent you wish to use (e.g., "Stock-Analysis-Agent").

- **`title` (str):**
The title that appears at the top of the web interface.

- **`description` (str):**
A short summary describing the functionality of the chat interface.

---

## Specialized Agents

Swarms Chat supports multiple specialized agents designed for different domains. Below is an overview of available agent types.

### Finance Agents

1. **Stock Analysis Agent**
- **Capabilities:**
- Market analysis and stock recommendations.
- Both technical and fundamental analysis.
- Portfolio management suggestions.

2. **Tax Planning Agent**
- **Capabilities:**
- Tax optimization strategies.
- Deduction analysis.
- Guidance on tax law compliance.

### Healthcare Agents

1. **Medical Diagnosis Assistant**
- **Capabilities:**
- Analysis of symptoms.
- Treatment recommendations.
- Research using current medical literature.

2. **Healthcare Management Agent**
- **Capabilities:**
- Patient care coordination.
- Organization of medical records.
- Monitoring and tracking treatment plans.

### News & Research Agents

1. **News Analysis Agent**
- **Capabilities:**
- Real-time news aggregation.
- Filtering news by topics.
- Trend analysis and insights.

2. **Research Assistant**
- **Capabilities:**
- Analysis of academic papers.
- Literature review support.
- Guidance on research methodologies.

---

## Swarms Integration Features

### Core Capabilities

- **Multi-Agent Collaboration:** Multiple agents can be engaged simultaneously for a coordinated experience.
- **Real-Time Data Processing:** The interface processes and responds to queries in real time.
- **Natural Language Understanding:** Advanced NLP for context-aware and coherent responses.
- **Context-Aware Responses:** Responses are tailored based on conversation context.

### Technical Features

- **API Integration Support:** Easily connect with external APIs.
- **Custom Model Selection:** Choose the appropriate model for your specific task.
- **Concurrent Processing:** Supports multiple sessions concurrently.
- **Session Management:** Built-in session management ensures smooth user interactions.

---

## Usage Examples

Below are detailed examples for each type of specialized agent.

### Finance Agent Example

This example configures a chat interface for stock analysis:

```python
import gradio as gr
import ai_gradio

finance_interface = gr.load(
name='swarms:gpt-4-turbo',
src=ai_gradio.registry,
agent_name="Stock-Analysis-Agent",
title='Finance Assistant',
description='Expert financial analysis and advice tailored to your investment needs.'
)
finance_interface.launch()
```

### Healthcare Agent Example

This example sets up a chat interface for healthcare assistance:

```python
import gradio as gr
import ai_gradio

healthcare_interface = gr.load(
name='swarms:gpt-4-turbo',
src=ai_gradio.registry,
agent_name="Medical-Assistant-Agent",
title='Healthcare Assistant',
description='Access medical information, symptom analysis, and treatment recommendations.'
)
healthcare_interface.launch()
```

### News Analysis Agent Example

This example creates an interface for real-time news analysis:

```python
import gradio as gr
import ai_gradio

news_interface = gr.load(
name='swarms:gpt-4-turbo',
src=ai_gradio.registry,
agent_name="News-Analysis-Agent",
title='News Analyzer',
description='Get real-time insights and analysis of trending news topics.'
)
news_interface.launch()
```

---

## Setup and Deployment

1. **Install Dependencies:**
Make sure all required packages are installed.

```bash
pip install gradio ai-gradio swarms
```

2. **Import Modules:**
Import Gradio and ai_gradio in your Python script.

```python
import gradio as gr
import ai_gradio
```

3. **Configure and Launch the Interface:**
Configure your interface with the desired parameters and then launch.

```python
interface = gr.load(
name='swarms:gpt-4-turbo',
src=ai_gradio.registry,
agent_name="Your-Desired-Agent",
title='Your Interface Title',
description='A brief description of your interface.'
)
interface.launch()
```

4. **Deployment Options:**
- **Local:** By default, the interface runs at [http://localhost:7860](http://localhost:7860).
- **Cloud Deployment:** Use cloud platforms like Heroku, AWS, or Google Cloud for remote access.
- **Concurrent Sessions:** The system supports multiple users at the same time. Monitor resources and use proper scaling.

---

## Best Practices

1. **Select the Right Agent:**
Use the agent that best suits your specific domain needs.

2. **Model Configuration:**
Adjust model parameters based on your computational resources to balance performance and cost.

3. **Error Handling:**
Implement error handling to manage unexpected inputs or API failures gracefully.

4. **Resource Monitoring:**
Keep an eye on system performance, especially during high-concurrency sessions.

5. **Regular Updates:**
Keep your Swarms and Gradio packages updated to ensure compatibility with new features and security patches.

---

## Notes

- **Local vs. Remote:**
The interface runs locally by default but can be deployed on remote servers for wider accessibility.

- **Customization:**
You can configure custom model parameters and integrate additional APIs as needed.

- **Session Management:**
Built-in session handling ensures that users can interact concurrently without interfering with each other's sessions.

- **Error Handling & Rate Limiting:**
The system includes basic error handling and rate limiting to maintain performance under load.

---

This documentation is designed to provide clarity, reliability, and comprehensive guidance for integrating and using the Swarms Chat UI. For further customization or troubleshooting, consult the respective package documentation and community forums.
Loading

0 comments on commit 506d116

Please sign in to comment.