data-gpt
v1.1.1
Published
Use the power of ChatGPT with your own data
Downloads
40
Maintainers
Readme
Table of Contents
Getting started
Install
npm install data-gpt
or
yarn add data-gpt
Import
import { embedding, completion } from 'data-gpt';
or
const { embedding, completion } = require('data-gpt');
Use
First configure your OpenAI API instance.
import { Configuration, OpenAIApi } from 'openai';
const configuration = new Configuration({
apiKey: process.env.OPENAI_API_KEY,
});
export const openai = new OpenAIApi(configuration);
Then, pass it as the first parameter of the functions.
import { openai } from './your-openai-config-file';
const source = 'your-text-to-embed';
const embed = embedding({ openai, source });
const prompt = 'your-prompt';
const complete = completion({ openai, prompt, embed });
Options
embedding()
openai (required) - OpenAIApi
Your OpenAI API instance.
source (required) - string
The text to embed.
debug (optional) - boolean
Set to true to enable the debug mode. Default: false
storagePrefix (optional) - string
The prefix to use for the storage key. Default: 'embeds'
model (optional) - string
The OpenAI model to use for embedding. Default: 'text-embedding-ada-002'
completion()
openai (required) - OpenAIApi
Your OpenAI API instance.
prompt (required) - string
The prompt to complete.
embed (required) - string
The embedded text (the result of the embedding function).
maxTokens (optional) - number
The maximum number of tokens to generate. Default: 100
debug (optional) - boolean
Set to true to enable the debug mode. Default: false
storagePrefix (optional) - string
The prefix to use for the storage key. Default: 'embeds' (/!\ Use the same storagePrefix as used in the embedding function)
embeddingModel (optional) - string
The OpenAI model to use for embedding. Default: 'text-embedding-ada-002' (/!\ Use the same model as used in the embedding function)
completionModel (optional) - string
The OpenAI model to use for chat completion. Default: 'gpt-3.5-turbo'
Issues
Please file an issue for bugs, missing documentation, or unexpected behavior.
LICENSE
MIT