1.0.7 • Published 3 years ago

@hellobardo/open-ai-sdk v1.0.7

Weekly downloads
131
License
MIT
Repository
github
Last release
3 years ago

OPEN-AI-SDK

A library that wraps the Open AI API built in TypeScript

Installation

npm i @hellobardo/open-ai-sdk

Usage

Completion

Completion takes 2 parameters

const {OpenAI} = require("@hellobardo/open-ai-sdk");

const oa = new OpenAI('YOUR_API_KEY', 'ORGANIZATION_KEY_IF_ANY')

oa.completion('davinci', {
    prompt    : 'This is a ...',
    max_tokens: 5
})
    .then(response => console.log(response.data))
    .catch(e => console.error(e))

Search

Search takes 2 parameters

  • engine: a string representing the engine to be used
  • configuration: an object with the search configuration
const {OpenAI} = require("@hellobardo/open-ai-sdk");

const oa = new OpenAI('YOUR_API_KEY', 'ORGANIZATION_KEY_IF_ANY')

oa.search('davinci', {
    documents: [
        "White House",
        "hospital",
        "school"
    ],
    query    : "the president"
})
    .then(response => console.log(response.data))
    .catch(e => console.error(e))

Get Engines

Retrieve all engines

const {OpenAI} = require("@hellobardo/open-ai-sdk");

const oa = new OpenAI('YOUR_API_KEY', 'ORGANIZATION_KEY_IF_ANY')

oa.getEngines()
    .then(response => console.log(response.data))
    .catch(e => console.error(e))

Get Engine

Retrieve a single engine

const {OpenAI} = require("@hellobardo/open-ai-sdk");

const oa = new OpenAI('YOUR_API_KEY', 'ORGANIZATION_KEY_IF_ANY')

oa.getEngine('davinci')
        .then(response => console.log(response.data))
        .catch(e => console.error(e))
1.0.7

3 years ago

1.0.6

3 years ago

1.0.5

3 years ago

1.0.4

3 years ago

1.0.3

3 years ago

1.0.2

3 years ago

1.0.1

3 years ago

1.0.0

3 years ago