Skip to main content

PyroPrompts Client for Python

Project description

pyroprompts-client

PyroPrompts client for python! PyroPrompts is a platform enabling easier exchange and automation of AI Prompts, Snippets and Workflows. This client library assists in token management and abstracts the HTTP requests to make it easy to interact with the system.

Learn more at https://pyroprompts.com.

Install

pip install pyroprompts-client

Docs

PyroPromptsClient

Create an instance of the PyroPromptsClient class with your credentials and then you may issue commands with that client instance.

Note: Might raise a pyroprompts_client.PyroPromptsError if PyroPrompts rejects the request

Note: Might raise a pyroprompts_client.PyroPromptsTimeoutError if the request times out

init

from pyroprompts_client import PyroPromptsClient,
client = PyroPromptsClient(
    client_id="1234",
    client_secret="567890",
)

workflow_trigger

see documentation

# get all project snippets
client.workflow_trigger({
    "account_id": "YOUR_ACCOUNT_ID",
    "workflow_id": "WORKFLOW_ID",
    "workflow_form_params": {"param_1": "value_1"}
})

get_workflow_executions

see documentation

# get all project snippets
client.get_workflow_executions({
    "workflow_id": "abcd-1234-cdfg-abcdefg"
})

which returns:

{
    "count":1,
    "next":null,
    "previous":null,
    "results":[
        {
            "id":"1a7bae4f-f121-432b-b44e-abcdefg",
            "status":"complete",
            "status_message":null,
            "created_date":"2024-07-03T15:51:08.905236Z",
            "workflow_id":"ca00d56b-79bc-42b1-8e99-abcdefg",
            "result":"The response is in here",
            "form_params":null
        }
    ]
}

get_project_snippets

see documentation

# get all project snippets
client.get_project_snippets()
# pass some filters as a dict of query parameters (see documentation)
client.get_project_snippets({
    "project_id": "1234-56-78-9012",
    "created_date__gt": "2023-01-01",
    "limit": 1,
})

which returns:

{
    "count": 2,
    "next": null,
    "previous": null,
    "results": [
        {
            "id": "3d1daced-ce1d-4232-9b39-abcdefg",
            "name": "Snippet1",
            "description": null,
            "content": "Content of Snippet1",
            "project_id": "e95d56f8-72d1-4b13-bc5d-abcdefg",
            "deleted": 0,
            "created_by": "454517f4-a97e-45a7-8088-abcdefg",
            "created_date": "2024-07-03T15:38:14.387627Z",
            "updated_date": "2024-07-03T15:38:14.387645Z"
        },
        {
            "id": "f54049ee-266f-4fd7-a2f6-abcdefg",
            "name": "Snippet2",
            "description": null,
            "content": "Content of Snippet2",
            "project_id": "e95d56f8-72d1-4b13-bc5d-abcdefg",
            "deleted": 0,
            "created_by": "454517f4-a97e-45a7-8088-abcdefg",
            "created_date": "2024-07-03T15:45:49.697119Z",
            "updated_date": "2024-07-03T15:51:04.722434Z"
        },
        
    ]
}

logging

To get visibility into logged events, override the log method and log however your app needs to log:

class CustomPyroPromptsClass(PyroPromptsClient):
    def log(self, level, msg, **log_variables):
        print(f"[{level}] {msg}", log_variables)
        

client = CustomPyroPromptsClass(client_id, client_secret)

Example

from pyroprompts import PyroPromptsClient, PyroPromptsError, PyroPromptsTimeoutError

my_client = PyroPromptsClient("1234", "56-789")
try:
    results = my_client.get_project_snippets()
    print(results)
except PyroPromptsError:
    print("PyroPrompts failure")
except PyroPromptsTimeoutError:
    print("PyroPrompts timed out")

Common Commands:

Black Formatting

$ black pyroprompts_client --config pyroprompts_client.toml

Build

$ python3 setup.py sdist

Pypi Distribution

$ python3 -m twine upload dist/*

License

PyroPrompts Client is MIT licensed.

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

pyroprompts-client-0.1.2.tar.gz (5.4 kB view details)

Uploaded Source

File details

Details for the file pyroprompts-client-0.1.2.tar.gz.

File metadata

  • Download URL: pyroprompts-client-0.1.2.tar.gz
  • Upload date:
  • Size: 5.4 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/5.1.1 CPython/3.10.13

File hashes

Hashes for pyroprompts-client-0.1.2.tar.gz
Algorithm Hash digest
SHA256 4e029c1be51fbf62c2eaf340286ebcacbdf705c9009fb188a90dbd5075b09467
MD5 a54ed6eef1a2f735cc4da485958ad8a4
BLAKE2b-256 efb9be01eb641cfd37259334dbe06c414846a15a8fa724ad3cef862a75bfaaa2

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page