Skip to main content

No project description provided

Project description

Prompt Hub Python Client

PyPI - Version Tests

A simple client to fetch prompts from Prompt Hub using its REST API.

Usage

First step is obviously installation:

pip install prompthub-py

Then you can import Prompt, that class is all you're going to need.

import prompthub

# To load from a JSON file
p = prompthub.from_json("./path/to/my/prompt.json")


# To load from a YAML file
p = prompthub.from_yaml("./path/to/my/prompt.yaml")


# To load from Prompt Hub
p = prompthub.fetch("deepset/question-answering")

# To get the prompt text (see Prompt class)
p.text

If you want to use a different Prompt Hub you must set the PROMPTHUB_MAIN_ENDPOINT environment variable to your main endpoint.

If the environment variable is not set the default api.prompthub.deepset.ai will be used.

Testing

To run tests locally first install dev dependencies, we use poetry to manage our dependencies:

poetry install --with=dev

Run Prompt Hub locally with a set of fake prompts:

docker run -p80:80 --volume $PWD/test/fake_prompts:/prompts deepset/prompthub

And then run tests:

poetry run pytest test

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

prompthub_py-4.0.0.tar.gz (6.1 kB view hashes)

Uploaded Source

Built Distribution

prompthub_py-4.0.0-py3-none-any.whl (6.9 kB view hashes)

Uploaded Python 3

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