parent
57f2679e4f
commit
7091518a34
@ -0,0 +1,122 @@
|
|||||||
|
# Swarms Platform Documentation
|
||||||
|
|
||||||
|
Welcome to the Swarms Platform, a dynamic ecosystem where users can share, discover, and host agents and agent swarms. This documentation will guide you through the various features of the platform, providing you with the information you need to get started and make the most out of your experience.
|
||||||
|
|
||||||
|
## Table of Contents
|
||||||
|
|
||||||
|
1. [Introduction](#introduction)
|
||||||
|
2. [Getting Started](#getting-started)
|
||||||
|
3. [Account Management](#account-management)
|
||||||
|
4. [Usage Monitoring](#usage-monitoring)
|
||||||
|
5. [API Key Generation](#api-key-generation)
|
||||||
|
6. [Explorer](#explorer)
|
||||||
|
7. [Dashboard](#dashboard)
|
||||||
|
8. [Creating an Organization](#creating-an-organization)
|
||||||
|
9. [Additional Resources](#additional-resources)
|
||||||
|
|
||||||
|
## Introduction
|
||||||
|
|
||||||
|
The Swarms Platform is designed to facilitate the sharing, discovery, and hosting of intelligent agents and swarms of agents. Whether you are a developer looking to deploy your own agents, or an organization seeking to leverage collective intelligence, the Swarms Platform provides the tools and community support you need.
|
||||||
|
|
||||||
|
## Getting Started
|
||||||
|
|
||||||
|
To begin using the Swarms Platform, follow these steps:
|
||||||
|
|
||||||
|
1. **Create an Account**: Sign up on the platform to access its features.
|
||||||
|
2. **Explore the Dashboard**: Familiarize yourself with the user interface and available functionalities.
|
||||||
|
3. **Generate API Keys**: Securely interact with the platform's API.
|
||||||
|
4. **Create and Join Organizations**: Collaborate with others to deploy and manage agents and swarms.
|
||||||
|
5. **Share and Discover**: Use the Explorer to find and share agents and swarms.
|
||||||
|
|
||||||
|
## Account Management
|
||||||
|
|
||||||
|
### Account Page
|
||||||
|
|
||||||
|
Access and manage your account settings through the account page.
|
||||||
|
|
||||||
|
- **URL**: [Account Page](https://swarms.world/platform/account)
|
||||||
|
|
||||||
|
Here, you can update your profile information, manage security settings, and configure notifications.
|
||||||
|
|
||||||
|
## Usage Monitoring
|
||||||
|
|
||||||
|
### Check Your Usage
|
||||||
|
|
||||||
|
Monitor your usage statistics to keep track of your activities and resource consumption on the platform.
|
||||||
|
|
||||||
|
- **URL**: [Usage Monitoring](https://swarms.world/platform/usage)
|
||||||
|
|
||||||
|
This page provides detailed insights into your usage patterns, helping you optimize your resource allocation and stay within your limits.
|
||||||
|
|
||||||
|
## API Key Generation
|
||||||
|
|
||||||
|
### Generate Your API Keys
|
||||||
|
|
||||||
|
Generate API keys to securely interact with the Swarms Platform API.
|
||||||
|
|
||||||
|
- **URL**: [API Key Generation](https://swarms.world/platform/api-keys)
|
||||||
|
|
||||||
|
Follow the steps on this page to create, manage, and revoke API keys as needed. Ensure that your keys are kept secure and only share them with trusted applications.
|
||||||
|
|
||||||
|
## Explorer
|
||||||
|
|
||||||
|
### Explorer: Share, Discover, and Deploy
|
||||||
|
|
||||||
|
The Explorer is a central hub for sharing, discovering, and deploying prompts, agents, and swarms.
|
||||||
|
|
||||||
|
- **URL**: [Explorer](https://swarms.world/)
|
||||||
|
|
||||||
|
Use the Explorer to:
|
||||||
|
|
||||||
|
- **Share**: Upload and share your own prompts, agents, and swarms with the community.
|
||||||
|
- **Discover**: Browse and discover new and innovative agents and swarms created by others.
|
||||||
|
- **Deploy**: Quickly deploy agents and swarms for your own use or organizational needs.
|
||||||
|
|
||||||
|
## Dashboard
|
||||||
|
|
||||||
|
### Dashboard
|
||||||
|
|
||||||
|
The Dashboard is your control center for managing all aspects of your Swarms Platform experience.
|
||||||
|
|
||||||
|
- **URL**: [Dashboard](https://swarms.world/platform/dashboard)
|
||||||
|
|
||||||
|
From the Dashboard, you can:
|
||||||
|
|
||||||
|
- Monitor real-time metrics and analytics.
|
||||||
|
- Manage your agents and swarms.
|
||||||
|
- Access your account settings and usage information.
|
||||||
|
- Navigate to other sections of the platform.
|
||||||
|
|
||||||
|
## Creating an Organization
|
||||||
|
|
||||||
|
### Create an Organization
|
||||||
|
|
||||||
|
Collaborate with others by creating and joining organizations on the Swarms Platform.
|
||||||
|
|
||||||
|
- **URL**: [Create an Organization](https://swarms.world/platform/organization)
|
||||||
|
|
||||||
|
Creating an organization allows you to:
|
||||||
|
|
||||||
|
- Pool resources with team members.
|
||||||
|
- Manage shared agents and swarms.
|
||||||
|
- Set permissions and roles for organization members.
|
||||||
|
|
||||||
|
## Additional Resources
|
||||||
|
|
||||||
|
To further enhance your understanding and usage of the Swarms Platform, explore the following resources:
|
||||||
|
|
||||||
|
- **API Documentation**: Comprehensive documentation on the platform's API.
|
||||||
|
- **Community Forums**: Engage with other users, share insights, and get support.
|
||||||
|
- **Tutorials and Guides**: Step-by-step tutorials to help you get started with specific features and use cases.
|
||||||
|
- **Support**: Contact the support team for any issues or inquiries.
|
||||||
|
|
||||||
|
### Links
|
||||||
|
|
||||||
|
- [API Documentation](https://docs.swarms.world)
|
||||||
|
- [Community Forums](https://discord.com/servers/agora-999382051935506503)
|
||||||
|
- [Tutorials and Guides](https://docs.swarms.world))
|
||||||
|
- [Support](https://discord.com/servers/agora-999382051935506503)
|
||||||
|
|
||||||
|
## Conclusion
|
||||||
|
|
||||||
|
The Swarms Platform is a versatile and powerful ecosystem for managing intelligent agents and swarms. By following this documentation, you can effectively navigate the platform, leverage its features, and collaborate with others to create innovative solutions. Happy swarming!
|
@ -0,0 +1,198 @@
|
|||||||
|
|
||||||
|
# Prompts API Documentation
|
||||||
|
|
||||||
|
The `https://swarms.world/api/add-prompt` endpoint allows users to add a new prompt to the Swarms platform. This API accepts a POST request with a JSON body containing details of the prompt, such as its name, description, use cases, and tags. The request must be authenticated using an API key.
|
||||||
|
|
||||||
|
## Endpoint
|
||||||
|
|
||||||
|
- **URL:** `https://swarms.world/api/add-prompt`
|
||||||
|
- **Method:** POST
|
||||||
|
- **Content-Type:** `application/json`
|
||||||
|
- **Authorization:** Bearer token required in the header
|
||||||
|
|
||||||
|
## Request Parameters
|
||||||
|
|
||||||
|
The request body should be a JSON object with the following attributes:
|
||||||
|
|
||||||
|
| Attribute | Type | Description | Required |
|
||||||
|
|-------------|----------|---------------------------------------------------------|----------|
|
||||||
|
| `name` | `string` | The name of the prompt. | Yes |
|
||||||
|
| `prompt` | `string` | The prompt text. | Yes |
|
||||||
|
| `description`| `string` | A brief description of the prompt. | Yes |
|
||||||
|
| `useCases` | `array` | An array of use cases, each containing a title and description. | Yes |
|
||||||
|
| `tags` | `string` | Comma-separated tags for the prompt. | No |
|
||||||
|
|
||||||
|
### `useCases` Structure
|
||||||
|
|
||||||
|
Each use case in the `useCases` array should be an object with the following attributes:
|
||||||
|
|
||||||
|
| Attribute | Type | Description | Required |
|
||||||
|
|---------------|----------|---------------------------------|----------|
|
||||||
|
| `title` | `string` | The title of the use case. | Yes |
|
||||||
|
| `description` | `string` | A brief description of the use case. | Yes |
|
||||||
|
|
||||||
|
## Example Usage
|
||||||
|
|
||||||
|
### Python
|
||||||
|
|
||||||
|
```python
|
||||||
|
import requests
|
||||||
|
import json
|
||||||
|
|
||||||
|
url = "https://swarms.world/api/add-prompt"
|
||||||
|
headers = {
|
||||||
|
"Content-Type": "application/json",
|
||||||
|
"Authorization": "Bearer {apiKey}"
|
||||||
|
}
|
||||||
|
data = {
|
||||||
|
"name": "Example Prompt",
|
||||||
|
"prompt": "This is an example prompt from an API route.",
|
||||||
|
"description": "Description of the prompt.",
|
||||||
|
"useCases": [
|
||||||
|
{"title": "Use case 1", "description": "Description of use case 1"},
|
||||||
|
{"title": "Use case 2", "description": "Description of use case 2"}
|
||||||
|
],
|
||||||
|
"tags": "example, prompt"
|
||||||
|
}
|
||||||
|
|
||||||
|
response = requests.post(url, headers=headers, data=json.dumps(data))
|
||||||
|
print(response.json())
|
||||||
|
```
|
||||||
|
|
||||||
|
### Node.js
|
||||||
|
|
||||||
|
```javascript
|
||||||
|
const fetch = require('node-fetch');
|
||||||
|
|
||||||
|
async function addPromptsHandler() {
|
||||||
|
try {
|
||||||
|
const response = await fetch('https://swarms.world/api/add-prompt', {
|
||||||
|
method: 'POST',
|
||||||
|
headers: {
|
||||||
|
'Content-Type': 'application/json',
|
||||||
|
'Authorization': 'Bearer {apiKey}'
|
||||||
|
},
|
||||||
|
body: JSON.stringify({
|
||||||
|
name: 'Example Prompt',
|
||||||
|
prompt: 'This is an example prompt from an API route.',
|
||||||
|
description: 'Description of the prompt.',
|
||||||
|
useCases: [
|
||||||
|
{ title: 'Use case 1', description: 'Description of use case 1' },
|
||||||
|
{ title: 'Use case 2', description: 'Description of use case 2' }
|
||||||
|
],
|
||||||
|
tags: 'example, prompt'
|
||||||
|
})
|
||||||
|
});
|
||||||
|
|
||||||
|
const result = await response.json();
|
||||||
|
console.log(result);
|
||||||
|
} catch (error) {
|
||||||
|
console.error('An error has occurred', error);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
addPromptsHandler();
|
||||||
|
```
|
||||||
|
|
||||||
|
### Go
|
||||||
|
|
||||||
|
```go
|
||||||
|
package main
|
||||||
|
|
||||||
|
import (
|
||||||
|
"bytes"
|
||||||
|
"encoding/json"
|
||||||
|
"fmt"
|
||||||
|
"net/http"
|
||||||
|
)
|
||||||
|
|
||||||
|
func main() {
|
||||||
|
url := "https://swarms.world/api/add-prompt"
|
||||||
|
payload := map[string]interface{}{
|
||||||
|
"name": "Example Prompt",
|
||||||
|
"prompt": "This is an example prompt from an API route.",
|
||||||
|
"description": "Description of the prompt.",
|
||||||
|
"useCases": []map[string]string{
|
||||||
|
{"title": "Use case 1", "description": "Description of use case 1"},
|
||||||
|
{"title": "Use case 2", "description": "Description of use case 2"},
|
||||||
|
},
|
||||||
|
"tags": "example, prompt",
|
||||||
|
}
|
||||||
|
jsonPayload, _ := json.Marshal(payload)
|
||||||
|
|
||||||
|
req, _ := http.NewRequest("POST", url, bytes.NewBuffer(jsonPayload))
|
||||||
|
req.Header.Set("Content-Type", "application/json")
|
||||||
|
req.Header.Set("Authorization", "Bearer {apiKey}")
|
||||||
|
|
||||||
|
client := &http.Client{}
|
||||||
|
resp, err := client.Do(req)
|
||||||
|
if err != nil {
|
||||||
|
fmt.Println("An error has occurred", err)
|
||||||
|
return
|
||||||
|
}
|
||||||
|
defer resp.Body.Close()
|
||||||
|
|
||||||
|
var result map[string]interface{}
|
||||||
|
json.NewDecoder(resp.Body).Decode(&result)
|
||||||
|
fmt.Println(result)
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
### cURL
|
||||||
|
|
||||||
|
```bash
|
||||||
|
curl -X POST https://swarms.world/api/add-prompt \
|
||||||
|
-H "Content-Type: application/json" \
|
||||||
|
-H "Authorization: Bearer {apiKey}" \
|
||||||
|
-d '{
|
||||||
|
"name": "Example Prompt",
|
||||||
|
"prompt": "This is an example prompt from an API route.",
|
||||||
|
"description": "Description of the prompt.",
|
||||||
|
"useCases": [
|
||||||
|
{ "title": "Use case 1", "description": "Description of use case 1" },
|
||||||
|
{ "title": "Use case 2", "description": "Description of use case 2" }
|
||||||
|
],
|
||||||
|
"tags": "example, prompt"
|
||||||
|
}'
|
||||||
|
```
|
||||||
|
|
||||||
|
## Response
|
||||||
|
|
||||||
|
The response will be a JSON object containing the result of the operation. Example response:
|
||||||
|
|
||||||
|
```json
|
||||||
|
{
|
||||||
|
"success": true,
|
||||||
|
"message": "Prompt added successfully",
|
||||||
|
"data": {
|
||||||
|
"id": "prompt_id",
|
||||||
|
"name": "Example Prompt",
|
||||||
|
"prompt": "This is an example prompt from an API route.",
|
||||||
|
"description": "Description of the prompt.",
|
||||||
|
"useCases": [
|
||||||
|
{ "title": "Use case 1", "description": "Description of use case 1" },
|
||||||
|
{ "title": "Use case 2", "description": "Description of use case 2" }
|
||||||
|
],
|
||||||
|
"tags": "example, prompt"
|
||||||
|
}
|
||||||
|
}
|
||||||
|
```
|
||||||
|
|
||||||
|
In case of an error, the response will contain an error message detailing the issue.
|
||||||
|
|
||||||
|
## Common Issues and Tips
|
||||||
|
|
||||||
|
- **Authentication Error:** Ensure that the `Authorization` header is correctly set with a valid API key.
|
||||||
|
- **Invalid JSON:** Make sure the request body is a valid JSON object.
|
||||||
|
- **Missing Required Fields:** Ensure that all required fields (`name`, `prompt`, `description`, `useCases`) are included in the request body.
|
||||||
|
- **Network Issues:** Verify network connectivity and endpoint URL.
|
||||||
|
|
||||||
|
## References and Resources
|
||||||
|
|
||||||
|
- [API Authentication Guide](https://swarms.world/docs/authentication)
|
||||||
|
- [JSON Structure Standards](https://json.org/)
|
||||||
|
- [Fetch API Documentation (Node.js)](https://developer.mozilla.org/en-US/docs/Web/API/Fetch_API)
|
||||||
|
- [Requests Library (Python)](https://requests.readthedocs.io/)
|
||||||
|
- [Net/HTTP Package (Go)](https://pkg.go.dev/net/http)
|
||||||
|
|
||||||
|
This comprehensive documentation provides all the necessary information to effectively use the `https://swarms.world/api/add-prompt` endpoint, including details on request parameters, example code snippets in multiple programming languages, and troubleshooting tips.
|
@ -0,0 +1,35 @@
|
|||||||
|
import os
|
||||||
|
from dotenv import load_dotenv
|
||||||
|
from swarms import GPT4VisionAPI, Agent
|
||||||
|
|
||||||
|
# Load the environment variables
|
||||||
|
load_dotenv()
|
||||||
|
|
||||||
|
|
||||||
|
# Initialize the language model
|
||||||
|
llm = GPT4VisionAPI(
|
||||||
|
openai_api_key=os.environ.get("OPENAI_API_KEY"),
|
||||||
|
max_tokens=500,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Initialize the task
|
||||||
|
task = (
|
||||||
|
"Analyze this image of an assembly line and identify any issues such as"
|
||||||
|
" misaligned parts, defects, or deviations from the standard assembly"
|
||||||
|
" process. IF there is anything unsafe in the image, explain why it is"
|
||||||
|
" unsafe and how it could be improved."
|
||||||
|
)
|
||||||
|
img = "assembly_line.jpg"
|
||||||
|
|
||||||
|
## Initialize the workflow
|
||||||
|
agent = Agent(
|
||||||
|
agent_name="Multi-ModalAgent",
|
||||||
|
llm=llm,
|
||||||
|
max_loops="auto",
|
||||||
|
autosave=True,
|
||||||
|
dashboard=True,
|
||||||
|
multi_modal=True,
|
||||||
|
)
|
||||||
|
|
||||||
|
# Run the workflow on a task
|
||||||
|
agent.run(task, img)
|
Loading…
Reference in new issue