Git Product home page Git Product logo

uopenai's Introduction

uOpenAI

uOpenAI is a lightweight, asynchronous Python library designed to interact with the OpenAI API. Leveraging the power of httpx for async HTTP requests and pydantic for data validation and settings management, it aims to provide a seamless and efficient way to access OpenAI's capabilities in modern async Python applications.

Features

  • Fully Asynchronous: Built from the ground up for asyncio compatibility.
  • Type-Hinted: Ensures robust code through comprehensive type annotations.
  • Simple and Intuitive: A straightforward API to access OpenAI's features with minimal boilerplate.

Installation

To install uOpenAI, run:

pip install uopenai

Quick Start

Here's a quick example to get you started:

import asyncio
from uopenai import OpenAI, Message

async def main():
    api = OpenAI("your-api-key")
    # Complete a prompt with options
    res = await api.complete([Message("system", "You are a chat bot"), Message("user", "What’s on your mind?")], max_tokens=50)
    print(res.choices[0].message.content)

    # easy version

    res = await api.easy_complete("What’s on your mind?", "You are a chat bot")

    res = await api.easy_complete("What’s on your mind?",
                    "You are a JSON answering machine, give the answer in JSON only.", json=True)

if __name__ == "__main__":
    asyncio.run(main())

Replace "your-api-key" with your actual OpenAI API key.

Requirements

  • Python 3.7+
  • OpenAI API key
  • httpx
  • pydantic

Contributing

Contributions are welcome! Feel free to open an issue or submit a pull request.

License

uOpenAI is released under the The Unlicense. See the LICENSE file for more details.

uopenai's People

Contributors

bobuk avatar

Stargazers

Aliaksei avatar Ilya Beketov avatar Evgeny avatar Maksim Panin avatar  avatar Yury Marozau avatar Gaiar Baimuratov avatar Sasha Savchuk avatar Egor avatar

Watchers

 avatar Kostas Georgiou avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.