-
-
Notifications
You must be signed in to change notification settings - Fork 255
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Kye Gomez
authored and
Kye Gomez
committed
Aug 2, 2024
1 parent
fb09c1f
commit d3dd573
Showing
4 changed files
with
51 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
24 changes: 18 additions & 6 deletions
24
playground/swarms_marketplace/prompts_api/query_prompts.py
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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") |