@aj-archipelago/cortex 1.0.1 → 1.0.3
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- package/.eslintignore +30 -0
- package/.eslintrc +31 -0
- package/README.md +13 -1
- package/config/default.example.json +70 -0
- package/config.js +5 -6
- package/graphql/chunker.js +1 -1
- package/graphql/graphql.js +1 -1
- package/graphql/parser.js +7 -0
- package/graphql/pathwayPrompter.js +8 -19
- package/graphql/pathwayResolver.js +10 -10
- package/graphql/pathwayResponseParser.js +13 -4
- package/graphql/plugins/localModelPlugin.js +54 -5
- package/graphql/plugins/modelPlugin.js +29 -20
- package/graphql/plugins/openAiCompletionPlugin.js +29 -12
- package/graphql/plugins/openAiWhisperPlugin.js +112 -19
- package/graphql/prompt.js +1 -0
- package/graphql/resolver.js +2 -2
- package/graphql/subscriptions.js +1 -1
- package/helper_apps/MediaFileChunker/blobHandler.js +150 -0
- package/helper_apps/MediaFileChunker/fileChunker.js +123 -0
- package/helper_apps/MediaFileChunker/function.json +20 -0
- package/helper_apps/MediaFileChunker/helper.js +33 -0
- package/helper_apps/MediaFileChunker/index.js +116 -0
- package/helper_apps/MediaFileChunker/localFileHandler.js +36 -0
- package/helper_apps/MediaFileChunker/package-lock.json +2919 -0
- package/helper_apps/MediaFileChunker/package.json +22 -0
- package/helper_apps/MediaFileChunker/redis.js +32 -0
- package/helper_apps/MediaFileChunker/start.js +27 -0
- package/lib/handleBars.js +26 -0
- package/lib/pathwayTools.js +15 -0
- package/lib/redisSubscription.js +51 -0
- package/lib/request.js +4 -5
- package/package.json +9 -6
- package/pathways/lc_test.mjs +9 -5
- package/pathways/summary.js +1 -1
- package/pathways/transcribe.js +2 -1
- package/tests/config.test.js +69 -0
- package/tests/handleBars.test.js +43 -0
- package/tests/mocks.js +39 -0
- package/tests/modelPlugin.test.js +129 -0
- package/tests/pathwayResolver.test.js +77 -0
- package/tests/truncateMessages.test.js +99 -0
- package/lib/fileChunker.js +0 -160
|
@@ -0,0 +1,36 @@
|
|
|
1
|
+
import { promises as fs } from 'fs';
|
|
2
|
+
import { join, basename } from 'path';
|
|
3
|
+
import { v4 as uuidv4 } from 'uuid';
|
|
4
|
+
|
|
5
|
+
import { publicFolder, port, ipAddress } from "./start.js";
|
|
6
|
+
|
|
7
|
+
|
|
8
|
+
async function moveFileToPublicFolder(chunkPath, requestId) {
|
|
9
|
+
// Use the filename with a UUID as the blob name
|
|
10
|
+
const filename = `${requestId}/${uuidv4()}_${basename(chunkPath)}`;
|
|
11
|
+
|
|
12
|
+
// Create the target folder if it doesn't exist
|
|
13
|
+
const targetFolder = join(publicFolder, requestId);
|
|
14
|
+
await fs.mkdir(targetFolder, { recursive: true });
|
|
15
|
+
|
|
16
|
+
// Move the file to the target folder
|
|
17
|
+
const targetPath = join(targetFolder, basename(filename));
|
|
18
|
+
await fs.rename(chunkPath, targetPath);
|
|
19
|
+
|
|
20
|
+
// Return the complete URL of the file
|
|
21
|
+
const fileUrl = `http://${ipAddress}:${port}/files/${filename}`;
|
|
22
|
+
// const fileUrl = `http://localhost:${port}/files/${filename}`;
|
|
23
|
+
return fileUrl;
|
|
24
|
+
}
|
|
25
|
+
|
|
26
|
+
async function deleteFolder(requestId) {
|
|
27
|
+
if (!requestId) throw new Error('Missing requestId parameter');
|
|
28
|
+
const targetFolder = join(publicFolder, requestId);
|
|
29
|
+
await fs.rm(targetFolder, { recursive: true });
|
|
30
|
+
console.log(`Cleaned folder: ${targetFolder}`);
|
|
31
|
+
}
|
|
32
|
+
|
|
33
|
+
|
|
34
|
+
export {
|
|
35
|
+
moveFileToPublicFolder, deleteFolder
|
|
36
|
+
};
|