Skip to content

Commit

Permalink
[CLEANUP]
Browse files Browse the repository at this point in the history
  • Loading branch information
Kye Gomez authored and Kye Gomez committed Aug 2, 2024
1 parent fb09c1f commit d3dd573
Show file tree
Hide file tree
Showing 4 changed files with 51 additions and 21 deletions.
16 changes: 11 additions & 5 deletions playground/swarms_marketplace/agents/create_agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,19 +15,25 @@
"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
Expand Down
16 changes: 11 additions & 5 deletions playground/swarms_marketplace/prompts_api/add_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,19 +5,25 @@
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 = {
"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"}
{
"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())
16 changes: 11 additions & 5 deletions playground/swarms_marketplace/prompts_api/edit_prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@

headers = {
"Content-Type": "application/json",
"Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}"
"Authorization": f"Bearer {os.getenv('SWARMS_API_KEY')}",
}

data = {
Expand All @@ -15,11 +15,17 @@
"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())
24 changes: 18 additions & 6 deletions playground/swarms_marketplace/prompts_api/query_prompts.py
Original file line number Diff line number Diff line change
@@ -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")

0 comments on commit d3dd573

Please sign in to comment.