No project description provided
Project description
Lazy OpenAI
Lazy OpenAI is a Python library that simplifies interaction with OpenAI's API. It provides easy-to-use functions to generate text and structured outputs using Pydantic models.
Installation
To install Lazy OpenAI, run the following command:
pip install lazyopenai
Usage
from lazyopenai import generate
print(generate("Hi"))
Structured Outputs
from pydantic import BaseModel
from rich import print
from lazyopenai import generate
class Step(BaseModel):
explanation: str
output: str
class MathReasoning(BaseModel):
steps: list[Step]
final_answer: str
# https://platform.openai.com/docs/guides/structured-outputs?context=ex1#chain-of-thought
resp = generate("how can I solve 8x + 7 = -23", response_format=MathReasoning)
print(resp)
Function Calling
from pydantic import Field
from lazyopenai import generate
from lazyopenai.types import LazyTool
class AddNumbers(LazyTool):
a: float = Field(..., description="First number to add")
b: float = Field(..., description="Second number to add")
def __call__(self) -> float:
print("function called")
return self.a + self.b
resp = generate(
"100 + 10 = ?",
tools=[AddNumbers],
)
print(resp)
TODO
- Function calling
- Memory
- Async
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 Distributions
No source distribution files available for this release.See tutorial on generating distribution archives.
Built Distribution
File details
Details for the file lazyopenai-0.1.1-py3-none-any.whl
.
File metadata
- Download URL: lazyopenai-0.1.1-py3-none-any.whl
- Upload date:
- Size: 6.4 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: uv/0.5.2
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | ab5045cf39c122dfd53ada7748bd11ed2a9c5b4c04abdea820ed1c7a729425b0 |
|
MD5 | ee8bcf20ef857cae71a52e1db1031592 |
|
BLAKE2b-256 | d312a2a89ed4ee5ea4961c46778933a3345f0e952ddaa8400f9585d066242fd7 |