You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
swarms/examples/swarms_marketplace/prompts_api/query_prompts.py

42 lines
857 B

5 months ago
import requests
# Fetch all prompts with optional filters
def get_prompts(filters):
response = requests.get(
"https://swarms.world/get-prompts", params=filters
)
if response.status_code != 200:
4 months ago
raise Exception(
f"Error: {response.status_code}, {response.text}"
)
5 months ago
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}")
if response.status_code != 200:
4 months ago
raise Exception(
f"Error: {response.status_code}, {response.text}"
)
5 months ago
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")