@amplication/plugin-integrate-openai

2.0.5 • Public • Published

@amplication/plugin-integrate-openai

NPM Downloads

Adds a service to use OpenAI API

Purpose

This plugin adds a module and a service to use OpenAI API, and adds the openai package as a dependency. It expose a single function createChatCompletion that can be used to create a chat completion using the OpenAI API.

const result = await this.openaiService.createChatCompletion(
  "gpt-3.5-turbo",
  [
    {
      role: "system",
      content: "This is a test system message",
    },
    {
      role: "user",
      content: "This is a test user message",
    },
  ],
  {
    temperature: 1,
    max_tokens: 2048,
    top_p: 1,
    frequency_penalty: 0,
    presence_penalty: 0,
  }
);

Configuration

This plugin requires the following environment variables: OPENAI_API_KEY=[open-ai-key]

Note: For development purposes, the plugin adds the variable to the .env file, but you should never use .env to hold secrets in production, and you should never check in a secrets file to source control. You should use a secrets manager like AWS Secrets Manager or Azure Key Vault to store secrets.

Readme

Keywords

none

Package Sidebar

Install

npm i @amplication/plugin-integrate-openai

Weekly Downloads

9

Version

2.0.5

License

Apache-2.0

Unpacked Size

16.4 kB

Total Files

15

Last publish

Collaborators

  • amplication-bot
  • mulygottlieb
  • levivannoort
  • morhag
  • yuvalhazaz