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.",
"requirements": [
{"package": "numpy", "installation": "pip install numpy"},
{"package": "pandas", "installation": "pip install pandas"}
{"package": "pandas", "installation": "pip install pandas"},
],
"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 = {
"Authorization": f"Bearer {api_key}",
"Content-Type": "application/json"
"Content-Type": "application/json",
}
# Sending POST request

@ -5,7 +5,7 @@ import os
url = "https://swarms.world/api/add-prompt"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}"
"Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}",
}
data = {
@ -13,11 +13,17 @@ data = {
"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"}
{
"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))
print(response.json())
print(response.json())

@ -6,7 +6,7 @@ url = "https://swarms.world/api/edit-prompt"
headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}"
"Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}",
}
data = {
@ -15,11 +15,17 @@ data = {
"prompt": "This is an updated prompt from an API route.",
"description": "Updated description of the prompt.",
"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))
print(response.json())
print(response.json())

@ -1,25 +1,37 @@
import requests
# Fetch all prompts with optional 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:
raise Exception(f'Error: {response.status_code}, {response.text}')
raise Exception(f"Error: {response.status_code}, {response.text}")
data = response.json()
print(data)
# Fetch prompt by 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:
raise Exception(f'Error: {response.status_code}, {response.text}')
raise Exception(f"Error: {response.status_code}, {response.text}")
data = response.json()
print(data)
# Example usage
get_prompts({'name': 'example', 'tag': 'tag1,tag2', 'use_case': 'example', 'use_case_description': 'description'})
get_prompt_by_id('123')
get_prompts(
{
"name": "example",
"tag": "tag1,tag2",
"use_case": "example",
"use_case_description": "description",
}
)
get_prompt_by_id("123")

Loading…
Cancel
Save