yapr
yapr (Yet Another Prompt)
Installation
pip install yapr
Usage
A complete chat example
from yapr import LLMProvider, RoleThread
# Create an LLM provider from the API keys found in the current system env vars
llm_provider = LLMProvider.from_env()
# Create a new role based chat thread
thread = RoleThread()
thread.post(role="user", msg="How are you?")
# Chat with the LLM, store the prompt data in the namespace "foo"
response = llm_provider.chat(thread, namespace="foo")
# Add the response message to the thread
thread.add_msg(response.msg)
# Ask for a structured response
from pydantic import BaseModel
class Foo(BaseModel):
bar: str
baz: int
thread.post(role="user", msg="Given the {...} can you return that in JSON?")
# Chat with the LLM, requiring the output be parsable into the Foo object
response = llm_provider.chat(thread, namespace="foo", response_schema=Foo)
# Get the parsed response
foo_parsed = response.parsed
Metadata
Release files for yapr 0.1.1
For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.
Source distribution (sdist)
| File | Size | Uploaded | |
|---|---|---|---|
| yapr-0.1.1.tar.gz | 7.5 kB | Details |
Built distribution (wheel)
| File | Interpreter | ABI | Platform | Reset |
|---|---|---|---|---|
| yapr-0.1.1-py3-none-any.whl | Python 3 | none | any | Details |
Total release size: 16.4 kB
Release files / yapr-0.1.1.tar.gz
| Download URL | yapr-0.1.1.tar.gz |
|---|---|
| Size | 7.5 kB |
| Tags | Source |
|
SHA-256 checksum How to use checksums |
1cb0f54fca64a1a52f27def0e77ce35e13041741b306e1bff7537371ed181688
|
|
BLAKE2b-256 checksum How to use checksums |
b023d7550298fd29422016abf0e81a2b8373c25e48f2900d67e2b497ea6e760e
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.1 Darwin/22.6.0
|
Release files / yapr-0.1.1-py3-none-any.whl
| Download URL | yapr-0.1.1-py3-none-any.whl |
|---|---|
| Size | 8.9 kB |
| Tags | Python 3 |
|
SHA-256 checksum How to use checksums |
ceb926e66118e153de68f7fca3e3b50c0bdeb0940d1f796f2d78c7b7561825e9
|
|
BLAKE2b-256 checksum How to use checksums |
132dff72b9d7b202b1b30203a9f33d86b7c271c09c5d8f1736b3f5114486a22c
|
| Upload date | |
|
Uploaded using Trusted Publishing? What is trusted publishing? |
No |
| Uploaded via |
poetry/1.5.1 CPython/3.10.1 Darwin/22.6.0
|