parent
fb09c1f596
commit
d3dd573659
@ -1,25 +1,37 @@
|
|||||||
import requests
|
import requests
|
||||||
|
|
||||||
|
|
||||||
# Fetch all prompts with optional filters
|
# Fetch all prompts with optional filters
|
||||||
def get_prompts(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:
|
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()
|
data = response.json()
|
||||||
print(data)
|
print(data)
|
||||||
|
|
||||||
|
|
||||||
# Fetch prompt by ID
|
# Fetch prompt by ID
|
||||||
def get_prompt_by_id(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:
|
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()
|
data = response.json()
|
||||||
print(data)
|
print(data)
|
||||||
|
|
||||||
|
|
||||||
# Example usage
|
# Example usage
|
||||||
get_prompts({'name': 'example', 'tag': 'tag1,tag2', 'use_case': 'example', 'use_case_description': 'description'})
|
get_prompts(
|
||||||
get_prompt_by_id('123')
|
{
|
||||||
|
"name": "example",
|
||||||
|
"tag": "tag1,tag2",
|
||||||
|
"use_case": "example",
|
||||||
|
"use_case_description": "description",
|
||||||
|
}
|
||||||
|
)
|
||||||
|
get_prompt_by_id("123")
|
||||||
|
Loading…
Reference in new issue