Yet another prompt
Project description
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
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
yapr-0.1.1.tar.gz
(7.5 kB
view details)
Built Distribution
yapr-0.1.1-py3-none-any.whl
(8.9 kB
view details)
File details
Details for the file yapr-0.1.1.tar.gz
.
File metadata
- Download URL: yapr-0.1.1.tar.gz
- Upload date:
- Size: 7.5 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.1 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 1cb0f54fca64a1a52f27def0e77ce35e13041741b306e1bff7537371ed181688 |
|
MD5 | 109a7173314a040d118ef722e84259ff |
|
BLAKE2b-256 | b023d7550298fd29422016abf0e81a2b8373c25e48f2900d67e2b497ea6e760e |
File details
Details for the file yapr-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: yapr-0.1.1-py3-none-any.whl
- Upload date:
- Size: 8.9 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: poetry/1.5.1 CPython/3.10.1 Darwin/22.6.0
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ceb926e66118e153de68f7fca3e3b50c0bdeb0940d1f796f2d78c7b7561825e9 |
|
MD5 | 23f64ee51161dfb83e5a0c5dea990810 |
|
BLAKE2b-256 | 132dff72b9d7b202b1b30203a9f33d86b7c271c09c5d8f1736b3f5114486a22c |