Skip to main content

A more reasonable OpenAI API.

Project description

Ez 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 ez-openai

Usage

Basic usage

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

from ez_openai import Assistant

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

# To create a new one:
ass = Assistant.create(
    name="Weatherperson",
    instructions="You are a helpful weatherperson.",
)

# 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 ez_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(f"I'm getting the weather for {city} woooooo")
    return {"temperature": 26, "humidity": "60%"}


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

conversation = ass.conversation.create()

# Similarly, you can store the ID to fetch later:
old_conversation = ass.conversation.get(old_conversation.id)

# The library will handle all the background function calls itself:
conversation.ask("Hi, what's the weather like in Thessaloniki and Athens right now?")
> I'm getting the weather for Thessaloniki woooooo
> I'm getting the weather for Athens woooooo
> "The weather today in both Thessaloniki and Athens is quite similar, with a
   temperature of 26°C and a humidity level at 60%. Enjoy a pleasant and comfortable
   day!"

gg ez

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.1.tar.gz (15.6 kB view details)

Uploaded Source

Built Distribution

ez_openai-0.0.1-py3-none-any.whl (16.3 kB view details)

Uploaded Python 3

File details

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

File metadata

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

File hashes

Hashes for ez_openai-0.0.1.tar.gz
Algorithm Hash digest
SHA256 91eff17fa3ba49e9453095709b87e259c76b866ce3a8a33c697ffee500c9ba29
MD5 ffa0f0d434e52f2479d7bbd5b9b4fb3b
BLAKE2b-256 77cfcd450d22615f967f666f67bee198b92bdc6efd1d2f829a806257ffffdc90

See more details on using hashes here.

File details

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

File metadata

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

File hashes

Hashes for ez_openai-0.0.1-py3-none-any.whl
Algorithm Hash digest
SHA256 15f68fbf9b098b3adcd448988ee1fc1111b59f7e96a8ff637ed4ee566eb182c9
MD5 7ddb0b6b01e3901322dd4b06f162c3b4
BLAKE2b-256 b1e9b3112eac445cc94385700db096973c7be2111ca5640fd97f3f8ebe502a6e

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