parent
fb09c1f596
commit
d3dd573659
@ -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")
|
||||
|
Loading…
Reference in new issue