Skip to main content

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 datetime import datetime

from pydantic import BaseModel

from lazyopenai import generate


class GetCurrentTime(BaseModel):
    def call(self) -> str:
        return datetime.now().strftime("%Y-%m-%d %H:%M:%S")


resp = generate("What is the current time?", tools=[GetCurrentTime])
print(resp)

TODO

  • Function calling
  • Memory
  • Async

Project details


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

lazyopenai-0.0.8-py3-none-any.whl (5.2 kB view details)

Uploaded Python 3

File details

Details for the file lazyopenai-0.0.8-py3-none-any.whl.

File metadata

File hashes

Hashes for lazyopenai-0.0.8-py3-none-any.whl
Algorithm Hash digest
SHA256 59f674d5383c2a8b591d576acd47708189e3383679c6982881770eb4e2c38248
MD5 4511f5feb4ac3c185cc8ca85c0280ffb
BLAKE2b-256 fa7f512d6e09d6ca88a8ba851fb6ec43ff1634ec4e0e0f947f75e0a5db196027

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page