polyfire-js
Advanced tools
Comparing version 0.2.5 to 0.2.6
@@ -13,4 +13,5 @@ import { GenerationClient } from "./generate"; | ||
import { AuthClient } from "./auth"; | ||
import { TTSClient } from "./tts"; | ||
export type Client = { | ||
models: GenerationClient & GenerationWithTypeClient & TranscribeClient & ImageGenerationClient; | ||
models: GenerationClient & GenerationWithTypeClient & TranscribeClient & ImageGenerationClient & TTSClient; | ||
data: MemoryClient & { | ||
@@ -17,0 +18,0 @@ kv: KVClient; |
@@ -29,5 +29,6 @@ "use strict"; | ||
var auth_1 = __importDefault(require("./auth")); | ||
var tts_1 = __importDefault(require("./tts")); | ||
function client(co, projectOptions) { | ||
return { | ||
models: __assign(__assign(__assign(__assign({}, (0, generate_1.default)(co)), (0, generateWithType_1.default)(co)), (0, transcribe_1.default)(co)), (0, image_1.default)(co)), | ||
models: __assign(__assign(__assign(__assign(__assign({}, (0, generate_1.default)(co)), (0, generateWithType_1.default)(co)), (0, transcribe_1.default)(co)), (0, image_1.default)(co)), (0, tts_1.default)(co)), | ||
data: __assign(__assign({}, (0, memory_1.default)(co)), { kv: (0, kv_1.default)(co) }), | ||
@@ -34,0 +35,0 @@ utils: __assign(__assign({}, (0, chats_1.default)(co)), (0, prompt_1.default)(co)), |
@@ -29,3 +29,3 @@ /// <reference types="node" /> | ||
{ | ||
memory: Memory; | ||
memory: Memory | string; | ||
}, | ||
@@ -32,0 +32,0 @@ { |
@@ -93,12 +93,18 @@ "use strict"; | ||
return __awaiter(this, void 0, void 0, function () { | ||
var memoryIds, _b, validMemoryIds; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
var memoryIds, _b, _c, validMemoryIds; | ||
return __generator(this, function (_d) { | ||
switch (_d.label) { | ||
case 0: | ||
_b = [dataMemory, | ||
genOptionsMemoryId]; | ||
return [4 /*yield*/, (genOptionsMemory === null || genOptionsMemory === void 0 ? void 0 : genOptionsMemory.memoryId)]; | ||
case 1: | ||
if (!(typeof genOptionsMemory === "string")) return [3 /*break*/, 1]; | ||
_c = genOptionsMemory; | ||
return [3 /*break*/, 3]; | ||
case 1: return [4 /*yield*/, (genOptionsMemory === null || genOptionsMemory === void 0 ? void 0 : genOptionsMemory.memoryId)]; | ||
case 2: | ||
_c = _d.sent(); | ||
_d.label = 3; | ||
case 3: | ||
memoryIds = _b.concat([ | ||
_c.sent() | ||
_c | ||
]); | ||
@@ -105,0 +111,0 @@ validMemoryIds = memoryIds.filter(function (id) { return id !== undefined; }); |
@@ -25,2 +25,7 @@ import { InputClientOptions } from "./clientOpts"; | ||
getId(): Promise<string>; | ||
search(input: string): Promise<{ | ||
id: string; | ||
content: string; | ||
similarity: number; | ||
}[]>; | ||
} | ||
@@ -27,0 +32,0 @@ export { createMemory, updateMemory, getAllMemories, Memory }; |
@@ -178,2 +178,37 @@ "use strict"; | ||
exports.getAllMemories = getAllMemories; | ||
function searchMemory(id, input, clientOptions) { | ||
var _a; | ||
if (clientOptions === void 0) { clientOptions = {}; } | ||
return __awaiter(this, void 0, void 0, function () { | ||
var _b, token, endpoint, res, e_4; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, (0, clientOpts_1.defaultOptions)(clientOptions)]; | ||
case 1: | ||
_b = _c.sent(), token = _b.token, endpoint = _b.endpoint; | ||
_c.label = 2; | ||
case 2: | ||
_c.trys.push([2, 4, , 5]); | ||
return [4 /*yield*/, axios_1.default.post("".concat(endpoint, "/memory/").concat(id, "/search"), { | ||
input: input, | ||
}, { | ||
headers: { | ||
"Content-Type": "application/json", | ||
"X-Access-Token": token, | ||
}, | ||
})]; | ||
case 3: | ||
res = _c.sent(); | ||
return [2 /*return*/, res.data.results]; | ||
case 4: | ||
e_4 = _c.sent(); | ||
if (e_4 instanceof axios_1.AxiosError) { | ||
throw new error_1.ApiError((_a = e_4 === null || e_4 === void 0 ? void 0 : e_4.response) === null || _a === void 0 ? void 0 : _a.data); | ||
} | ||
throw e_4; | ||
case 5: return [2 /*return*/]; | ||
} | ||
}); | ||
}); | ||
} | ||
var Memory = /** @class */ (function () { | ||
@@ -223,2 +258,18 @@ function Memory(memoryOptions, clientOptions) { | ||
}; | ||
Memory.prototype.search = function (input) { | ||
return __awaiter(this, void 0, void 0, function () { | ||
var id, _a, _b; | ||
return __generator(this, function (_c) { | ||
switch (_c.label) { | ||
case 0: return [4 /*yield*/, this.memoryId]; | ||
case 1: | ||
id = _c.sent(); | ||
_a = searchMemory; | ||
_b = [id, input]; | ||
return [4 /*yield*/, this.clientOptions]; | ||
case 2: return [2 /*return*/, _a.apply(void 0, _b.concat([_c.sent()]))]; | ||
} | ||
}); | ||
}); | ||
}; | ||
return Memory; | ||
@@ -225,0 +276,0 @@ }()); |
{ | ||
"name": "polyfire-js", | ||
"version": "0.2.5", | ||
"version": "0.2.6", | ||
"main": "index.js", | ||
@@ -5,0 +5,0 @@ "types": "index.d.ts", |
@@ -1,2 +0,2 @@ | ||
<h1 align="center">Polyfire</h1> | ||
<h1 align="center">🔥 polyfire</h1> | ||
@@ -15,3 +15,3 @@ <h4 align="center"> | ||
It's a **managed backend**, we help you save time, by managing your AI backend. | ||
We **manage your AI backend** so you don't have to. | ||
@@ -51,2 +51,2 @@ ![Demo Gif](https://files.readme.io/7442014-demo.gif) | ||
We're open source! Make a good PR to the JS SDK or the API and we'll merge it. | ||
We're open source! Make a good PR to the JS SDK or the API and we'll merge it. |
Sorry, the diff of this file is not supported yet
2481795
51
4094
51