Coder Social home page Coder Social logo

openai's Introduction

openai crates.io Rust workflow

An unofficial Rust library for the OpenAI API.

Note

The ownership of the openai package on crates.io has been transfered to me, Valentine Briese (not the previous owner). This is an entirely different project than the one that was on crates.io as openai previously!

Warning

Currently in alpha, I wouldn't recommend using in any production applications. See Implementation Progress.

Core Principles

  • Instead of accessing all functions as methods on a single client-like structure, functions should be accessed from their own modules.
  • Environmental variables should be the prioitized method of authentication, but you shouldn't be forced to do things this way. (Currently, you kind of are, because the API key is needed during compile-time.)
  • This is a LIBRARY, not a WRAPPER! The goal here isn't to just give some basic wrapper functions for making HTTP requests, it's to "rust-ify" things. We want to create the illusion that the OpenAI API was made in Rust first!
  • What is this, C? No, it's Rust! We follow the object-oriented paradigm, not the procedural one. What this mainly means is less create_completion(), more Completion::create().

Examples

I'm still working on making examples in the examples directory. Currently, there are examples for the completions module and the chat module. For other modules, you can look at the tests submodules for some reference.

Examples come slowly because this project, in its current state, changes very quickly, and it's not fun making sure all examples accurately reflect the latest version. But, they are coming, don't worry!

Troubleshooting

environment variable OPENAI_KEY should be defined

An error you will likely run into, and a hopefully pretty self-explanatory one. For the library to even build, you must have an environment variabled named OPENAI_KEY which is set to, you guessed it, your OpenAI API key. Without your API key, this library can't do anything. In fact, the library won't build without it because at compile-time it uses your key to fetch all available models and generate the ModelID enumerator.

In a development environment, this can be best resolved by created a .env file in the root of your project with the following contents:

OPENAI_KEY=put-your-api-key-here

Then, you need to load the contents of your .env file when your program starts. For this, I recommend a crate such as dotenvy.

Implementation Progress

██████████ Models

████████░░ Completions

████████░░ Chat

██████████ Edits

░░░░░░░░░░ Images

█████████░ Embeddings

░░░░░░░░░░ Audio

░░░░░░░░░░ Files

░░░░░░░░░░ Fine-tunes

░░░░░░░░░░ Moderations

openai's People

Contributors

valentinegb avatar dependabot[bot] 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.