# 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:
```python
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:
```python
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
Raw data
{
"_id": null,
"home_page": "https://github.com/skorokithakis/ez-openai/",
"name": "ez-openai",
"maintainer": "",
"docs_url": null,
"requires_python": ">=3.7.1",
"maintainer_email": "",
"keywords": "",
"author": "Stavros Korokithakis",
"author_email": "hi@stavros.io",
"download_url": "https://files.pythonhosted.org/packages/77/cf/cd450d22615f967f666f67bee198b92bdc6efd1d2f829a806257ffffdc90/ez_openai-0.0.1.tar.gz",
"platform": null,
"description": "# Ez OpenAI\n\nMy opinion of the `openai` Python library is best illustrated by the fact that if you\nask ChatGPT about it, it will usually hallucinate a more reasonable API. So, I wrote\nthis library, because if I had to manually poll for a tool update again I would\ninstigate the robot uprising myself.\n\n\n## Installation\n\nRun this somewhere:\n\n```\npip install ez-openai\n```\n\n\n## Usage\n\n### Basic usage\n\nUsing Ez OpenAI is (hopefully) straightforward, otherwise I've failed at the one thing\nI've set out to make:\n\n```python\nfrom ez_openai import Assistant\n\n# To use a previously-created assistant:\nass = Assistant(\"asst_someassistantid\")\n\n# To create a new one:\nass = Assistant.create(\n name=\"Weatherperson\",\n instructions=\"You are a helpful weatherperson.\",\n)\n\n# You can store the ID for later.\nassistant_id = ass.id\n\n# Delete it when you're done.\nass.delete()\n```\n\n### Function calling\n\nNo more wizardry, just plain Python functions:\n\n```python\nfrom ez_openai import Assistant, openai_function\n\n@openai_function(descriptions={\n \"city\": \"The city to get the weather for.\",\n \"unit\": \"The temperature unit , either `c` or `f`.\",\n })\ndef get_weather(city: str, unit: str):\n # ...do some magic here to get the weather...\n print(f\"I'm getting the weather for {city} woooooo\")\n return {\"temperature\": 26, \"humidity\": \"60%\"}\n\n\nass = Assistant.create(\n name=\"Weatherperson\",\n system=\"You are a helpful weatherperson.\",\n functions=[get_weather]\n)\n\nconversation = ass.conversation.create()\n\n# Similarly, you can store the ID to fetch later:\nold_conversation = ass.conversation.get(old_conversation.id)\n\n# The library will handle all the background function calls itself:\nconversation.ask(\"Hi, what's the weather like in Thessaloniki and Athens right now?\")\n> I'm getting the weather for Thessaloniki woooooo\n> I'm getting the weather for Athens woooooo\n> \"The weather today in both Thessaloniki and Athens is quite similar, with a\n temperature of 26\u00b0C and a humidity level at 60%. Enjoy a pleasant and comfortable\n day!\"\n```\n\ngg ez\n\n",
"bugtrack_url": null,
"license": "AGPL-3.0-or-later",
"summary": "A more reasonable OpenAI API.",
"version": "0.0.1",
"project_urls": {
"Homepage": "https://github.com/skorokithakis/ez-openai/",
"Repository": "https://github.com/skorokithakis/ez-openai/"
},
"split_keywords": [],
"urls": [
{
"comment_text": "",
"digests": {
"blake2b_256": "b1e9b3112eac445cc94385700db096973c7be2111ca5640fd97f3f8ebe502a6e",
"md5": "7ddb0b6b01e3901322dd4b06f162c3b4",
"sha256": "15f68fbf9b098b3adcd448988ee1fc1111b59f7e96a8ff637ed4ee566eb182c9"
},
"downloads": -1,
"filename": "ez_openai-0.0.1-py3-none-any.whl",
"has_sig": false,
"md5_digest": "7ddb0b6b01e3901322dd4b06f162c3b4",
"packagetype": "bdist_wheel",
"python_version": "py3",
"requires_python": ">=3.7.1",
"size": 16259,
"upload_time": "2023-12-10T16:02:38",
"upload_time_iso_8601": "2023-12-10T16:02:38.008064Z",
"url": "https://files.pythonhosted.org/packages/b1/e9/b3112eac445cc94385700db096973c7be2111ca5640fd97f3f8ebe502a6e/ez_openai-0.0.1-py3-none-any.whl",
"yanked": false,
"yanked_reason": null
},
{
"comment_text": "",
"digests": {
"blake2b_256": "77cfcd450d22615f967f666f67bee198b92bdc6efd1d2f829a806257ffffdc90",
"md5": "ffa0f0d434e52f2479d7bbd5b9b4fb3b",
"sha256": "91eff17fa3ba49e9453095709b87e259c76b866ce3a8a33c697ffee500c9ba29"
},
"downloads": -1,
"filename": "ez_openai-0.0.1.tar.gz",
"has_sig": false,
"md5_digest": "ffa0f0d434e52f2479d7bbd5b9b4fb3b",
"packagetype": "sdist",
"python_version": "source",
"requires_python": ">=3.7.1",
"size": 15566,
"upload_time": "2023-12-10T16:02:39",
"upload_time_iso_8601": "2023-12-10T16:02:39.560313Z",
"url": "https://files.pythonhosted.org/packages/77/cf/cd450d22615f967f666f67bee198b92bdc6efd1d2f829a806257ffffdc90/ez_openai-0.0.1.tar.gz",
"yanked": false,
"yanked_reason": null
}
],
"upload_time": "2023-12-10 16:02:39",
"github": true,
"gitlab": false,
"bitbucket": false,
"codeberg": false,
"github_user": "skorokithakis",
"github_project": "ez-openai",
"travis_ci": false,
"coveralls": false,
"github_actions": false,
"lcname": "ez-openai"
}