@adminforth/completion-adapter-open-ai-chat-gpt
Advanced tools
Comparing version 1.0.1 to 1.0.2
@@ -34,2 +34,5 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, generator) { | ||
const data = yield resp.json(); | ||
if (data.error) { | ||
return { error: data.error.message }; | ||
} | ||
return { | ||
@@ -41,3 +44,5 @@ content: data.choices[0].message.content, | ||
this.options = options; | ||
if (!options.openAiApiKey) { | ||
} | ||
validate() { | ||
if (!this.options.openAiApiKey) { | ||
throw new Error("openAiApiKey is required"); | ||
@@ -44,0 +49,0 @@ } |
16
index.ts
@@ -1,2 +0,1 @@ | ||
import { da } from "@faker-js/faker"; | ||
import type { AdapterOptions } from "./types.js"; | ||
@@ -12,3 +11,6 @@ import type { CompletionAdapter } from "adminforth"; | ||
this.options = options; | ||
if (!options.openAiApiKey) { | ||
} | ||
validate() { | ||
if (!this.options.openAiApiKey) { | ||
throw new Error("openAiApiKey is required"); | ||
@@ -18,3 +20,7 @@ } | ||
complete = async (content: string, stop = ["."], maxTokens = 50) => { | ||
complete = async (content: string, stop = ["."], maxTokens = 50): Promise<{ | ||
content?: string; | ||
finishReason?: string; | ||
error?: string; | ||
}> => { | ||
const resp = await fetch("https://api.openai.com/v1/chat/completions", { | ||
@@ -40,3 +46,5 @@ method: "POST", | ||
const data = await resp.json(); | ||
if (data.error) { | ||
return { error: data.error.message }; | ||
} | ||
return { | ||
@@ -43,0 +51,0 @@ content: data.choices[0].message.content, |
{ | ||
"name": "@adminforth/completion-adapter-open-ai-chat-gpt", | ||
"version": "1.0.1", | ||
"version": "1.0.2", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
New author
Supply chain riskA new npm collaborator published a version of the package for the first time. New collaborators are usually benign additions to a project, but do indicate a change to the security surface area of a package.
Found 1 instance in 1 package
License Policy Violation
LicenseThis package is not allowed per your license policy. Review the package's license to ensure compliance.
Found 1 instance in 1 package
5721
131
2