pull/552/head
Kye Gomez 5 months ago
parent fb09c1f596
commit d3dd573659

@ -15,19 +15,25 @@ agent_data = {
"description": "This is a sample agent description.", "description": "This is a sample agent description.",
"requirements": [ "requirements": [
{"package": "numpy", "installation": "pip install numpy"}, {"package": "numpy", "installation": "pip install numpy"},
{"package": "pandas", "installation": "pip install pandas"} {"package": "pandas", "installation": "pip install pandas"},
], ],
"useCases": [ "useCases": [
{"title": "Data Analysis", "description": "Analyzes data using advanced algorithms."}, {
{"title": "Prediction", "description": "Predicts outcomes based on data."} "title": "Data Analysis",
"description": "Analyzes data using advanced algorithms.",
},
{
"title": "Prediction",
"description": "Predicts outcomes based on data.",
},
], ],
"tags": "data,analysis,prediction" "tags": "data,analysis,prediction",
} }
# Headers # Headers
headers = { headers = {
"Authorization": f"Bearer {api_key}", "Authorization": f"Bearer {api_key}",
"Content-Type": "application/json" "Content-Type": "application/json",
} }
# Sending POST request # Sending POST request

@ -5,7 +5,7 @@ import os
url = "https://swarms.world/api/add-prompt" url = "https://swarms.world/api/add-prompt"
headers = { headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}" "Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}",
} }
data = { data = {
@ -13,11 +13,17 @@ data = {
"prompt": "This is an example prompt from an API route.", "prompt": "This is an example prompt from an API route.",
"description": "Description of the prompt.", "description": "Description of the prompt.",
"useCases": [ "useCases": [
{"title": "Use case 1", "description": "Description of use case 1"}, {
{"title": "Use case 2", "description": "Description of use case 2"} "title": "Use case 1",
"description": "Description of use case 1",
},
{
"title": "Use case 2",
"description": "Description of use case 2",
},
], ],
"tags": "example, prompt" "tags": "example, prompt",
} }
response = requests.post(url, headers=headers, data=json.dumps(data)) response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json()) print(response.json())

@ -6,7 +6,7 @@ url = "https://swarms.world/api/edit-prompt"
headers = { headers = {
"Content-Type": "application/json", "Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}" "Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}",
} }
data = { data = {
@ -15,11 +15,17 @@ data = {
"prompt": "This is an updated prompt from an API route.", "prompt": "This is an updated prompt from an API route.",
"description": "Updated description of the prompt.", "description": "Updated description of the prompt.",
"useCases": [ "useCases": [
{"title": "Updated use case 1", "description": "Updated description of use case 1"}, {
{"title": "Updated use case 2", "description": "Updated description of use case 2"} "title": "Updated use case 1",
"description": "Updated description of use case 1",
},
{
"title": "Updated use case 2",
"description": "Updated description of use case 2",
},
], ],
"tags": "updated, prompt" "tags": "updated, prompt",
} }
response = requests.post(url, headers=headers, data=json.dumps(data)) response = requests.post(url, headers=headers, data=json.dumps(data))
print(response.json()) print(response.json())

@ -1,25 +1,37 @@
import requests import requests
# Fetch all prompts with optional filters # Fetch all prompts with optional filters
def get_prompts(filters): def get_prompts(filters):
response = requests.get('https://swarms.world/get-prompts', params=filters) response = requests.get(
"https://swarms.world/get-prompts", params=filters
)
if response.status_code != 200: if response.status_code != 200:
raise Exception(f'Error: {response.status_code}, {response.text}') raise Exception(f"Error: {response.status_code}, {response.text}")
data = response.json() data = response.json()
print(data) print(data)
# Fetch prompt by ID # Fetch prompt by ID
def get_prompt_by_id(id): def get_prompt_by_id(id):
response = requests.get(f'https://swarms.world/get-prompts/{id}') response = requests.get(f"https://swarms.world/get-prompts/{id}")
if response.status_code != 200: if response.status_code != 200:
raise Exception(f'Error: {response.status_code}, {response.text}') raise Exception(f"Error: {response.status_code}, {response.text}")
data = response.json() data = response.json()
print(data) print(data)
# Example usage # Example usage
get_prompts({'name': 'example', 'tag': 'tag1,tag2', 'use_case': 'example', 'use_case_description': 'description'}) get_prompts(
get_prompt_by_id('123') {
"name": "example",
"tag": "tag1,tag2",
"use_case": "example",
"use_case_description": "description",
}
)
get_prompt_by_id("123")

Loading…
Cancel
Save