diff --git a/README.md b/README.md index 94adc06..ddcb75a 100644 --- a/README.md +++ b/README.md @@ -1,25 +1,34 @@ -# OpenAI Plugin Node.js Library +# OpenAI Plugin Node.js Library πŸš€ > PROJECT IN EARLY DEVELOPMENT A simple modification in the official OpenAI module that gives the possibility to use plugins that follow the OpenAI standards together with the API. -**Important note: this library is meant for server-side usage only, as using it in client-side browser code will expose your secret API key. [See here](https://platform.openai.com/docs/api-reference/authentication) for more details.** +πŸ”’ **Important note**: this library is meant for server-side usage only, as using it in client-side browser code will expose your secret API key. [See here](https://platform.openai.com/docs/api-reference/authentication) for more details. -## Installation +## πŸ—ΊοΈ Table of Contents + +- [Installation](#installation-πŸ’») +- [Usage](#usage-πŸ“–) +- [TODO](#todo-πŸ“) +- [Thanks](#thanks-πŸ™) + +## Installation πŸ’» ```bash npm install openai-plugin ``` -## Usage +## Usage πŸ“– The library needs to be configured with your account's secret key, which is available on the [website](https://platform.openai.com/account/api-keys). We recommend setting as an environment variable. Create a `.env` file in the root of your project and add your secret key: + ``` OPENAI_API_KEY=sk-xxxxxxxxxxxxxxxxxxxxxxxx ``` + Here's an example of initializing the library with the API key loaded from an environment variable and creating a completion using a plugin: ```javascript @@ -28,41 +37,31 @@ import dotenv from "dotenv"; dotenv.config(); const configuration = new Configuration({ - apiKey: process.env.OPENAI_API_KEY, +apiKey: process.env.OPENAI_API_KEY, }); const openai = new OpenAIPluginApi(configuration); (async () => { - var plugins = new Plugins([ - { - name: 'Calculator', - manifest: 'https://chat-calculator-plugin.supportmirage.repl.co/.well-known/ai-plugin.json' - } - ]) - - var completion = await openai.createChatCompletionPlugin({ - model: "gpt-3.5-turbo", - messages: [{role: "user", content: "How much is 3849 x 8394 ?"}], - plugins - }); - - console.log(completion.completions.map(completion => completion.message)); - -})(); -``` - -Check out the [full API documentation](https://platform.openai.com/docs/api-reference?lang=node.js) for examples of all the available functions. +var plugins = new Plugins([ +{ +name: 'Calculator', +manifest: 'https://chat-calculator-plugin.supportmirage.repl.co/.well-known/ai-plugin.json' +} +]) + +var completion = await openai.createChatCompletionPlugin({ +model: "gpt-3.5-turbo", +messages: [{role: "user", content: "How much is 3849 x 8394 ?"}], +plugins +}); -## TODO -- support to auth -- support to all openapi versions -- support to predefined variables(like $userId) -- debug mode -- token management -- Fix method in sdk generation -- make tamplates and handles more modular +console.log(completion.completions.map(completion => completion.message)); +})(); +``` -## Thanks +πŸ“š Check out the [full API documentation](https://platform.openai.com/docs/api-reference?lang=node.js) for examples of all the available functions. +## TODO πŸ“ +## Thanks πŸ™ -Thank you to [ceifa](https://github.com/ceifa) for creating and maintaining the original unofficial `openai` npm package before we released this official library! ceifa's original package has been renamed to [gpt-x](https://www.npmjs.com/package/gpt-x). +Thank you to [ceifa](https://github.com/ceifa) for creating and maintaining the original unofficial `openai` npm package before we released this official library! ceifa's original package has been renamed to [gpt-x](https://www.npmjs.com/package/gpt-x). \ No newline at end of file