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

openai-edge

Package Overview
Dependencies
Maintainers
1
Versions
21
Alerts
File Explorer

Advanced tools

Socket logo

Install Socket

Detect and block malicious and high-risk dependencies

Install

openai-edge - npm Package Compare versions

Comparing version 0.5.1 to 0.6.0

8

dist/index.js

@@ -61,3 +61,2 @@ 'use strict';

formDataCtor;
// asdlfkalsdfkmad
constructor(param = {}) {

@@ -111,3 +110,8 @@ this.apiKey = param.apiKey;

configuration;
constructor(configuration, basePath = BASE_PATH) {
fetch;
constructor(configuration, basePath = BASE_PATH, customFetch) {
if (typeof fetch === "undefined" && !customFetch) {
throw new Error("You must pass a fetch polyfill into the openai-edge configuration if you're running in an environment without a global fetch");
}
this.fetch = customFetch ? customFetch : fetch;
this.basePath = basePath;

@@ -114,0 +118,0 @@ // this.axios = axios;

@@ -1,1 +0,1 @@

!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self)["openai-edge"]={})}(this,(function(t){"use strict";const i="https://api.openai.com/v1".replace(/\/+$/,"");class o{basePath;configuration;constructor(t,o=i){this.basePath=o,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}t.Configuration=class{apiKey;organization;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(t={}){this.apiKey=t.apiKey,this.organization=t.organization,this.username=t.username,this.password=t.password,this.accessToken=t.accessToken,this.basePath=t.basePath,this.baseOptions=t.baseOptions,this.formDataCtor=t.formDataCtor,this.baseOptions||(this.baseOptions={}),this.baseOptions.headers=Object.assign({Authorization:`Bearer ${this.apiKey}`},this.baseOptions.headers),this.organization&&(this.baseOptions.headers["OpenAI-Organization"]=this.organization)}isJsonMime(t){const i=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==t&&(i.test(t)||"application/json-patch+json"===t.toLowerCase())}},t.OpenAIApi=class extends o{createChatCompletion(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}createCompletion(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/completions",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}createImage(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/images/generations",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}createModeration(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/moderations",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}createEmbedding(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/embeddings",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}}}));
!function(t,i){"object"==typeof exports&&"undefined"!=typeof module?i(exports):"function"==typeof define&&define.amd?define(["exports"],i):i((t="undefined"!=typeof globalThis?globalThis:t||self)["openai-edge"]={})}(this,(function(t){"use strict";const i="https://api.openai.com/v1".replace(/\/+$/,"");class e{basePath;configuration;fetch;constructor(t,e=i,o){if("undefined"==typeof fetch&&!o)throw new Error("You must pass a fetch polyfill into the openai-edge configuration if you're running in an environment without a global fetch");this.fetch=o||fetch,this.basePath=e,t&&(this.configuration=t,this.basePath=t.basePath||this.basePath)}}t.Configuration=class{apiKey;organization;username;password;accessToken;basePath;baseOptions;formDataCtor;constructor(t={}){this.apiKey=t.apiKey,this.organization=t.organization,this.username=t.username,this.password=t.password,this.accessToken=t.accessToken,this.basePath=t.basePath,this.baseOptions=t.baseOptions,this.formDataCtor=t.formDataCtor,this.baseOptions||(this.baseOptions={}),this.baseOptions.headers=Object.assign({Authorization:`Bearer ${this.apiKey}`},this.baseOptions.headers),this.organization&&(this.baseOptions.headers["OpenAI-Organization"]=this.organization)}isJsonMime(t){const i=new RegExp("^(application/json|[^;/ \t]+/[^;/ \t]+[+]json)[ \t]*(;.*)?$","i");return null!==t&&(i.test(t)||"application/json-patch+json"===t.toLowerCase())}},t.OpenAIApi=class extends e{createChatCompletion(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/chat/completions",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}createCompletion(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/completions",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}createImage(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/images/generations",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}createModeration(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/moderations",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}createEmbedding(t){if(!this.configuration)throw new Error("Must provide a valid configuration to `OpenAIApi`");return fetch("https://api.openai.com/v1/embeddings",{method:"POST",headers:{...this.configuration.baseOptions.headers,"Content-Type":"application/json"},body:JSON.stringify(t)})}}}));
{
"version": "0.5.1",
"version": "0.6.0",
"name": "openai-edge",

@@ -4,0 +4,0 @@ "umd:name": "openai-edge",

@@ -7,2 +7,3 @@ import { ConfigurationParameters } from "./types/config";

import { CreateEmbeddingRequest } from "./types/embedding";
type FetchAPI = (input: RequestInfo | URL, init?: RequestInit | undefined) => Promise<Response>;
export declare class Configuration {

@@ -86,3 +87,4 @@ /**

configuration?: Configuration;
constructor(configuration?: Configuration, basePath?: string);
fetch?: FetchAPI;
constructor(configuration?: Configuration, basePath?: string, customFetch?: FetchAPI);
}

@@ -89,0 +91,0 @@ /**

Sorry, the diff of this file is not supported yet

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