@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.
Files changed (43) hide show
  1. package/.eslintignore +30 -0
  2. package/.eslintrc +31 -0
  3. package/README.md +13 -1
  4. package/config/default.example.json +70 -0
  5. package/config.js +5 -6
  6. package/graphql/chunker.js +1 -1
  7. package/graphql/graphql.js +1 -1
  8. package/graphql/parser.js +7 -0
  9. package/graphql/pathwayPrompter.js +8 -19
  10. package/graphql/pathwayResolver.js +10 -10
  11. package/graphql/pathwayResponseParser.js +13 -4
  12. package/graphql/plugins/localModelPlugin.js +54 -5
  13. package/graphql/plugins/modelPlugin.js +29 -20
  14. package/graphql/plugins/openAiCompletionPlugin.js +29 -12
  15. package/graphql/plugins/openAiWhisperPlugin.js +112 -19
  16. package/graphql/prompt.js +1 -0
  17. package/graphql/resolver.js +2 -2
  18. package/graphql/subscriptions.js +1 -1
  19. package/helper_apps/MediaFileChunker/blobHandler.js +150 -0
  20. package/helper_apps/MediaFileChunker/fileChunker.js +123 -0
  21. package/helper_apps/MediaFileChunker/function.json +20 -0
  22. package/helper_apps/MediaFileChunker/helper.js +33 -0
  23. package/helper_apps/MediaFileChunker/index.js +116 -0
  24. package/helper_apps/MediaFileChunker/localFileHandler.js +36 -0
  25. package/helper_apps/MediaFileChunker/package-lock.json +2919 -0
  26. package/helper_apps/MediaFileChunker/package.json +22 -0
  27. package/helper_apps/MediaFileChunker/redis.js +32 -0
  28. package/helper_apps/MediaFileChunker/start.js +27 -0
  29. package/lib/handleBars.js +26 -0
  30. package/lib/pathwayTools.js +15 -0
  31. package/lib/redisSubscription.js +51 -0
  32. package/lib/request.js +4 -5
  33. package/package.json +9 -6
  34. package/pathways/lc_test.mjs +9 -5
  35. package/pathways/summary.js +1 -1
  36. package/pathways/transcribe.js +2 -1
  37. package/tests/config.test.js +69 -0
  38. package/tests/handleBars.test.js +43 -0
  39. package/tests/mocks.js +39 -0
  40. package/tests/modelPlugin.test.js +129 -0
  41. package/tests/pathwayResolver.test.js +77 -0
  42. package/tests/truncateMessages.test.js +99 -0
  43. 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
+ };