yapr


Nameyapr JSON
Version 0.1.1 PyPI version JSON
download
home_pageNone
SummaryYet another prompt
upload_time2024-04-26 20:31:40
maintainerNone
docs_urlNone
authorPatrick Barker
requires_python<4.0,>=3.10
licenseApache 2.0
keywords
VCS
bugtrack_url
requirements No requirements were recorded.
Travis-CI No Travis.
coveralls test coverage No coveralls.
            # yapr

yapr (Yet Another Prompt)

## Installation

```sh
pip install yapr
```

## Usage

A complete chat example

```python
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
```

            

Raw data

            {
    "_id": null,
    "home_page": null,
    "name": "yapr",
    "maintainer": null,
    "docs_url": null,
    "requires_python": "<4.0,>=3.10",
    "maintainer_email": null,
    "keywords": null,
    "author": "Patrick Barker",
    "author_email": "patrickbarkerco@gmail.com",
    "download_url": "https://files.pythonhosted.org/packages/b0/23/d7550298fd29422016abf0e81a2b8373c25e48f2900d67e2b497ea6e760e/yapr-0.1.1.tar.gz",
    "platform": null,
    "description": "# yapr\n\nyapr (Yet Another Prompt)\n\n## Installation\n\n```sh\npip install yapr\n```\n\n## Usage\n\nA complete chat example\n\n```python\nfrom yapr import LLMProvider, RoleThread\n\n# Create an LLM provider from the API keys found in the current system env vars\nllm_provider = LLMProvider.from_env()\n\n# Create a new role based chat thread\nthread = RoleThread()\nthread.post(role=\"user\", msg=\"How are you?\")\n\n# Chat with the LLM, store the prompt data in the namespace \"foo\"\nresponse = llm_provider.chat(thread, namespace=\"foo\")\n\n# Add the response message to the thread\nthread.add_msg(response.msg)\n\n# Ask for a structured response\nfrom pydantic import BaseModel\n\nclass Foo(BaseModel):\n    bar: str\n    baz: int\n\nthread.post(role=\"user\", msg=\"Given the {...} can you return that in JSON?\")\n\n# Chat with the LLM, requiring the output be parsable into the Foo object\nresponse = llm_provider.chat(thread, namespace=\"foo\", response_schema=Foo)\n\n# Get the parsed response\nfoo_parsed = response.parsed\n```\n",
    "bugtrack_url": null,
    "license": "Apache 2.0",
    "summary": "Yet another prompt",
    "version": "0.1.1",
    "project_urls": null,
    "split_keywords": [],
    "urls": [
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "132dff72b9d7b202b1b30203a9f33d86b7c271c09c5d8f1736b3f5114486a22c",
                "md5": "23f64ee51161dfb83e5a0c5dea990810",
                "sha256": "ceb926e66118e153de68f7fca3e3b50c0bdeb0940d1f796f2d78c7b7561825e9"
            },
            "downloads": -1,
            "filename": "yapr-0.1.1-py3-none-any.whl",
            "has_sig": false,
            "md5_digest": "23f64ee51161dfb83e5a0c5dea990810",
            "packagetype": "bdist_wheel",
            "python_version": "py3",
            "requires_python": "<4.0,>=3.10",
            "size": 8941,
            "upload_time": "2024-04-26T20:31:38",
            "upload_time_iso_8601": "2024-04-26T20:31:38.990418Z",
            "url": "https://files.pythonhosted.org/packages/13/2d/ff72b9d7b202b1b30203a9f33d86b7c271c09c5d8f1736b3f5114486a22c/yapr-0.1.1-py3-none-any.whl",
            "yanked": false,
            "yanked_reason": null
        },
        {
            "comment_text": "",
            "digests": {
                "blake2b_256": "b023d7550298fd29422016abf0e81a2b8373c25e48f2900d67e2b497ea6e760e",
                "md5": "109a7173314a040d118ef722e84259ff",
                "sha256": "1cb0f54fca64a1a52f27def0e77ce35e13041741b306e1bff7537371ed181688"
            },
            "downloads": -1,
            "filename": "yapr-0.1.1.tar.gz",
            "has_sig": false,
            "md5_digest": "109a7173314a040d118ef722e84259ff",
            "packagetype": "sdist",
            "python_version": "source",
            "requires_python": "<4.0,>=3.10",
            "size": 7493,
            "upload_time": "2024-04-26T20:31:40",
            "upload_time_iso_8601": "2024-04-26T20:31:40.088300Z",
            "url": "https://files.pythonhosted.org/packages/b0/23/d7550298fd29422016abf0e81a2b8373c25e48f2900d67e2b497ea6e760e/yapr-0.1.1.tar.gz",
            "yanked": false,
            "yanked_reason": null
        }
    ],
    "upload_time": "2024-04-26 20:31:40",
    "github": false,
    "gitlab": false,
    "bitbucket": false,
    "codeberg": false,
    "lcname": "yapr"
}
        
Elapsed time: 0.21114s