prompthub-py

所属分类:自然语言处理
开发工具:Python
文件大小:25KB
下载次数:0
上传日期:2023-06-01 09:13:04
上 传 者sh-1993
说明:  提示中心py,,
(prompthub-py,,)

文件列表:
LICENSE (11343, 2023-06-01)
poetry.lock (44568, 2023-06-01)
prompthub (0, 2023-06-01)
prompthub\__init__.py (65, 2023-06-01)
prompthub\prompt.py (1880, 2023-06-01)
pyproject.toml (439, 2023-06-01)
test (0, 2023-06-01)
test\conftest.py (180, 2023-06-01)
test\fake_prompts (0, 2023-06-01)
test\fake_prompts\fake_prompt.json (337, 2023-06-01)
test\fake_prompts\fake_prompt.yml (300, 2023-06-01)
test\test_prompt.py (2099, 2023-06-01)

# Prompt Hub Python Client [![PyPI - Version][pypi-badge]][pypi-project] [![Tests][tests-badge]][tests-workflow] A simple client to fetch prompts from [Prompt Hub][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. ```python 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`][python-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 ``` [pypi-badge]: https://img.shields.io/pypi/v/prompthub-py.svg [pypi-project]: https://pypi.org/project/prompthub-py [prompt-hub]: https://prompthub.deepset.ai/ [python-poetry]: https://python-poetry.org/ [tests-badge]: https://github.com/deepset-ai/prompthub-py/actions/workflows/test.yml/badge.svg [tests-workflow]: https://github.com/deepset-ai/prompthub-py/actions/workflows/test.yml

近期下载者

相关文件


收藏者