Huge News!Announcing our $40M Series B led by Abstract Ventures.Learn More
Socket
Sign inDemoInstall
Socket

openai

Package Overview
Dependencies
Maintainers
1
Versions
209
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openai - npm Package Compare versions

Comparing version 0.0.8 to 0.0.9

2

dist/index.d.ts
/// <reference types="node" />
import { Answer, AnswerRequest, Classification, ClassificationRequest, Completion, CompletionRequest, ContentLabel, Engine, EngineId, File, FilePurpose, FineTune, FineTuneEvent, FineTuneRequest, JsonLines, SearchDocument, SearchRequest } from './types';
import { Readable } from 'stream';
export * from './types';
export declare class OpenAI {

@@ -11,2 +12,3 @@ private readonly url;

complete(engine: EngineId, options: CompletionRequest): Promise<Completion>;
completeFromModel(fineTunedModel: string, options: CompletionRequest): Promise<Completion>;
completionTextStream(engine: EngineId, options: CompletionRequest): Promise<Readable>;

@@ -13,0 +15,0 @@ contentFilter(content: string, user?: string): Promise<ContentLabel>;

16

dist/index.js

@@ -7,3 +7,3 @@ (function (factory) {

else if (typeof define === "function" && define.amd) {
define(["require", "exports", "tslib", "stream", "form-data", "node-fetch"], factory);
define(["require", "exports", "tslib", "stream", "form-data", "node-fetch", "./types"], factory);
}

@@ -16,6 +16,7 @@ })(function (require, exports) {

const stream_1 = require("stream");
const form_data_1 = tslib_1.__importDefault(require("form-data"));
const node_fetch_1 = tslib_1.__importDefault(require("node-fetch"));
const form_data_1 = (0, tslib_1.__importDefault)(require("form-data"));
const node_fetch_1 = (0, tslib_1.__importDefault)(require("node-fetch"));
const baseUrl = 'https://api.openai.com';
const defaultVersion = 'v1';
(0, tslib_1.__exportStar)(require("./types"), exports);
class OpenAI {

@@ -43,2 +44,5 @@ url;

}
completeFromModel(fineTunedModel, options) {
return this.request(`/completions`, 'POST', { ...options, model: fineTunedModel });
}
async completionTextStream(engine, options) {

@@ -77,4 +81,4 @@ const request = await this.requestRaw(`/engines/${engine}/completions`, 'POST', { ...options, stream: true });

if (label === 2) {
const logprobs = completion.choices[0].logprobs.top_logprobs[0];
if (logprobs['2'] < -0.355) {
const logprobs = completion.choices[0].logprobs?.top_logprobs[0];
if (logprobs && logprobs['2'] < -0.355) {
if (logprobs['0'] && logprobs['1']) {

@@ -154,3 +158,3 @@ label = logprobs['0'] >= logprobs['1'] ? 0 : 1;

}
const response = await node_fetch_1.default(this.url + path, {
const response = await (0, node_fetch_1.default)(this.url + path, {
headers,

@@ -157,0 +161,0 @@ method,

@@ -41,3 +41,3 @@ export declare type EngineId = 'davinci' | 'curie' | 'babbage' | 'ada' | string;

index: number;
logprobs: LogProbs;
logprobs: LogProbs | null;
finish_reason: string | null;

@@ -44,0 +44,0 @@ }

{
"name": "openai",
"version": "0.0.8",
"version": "0.0.9",
"description": "Tiny OpenAI API wrapper",

@@ -29,18 +29,18 @@ "main": "dist/index.js",

"devDependencies": {
"@types/node": "16.7.0",
"@types/node": "16.10.5",
"@types/node-fetch": "2.5.12",
"@typescript-eslint/eslint-plugin": "4.29.2",
"@typescript-eslint/parser": "4.29.2",
"eslint": "7.32.0",
"@typescript-eslint/eslint-plugin": "5.0.0",
"@typescript-eslint/parser": "5.0.0",
"eslint": "8.0.0",
"eslint-config-prettier": "8.3.0",
"eslint-plugin-prettier": "3.4.0",
"eslint-plugin-prettier": "4.0.0",
"eslint-plugin-sort-imports-es6-autofix": "0.6.0",
"prettier": "2.3.2",
"typescript": "4.3.5"
"prettier": "2.4.1",
"typescript": "4.4.4"
},
"dependencies": {
"form-data": "4.0.0",
"node-fetch": "2.6.1",
"node-fetch": "2.6.5",
"tslib": "2.3.1"
}
}

@@ -61,2 +61,10 @@ # OpenAI

Make a completion from a fine-tuned model:
```js
const completion = await openai.completeFromModel('FINE_TUNED_MODEL', {
prompt: 'Q: Hello\nA:'
});
```
Make a completion and stream the response:

@@ -195,2 +203,2 @@

const events = await openai.getFinetuneEvents('ftjob-AF1WoRqd3aJ');
```
```
SocketSocket SOC 2 Logo

Product

  • Package Alerts
  • Integrations
  • Docs
  • Pricing
  • FAQ
  • Roadmap
  • Changelog

Packages

npm

Stay in touch

Get open source security insights delivered straight into your inbox.


  • Terms
  • Privacy
  • Security

Made with ⚡️ by Socket Inc