Comparing version 0.1.15 to 0.1.16
@@ -30,3 +30,3 @@ "use strict"; | ||
exports.generateWithTokenUsage = exports.generate = void 0; | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch")); | ||
const t = __importStar(require("io-ts")); | ||
@@ -61,3 +61,3 @@ const ensurePolyfactToken_1 = require("./helpers/ensurePolyfactToken"); | ||
const requestBody = { task, provider: options?.provider || "openai", memory_id: options?.memoryId || "" }; | ||
const res = await (0, node_fetch_1.default)(`${POLYFACT_ENDPOINT}/generate`, { | ||
const resJSON = await (0, isomorphic_fetch_1.default)(`${POLYFACT_ENDPOINT}/generate`, { | ||
method: "POST", | ||
@@ -69,3 +69,5 @@ headers: { | ||
body: JSON.stringify(requestBody), | ||
}).then((res) => res.json()); | ||
}).then((res) => res.text()); | ||
console.log(resJSON); | ||
const res = JSON.parse(resJSON); | ||
if (!ResultType.is(res)) { | ||
@@ -72,0 +74,0 @@ throw new GenerationError(); |
declare function createMemory(): Promise<{ | ||
id: string; | ||
}>; | ||
declare function updateMemory(id: string, input: string): Promise<{ | ||
declare function updateMemory(id: string, input: string, maxToken?: number): Promise<{ | ||
success: boolean; | ||
@@ -6,0 +6,0 @@ }>; |
@@ -7,3 +7,3 @@ "use strict"; | ||
exports.getAllMemories = exports.updateMemory = exports.createMemory = void 0; | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch")); | ||
const ensurePolyfactToken_1 = require("./helpers/ensurePolyfactToken"); | ||
@@ -25,3 +25,3 @@ const { POLYFACT_ENDPOINT = "https://api2.polyfact.com", POLYFACT_TOKEN = "" } = process.env; | ||
try { | ||
const res = await (0, node_fetch_1.default)(`${POLYFACT_ENDPOINT}/memory`, { | ||
const res = await (0, isomorphic_fetch_1.default)(`${POLYFACT_ENDPOINT}/memory`, { | ||
method: "POST", | ||
@@ -43,6 +43,6 @@ headers: { | ||
exports.createMemory = createMemory; | ||
async function updateMemory(id, input) { | ||
async function updateMemory(id, input, maxToken = 0) { | ||
(0, ensurePolyfactToken_1.ensurePolyfactToken)(); | ||
try { | ||
const res = await (0, node_fetch_1.default)(`${POLYFACT_ENDPOINT}/memory`, { | ||
const res = await (0, isomorphic_fetch_1.default)(`${POLYFACT_ENDPOINT}/memory`, { | ||
method: "PUT", | ||
@@ -56,2 +56,3 @@ headers: { | ||
input, | ||
max_token: maxToken, | ||
}), | ||
@@ -72,3 +73,3 @@ }).then((res) => res.json()); | ||
try { | ||
const res = await (0, node_fetch_1.default)(`${POLYFACT_ENDPOINT}/memories`, { | ||
const res = await (0, isomorphic_fetch_1.default)(`${POLYFACT_ENDPOINT}/memories`, { | ||
method: "GET", | ||
@@ -75,0 +76,0 @@ headers: { |
/// <reference types="node" /> | ||
/// <reference types="node" /> | ||
import { Blob } from "node-fetch"; | ||
import { Readable } from "stream"; | ||
export declare function transcribe(file: Blob | Buffer | Readable): Promise<string>; | ||
export declare function transcribe(file: Buffer | Readable): Promise<string>; |
@@ -30,3 +30,3 @@ "use strict"; | ||
exports.transcribe = void 0; | ||
const node_fetch_1 = __importDefault(require("node-fetch")); | ||
const isomorphic_fetch_1 = __importDefault(require("isomorphic-fetch")); | ||
const form_data_1 = __importDefault(require("form-data")); | ||
@@ -48,3 +48,3 @@ const t = __importStar(require("io-ts")); | ||
}); | ||
const res = await (0, node_fetch_1.default)(`${POLYFACT_ENDPOINT}/transcribe`, { | ||
const res = await (0, isomorphic_fetch_1.default)(`${POLYFACT_ENDPOINT}/transcribe`, { | ||
method: "POST", | ||
@@ -51,0 +51,0 @@ headers: { |
{ | ||
"name": "polyfact", | ||
"version": "0.1.15", | ||
"version": "0.1.16", | ||
"main": "dist/index.js", | ||
@@ -5,0 +5,0 @@ "types": "dist/index.d.ts", |
871378
1581