diff --git a/playground/swarms_marketplace/agents/create_agent.py b/playground/swarms_marketplace/agents/create_agent.py index ea04c3a3b..8714c3945 100644 --- a/playground/swarms_marketplace/agents/create_agent.py +++ b/playground/swarms_marketplace/agents/create_agent.py @@ -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 diff --git a/playground/swarms_marketplace/prompts_api/add_prompt.py b/playground/swarms_marketplace/prompts_api/add_prompt.py index 74f222a4b..ecf13b75d 100644 --- a/playground/swarms_marketplace/prompts_api/add_prompt.py +++ b/playground/swarms_marketplace/prompts_api/add_prompt.py @@ -5,7 +5,7 @@ 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 @@ "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()) \ No newline at end of file +print(response.json()) diff --git a/playground/swarms_marketplace/prompts_api/edit_prompt.py b/playground/swarms_marketplace/prompts_api/edit_prompt.py index 7a7e6fca0..0f297e47d 100644 --- a/playground/swarms_marketplace/prompts_api/edit_prompt.py +++ b/playground/swarms_marketplace/prompts_api/edit_prompt.py @@ -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 = { @@ -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()) \ No newline at end of file +print(response.json()) diff --git a/playground/swarms_marketplace/prompts_api/query_prompts.py b/playground/swarms_marketplace/prompts_api/query_prompts.py index 0a9b418ae..e1475cbfb 100644 --- a/playground/swarms_marketplace/prompts_api/query_prompts.py +++ b/playground/swarms_marketplace/prompts_api/query_prompts.py @@ -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') \ No newline at end of file +get_prompts( + { + "name": "example", + "tag": "tag1,tag2", + "use_case": "example", + "use_case_description": "description", + } +) +get_prompt_by_id("123")