Skip to main content

A more reasonable OpenAI API.

Project description

Easy OpenAI

My opinion of the openai Python library is best illustrated by the fact that, if you ask ChatGPT about it, it will usually hallucinate a more reasonable API. So, I wrote this library, because if I had to manually poll for a tool update again I would instigate the robot uprising myself.

Installation

Run this somewhere:

pip install easy-openai

Usage

Basic usage

Using Easy OpenAI is (hopefully) straightforward, otherwise I've failed at the one thing I've set out to make:

from easy_openai import Assistant

# To use a previously-created assistant:
ass = Assistant("asst_someassistantid)

# To create a new one:
ass = Assistant.create(system="Some system instructions.")

# You can store the ID for later.
assistant_id = ass.id

# Delete it when you're done.
ass.delete()

Function calling

No more wizardry, just plain Python functions:

from easy_openai import Assistant, openai_function

@openai_function(descriptions={
        "city": "The city to get the weather for.",
        "unit": "The temperature unit , either `c` or `f`.",
    })
def get_weather(city: str, unit: str):
    # ...do some magic here to get the weather...
    print("I'm getting the weather wooooooooo")
    return {"temperature": 26, "unit": "c"}


ass = Assistant.create(
    system="You are a helpful weatherperson.",
    functions=[get_weather]
)

# The library will handle all the background function calls itself:
ass.ask("Hi, what's the weather like in Thessaloniki right now?")
> I'm getting the weather wooooooooo
> "It's 26 degrees centigrade right now in Thessaloniki."

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

ez_openai-0.0.0.tar.gz (13.6 kB view details)

Uploaded Source

Built Distribution

ez_openai-0.0.0-py3-none-any.whl (13.9 kB view details)

Uploaded Python 3

File details

Details for the file ez_openai-0.0.0.tar.gz.

File metadata

  • Download URL: ez_openai-0.0.0.tar.gz
  • Upload date:
  • Size: 13.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ez_openai-0.0.0.tar.gz
Algorithm Hash digest
SHA256 47c91d94f33a71e36cd51c33270e7ce750d2a39c0c2df7d37f6b229ffe897a3e
MD5 30dca1021f6f7456aa885d1a61113257
BLAKE2b-256 d30f863659440f3acf8a12bbe66a334d266f7d91bdf2c30fa88496623f72a7ba

See more details on using hashes here.

File details

Details for the file ez_openai-0.0.0-py3-none-any.whl.

File metadata

  • Download URL: ez_openai-0.0.0-py3-none-any.whl
  • Upload date:
  • Size: 13.9 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/4.0.2 CPython/3.10.12

File hashes

Hashes for ez_openai-0.0.0-py3-none-any.whl
Algorithm Hash digest
SHA256 d9e6e824e6f76ad0098e327b4fe7dfad07f97d0a03a43413a4cb3f554d7f9c28
MD5 e12d15e3b5ad100f5cb3197a169ac823
BLAKE2b-256 a55bbd6bf793d3a832c2fca319fcc217844708a8abce5be351de645e89214c93

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