@aj-archipelago/cortex 1.1.3 → 1.1.4

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 (63) hide show
  1. package/.eslintignore +3 -3
  2. package/README.md +17 -4
  3. package/config.js +45 -9
  4. package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/Dockerfile +1 -1
  5. package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/fileChunker.js +4 -1
  6. package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/package-lock.json +25 -216
  7. package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/package.json +2 -2
  8. package/helper-apps/cortex-whisper-wrapper/.dockerignore +27 -0
  9. package/helper-apps/cortex-whisper-wrapper/Dockerfile +32 -0
  10. package/helper-apps/cortex-whisper-wrapper/app.py +104 -0
  11. package/helper-apps/cortex-whisper-wrapper/docker-compose.debug.yml +12 -0
  12. package/helper-apps/cortex-whisper-wrapper/docker-compose.yml +10 -0
  13. package/helper-apps/cortex-whisper-wrapper/models/.gitkeep +0 -0
  14. package/helper-apps/cortex-whisper-wrapper/requirements.txt +5 -0
  15. package/lib/cortexRequest.js +117 -0
  16. package/lib/pathwayTools.js +2 -1
  17. package/lib/redisSubscription.js +2 -2
  18. package/lib/requestExecutor.js +360 -0
  19. package/lib/requestMonitor.js +131 -28
  20. package/package.json +2 -1
  21. package/pathways/summary.js +3 -3
  22. package/server/graphql.js +6 -6
  23. package/server/{pathwayPrompter.js → modelExecutor.js} +24 -21
  24. package/server/pathwayResolver.js +22 -17
  25. package/server/plugins/azureCognitivePlugin.js +25 -20
  26. package/server/plugins/azureTranslatePlugin.js +6 -10
  27. package/server/plugins/cohereGeneratePlugin.js +5 -12
  28. package/server/plugins/cohereSummarizePlugin.js +5 -12
  29. package/server/plugins/localModelPlugin.js +3 -3
  30. package/server/plugins/modelPlugin.js +18 -12
  31. package/server/plugins/openAiChatExtensionPlugin.js +5 -5
  32. package/server/plugins/openAiChatPlugin.js +8 -10
  33. package/server/plugins/openAiCompletionPlugin.js +9 -12
  34. package/server/plugins/openAiDallE3Plugin.js +14 -31
  35. package/server/plugins/openAiEmbeddingsPlugin.js +6 -9
  36. package/server/plugins/openAiImagePlugin.js +19 -15
  37. package/server/plugins/openAiWhisperPlugin.js +168 -100
  38. package/server/plugins/palmChatPlugin.js +9 -10
  39. package/server/plugins/palmCodeCompletionPlugin.js +2 -2
  40. package/server/plugins/palmCompletionPlugin.js +11 -12
  41. package/server/resolver.js +2 -2
  42. package/server/rest.js +1 -1
  43. package/tests/config.test.js +1 -1
  44. package/tests/mocks.js +5 -0
  45. package/tests/modelPlugin.test.js +3 -10
  46. package/tests/openAiChatPlugin.test.js +9 -8
  47. package/tests/openai_api.test.js +3 -3
  48. package/tests/palmChatPlugin.test.js +1 -1
  49. package/tests/palmCompletionPlugin.test.js +1 -1
  50. package/tests/pathwayResolver.test.js +2 -1
  51. package/tests/requestMonitor.test.js +94 -0
  52. package/tests/{requestDurationEstimator.test.js → requestMonitorDurationEstimator.test.js} +21 -17
  53. package/tests/truncateMessages.test.js +1 -1
  54. package/lib/request.js +0 -259
  55. package/lib/requestDurationEstimator.js +0 -90
  56. /package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/blobHandler.js +0 -0
  57. /package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/docHelper.js +0 -0
  58. /package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/function.json +0 -0
  59. /package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/helper.js +0 -0
  60. /package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/index.js +0 -0
  61. /package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/localFileHandler.js +0 -0
  62. /package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/redis.js +0 -0
  63. /package/{helper_apps/CortexFileHandler → helper-apps/cortex-file-handler}/start.js +0 -0
package/.eslintignore CHANGED
@@ -15,12 +15,12 @@
15
15
  # Ignore coverage reports
16
16
  /coverage
17
17
 
18
+ # Ignore helper apps
19
+ /helper-apps
20
+
18
21
  # Ignore documentation
19
22
  /docs
20
23
 
21
- # Ignore helper apps
22
- /helper_apps
23
-
24
24
  # Ignore tests
25
25
  /tests
26
26
 
package/README.md CHANGED
@@ -212,12 +212,12 @@ export default {
212
212
 
213
213
  // Custom resolver to generate summaries by reprompting if they are too long or too short.
214
214
  resolver: async (parent, args, contextValue, info) => {
215
- const { config, pathway, requestState } = contextValue;
215
+ const { config, pathway } = contextValue;
216
216
  const originalTargetLength = args.targetLength;
217
217
 
218
218
  // If targetLength is not provided, execute the prompt once and return the result.
219
219
  if (originalTargetLength === 0) {
220
- let pathwayResolver = new PathwayResolver({ config, pathway, args, requestState });
220
+ let pathwayResolver = new PathwayResolver({ config, pathway, args });
221
221
  return await pathwayResolver.resolve(args);
222
222
  }
223
223
 
@@ -232,7 +232,7 @@ export default {
232
232
 
233
233
  const MAX_ITERATIONS = 5;
234
234
  let summary = '';
235
- let pathwayResolver = new PathwayResolver({ config, pathway, args, requestState });
235
+ let pathwayResolver = new PathwayResolver({ config, pathway, args });
236
236
 
237
237
  // Modify the prompt to be words-based instead of characters-based.
238
238
  pathwayResolver.pathwayPrompt = `Write a summary of all of the text below. If the text is in a language other than english, make sure the summary is written in the same language. Your summary should be ${targetWords} words in length.\n\nText:\n\n{{{text}}}\n\nSummary:\n\n`
@@ -422,7 +422,7 @@ Configuration of Cortex is done via a [convict](https://github.com/mozilla/node-
422
422
  - `enableCache`: A boolean flag indicating whether to enable Axios-level request caching. Default is true. The value can be set using the `CORTEX_ENABLE_CACHE` environment variable.
423
423
  - `enableGraphqlCache`: A boolean flag indicating whether to enable GraphQL query caching. Default is false. The value can be set using the `CORTEX_ENABLE_GRAPHQL_CACHE` environment variable.
424
424
  - `enableRestEndpoints`: A boolean flag indicating whether create REST endpoints for pathways as well as GraphQL queries. Default is false. The value can be set using the `CORTEX_ENABLE_REST` environment variable.
425
- - `cortexApiKey`: A string containing an API key that the client must pass to Cortex for authorization. Default is null in which case Cortex is unprotected. The value can be set using the `CORTEX_API_KEY` environment variable
425
+ - `cortexApiKeys`: A string containing one or more comma separated API keys that the client must pass to Cortex for authorization. Default is null in which case Cortex is unprotected. The value can be set using the `CORTEX_API_KEY` environment variable
426
426
  - `models`: An object containing the different models used by the project. The value can be set using the `CORTEX_MODELS` environment variable. Cortex is model and vendor agnostic - you can use this config to set up models of any type from any vendor.
427
427
  - `openaiApiKey`: The API key used for accessing the OpenAI API. This is sensitive information and has no default value. The value can be set using the `OPENAI_API_KEY` environment variable.
428
428
  - `openaiApiUrl`: The URL used for accessing the OpenAI API. Default is https://api.openai.com/v1/completions. The value can be set using the `OPENAI_API_URL` environment variable.
@@ -440,6 +440,19 @@ The `config` object can be used to access configuration values throughout the pr
440
440
  ```js
441
441
  config.get('PORT')
442
442
  ```
443
+
444
+ ## Helper Apps
445
+ The Cortex project includes a set of utility applications, which are located in the `helper-apps`` directory. Each of these applications comes with a Dockerfile. This Dockerfile can be used to create a Docker image of the application, which in turn allows the application to be run in a standalone manner using Docker.
446
+
447
+ - cortex-file-handler
448
+ Extends Cortex with several file processing units. Handles file operations (download, split, upload) with local file system or Azure Storage. It can process different file types including documents, files ( .pdf, .docx, .xlsx, .csv .txt, .json, .md, .xml, .js, .html, .css) and additionally YouTube URLs. It also manages deletion requests and cleanup operations, and provides progress reporting for requests.
449
+
450
+ - cortex-whisper-wrapper
451
+ The cortex-whisper-wrapper is a custom API wrapper for the Whisper package from OpenAI. Designed as a FastAPI server, it aids in transcribing audio files using the Whisper library.
452
+ The server provides an HTTP endpoint ("/") that accepts POST requests with a JSON payload containing a "fileurl" parameter specifying the URL of the audio file to transcribe. Upon receiving a request, the server calls the transcribe function to perform the transcription using the Whisper model, saves the transcription as an SRT file, and returns the SRT content as the response.
453
+ It helps Cortex to make use of Whisper OS parameters which currently are not available in OpenAI API. Parameters supported are: 'word_timestamps', 'highlight_words', 'max_line_count', 'max_line_width', 'max_words_per_line'. These parameters customizes transcription output, for more info on the parameters see open source Whisper package https://github.com/openai/whisper
454
+
455
+
443
456
  ## Troubleshooting
444
457
  If you encounter any issues while using Cortex, there are a few things you can do. First, check the Cortex documentation for any common errors and their solutions. If that does not help, you can also open an issue on the Cortex GitHub repository.
445
458
 
package/config.js CHANGED
@@ -8,6 +8,18 @@ import logger from './lib/logger.js';
8
8
 
9
9
  const __dirname = path.dirname(fileURLToPath(import.meta.url));
10
10
 
11
+ convict.addFormat({
12
+ name: 'string-array',
13
+ validate: function(val) {
14
+ if (!Array.isArray(val)) {
15
+ throw new Error('must be of type Array');
16
+ }
17
+ },
18
+ coerce: function(val) {
19
+ return val.split(',');
20
+ },
21
+ });
22
+
11
23
  // Schema for config
12
24
  var config = convict({
13
25
  env: {
@@ -30,8 +42,8 @@ var config = convict({
30
42
  default: path.join(__dirname, 'pathways'),
31
43
  env: 'CORTEX_CORE_PATHWAYS_PATH'
32
44
  },
33
- cortexApiKey: {
34
- format: String,
45
+ cortexApiKeys: {
46
+ format: 'string-array',
35
47
  default: null,
36
48
  env: 'CORTEX_API_KEY',
37
49
  sensitive: true
@@ -101,7 +113,7 @@ var config = convict({
101
113
  },
102
114
  "azure-cognitive": {
103
115
  "type": "AZURE-COGNITIVE",
104
- "url": "https://archipelago-cognitive-search.search.windows.net/indexes/indexcortex/docs/search?api-version=2023-07-01-Preview",
116
+ "url": "{{{AZURE_COGNITIVE_API_URL}}}",
105
117
  "headers": {
106
118
  "api-key": "{{AZURE_COGNITIVE_API_KEY}}",
107
119
  "Content-Type": "application/json"
@@ -110,7 +122,7 @@ var config = convict({
110
122
  },
111
123
  "oai-embeddings": {
112
124
  "type": "OPENAI-EMBEDDINGS",
113
- "url": "https://archipelago-openai.openai.azure.com/openai/deployments/archipelago-embedding/embeddings?api-version=2023-05-15",
125
+ "url": "https://archipelago-openai.openai.azure.com/openai/deployments/archipelago-embedding/embeddings?api-version=2023-12-01",
114
126
  "headers": {
115
127
  "api-key": "{{ARCHIPELAGO_OPENAI_KEY}}",
116
128
  "Content-Type": "application/json"
@@ -192,7 +204,7 @@ var config = convict({
192
204
  },
193
205
  whisperTSApiUrl: {
194
206
  format: String,
195
- default: 'null',
207
+ default: null,
196
208
  env: 'WHISPER_TS_API_URL'
197
209
  },
198
210
  subscriptionKeepAlive: {
@@ -266,15 +278,39 @@ const buildPathways = async (config) => {
266
278
  const buildModels = (config) => {
267
279
  const { models } = config.getProperties();
268
280
 
269
- for (const [key, model] of Object.entries(models)) {
270
- // Compile handlebars templates for models
271
- models[key] = JSON.parse(HandleBars.compile(JSON.stringify(model))({ ...config.getEnv(), ...config.getProperties() }))
281
+ // iterate over each model
282
+ for (let [key, model] of Object.entries(models)) {
283
+ if (!model.name) {
284
+ model.name = key;
285
+ }
286
+
287
+ // if model is in old format, convert it to new format
288
+ if (!model.endpoints) {
289
+ model = {
290
+ ...model,
291
+ endpoints: [
292
+ {
293
+ name: "default",
294
+ url: model.url,
295
+ headers: model.headers,
296
+ params: model.params,
297
+ requestsPerSecond: model.requestsPerSecond
298
+ }
299
+ ]
300
+ };
301
+ }
302
+
303
+ // compile handlebars templates for each endpoint
304
+ model.endpoints = model.endpoints.map(endpoint =>
305
+ JSON.parse(HandleBars.compile(JSON.stringify(endpoint))({ ...model, ...config.getEnv(), ...config.getProperties() }))
306
+ );
307
+
308
+ models[key] = model;
272
309
  }
273
310
 
274
311
  // Add constructed models to config
275
312
  config.load({ models });
276
313
 
277
-
278
314
  // Check that models are specified, Cortex cannot run without a model
279
315
  if (Object.keys(config.get('models')).length <= 0) {
280
316
  const errorString = 'No models specified! Please set the models in your config file or via CORTEX_MODELS environment variable to point at the models for your project.';
@@ -8,7 +8,7 @@ RUN npm install
8
8
 
9
9
  ## installing ffmepg
10
10
  RUN apk update && \
11
- apk add ffmpeg=6.0-r15
11
+ apk add ffmpeg
12
12
 
13
13
  COPY . .
14
14
 
@@ -6,6 +6,7 @@ import os from 'os';
6
6
  import { promisify } from 'util';
7
7
  import axios from 'axios';
8
8
  import { ensureEncoded } from './helper.js';
9
+ import ytdl from 'ytdl-core';
9
10
 
10
11
 
11
12
  const ffmpegProbe = promisify(ffmpeg.ffprobe);
@@ -112,7 +113,9 @@ async function splitMediaFile(inputPath, chunkDurationInSeconds = 600) {
112
113
 
113
114
  return { chunkPromises, uniqueOutputPath };
114
115
  } catch (err) {
115
- console.error('Error occurred during the splitting process:', err);
116
+ const msg = `Error processing media file, check if the file is a valid media file or is accessible`;
117
+ console.error(msg, err);
118
+ throw new Error(msg);
116
119
  }
117
120
  }
118
121
 
@@ -9,7 +9,6 @@
9
9
  "version": "1.0.0",
10
10
  "dependencies": {
11
11
  "@azure/storage-blob": "^12.13.0",
12
- "@distube/ytdl-core": "^4.13.2",
13
12
  "axios": "^1.3.6",
14
13
  "busboy": "^1.6.0",
15
14
  "cors": "^2.8.5",
@@ -21,7 +20,8 @@
21
20
  "pdfjs-dist": "^3.9.179",
22
21
  "public-ip": "^6.0.1",
23
22
  "uuid": "^9.0.0",
24
- "xlsx": "^0.18.5"
23
+ "xlsx": "^0.18.5",
24
+ "ytdl-core": "^4.11.5"
25
25
  }
26
26
  },
27
27
  "node_modules/@azure/abort-controller": {
@@ -156,29 +156,6 @@
156
156
  "node": ">=14.0.0"
157
157
  }
158
158
  },
159
- "node_modules/@distube/ytdl-core": {
160
- "version": "4.13.2",
161
- "resolved": "https://registry.npmjs.org/@distube/ytdl-core/-/ytdl-core-4.13.2.tgz",
162
- "integrity": "sha512-FBjy4LXsBv34qFrmEF1dSbKWQtqB+yd0dt4MYYUq8oYys2Bvqps3QSFGTUZO5QA6nKD/XRsMJfcG5lgEJaUqiQ==",
163
- "dependencies": {
164
- "http-cookie-agent": "^5.0.4",
165
- "m3u8stream": "^0.8.6",
166
- "sax": "^1.2.4",
167
- "tough-cookie": "^4.1.3",
168
- "undici": "^5.25.2"
169
- },
170
- "engines": {
171
- "node": ">=12"
172
- }
173
- },
174
- "node_modules/@fastify/busboy": {
175
- "version": "2.1.0",
176
- "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
177
- "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA==",
178
- "engines": {
179
- "node": ">=14"
180
- }
181
- },
182
159
  "node_modules/@ioredis/commands": {
183
160
  "version": "1.2.0",
184
161
  "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
@@ -1190,44 +1167,6 @@
1190
1167
  "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
1191
1168
  "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ=="
1192
1169
  },
1193
- "node_modules/http-cookie-agent": {
1194
- "version": "5.0.4",
1195
- "resolved": "https://registry.npmjs.org/http-cookie-agent/-/http-cookie-agent-5.0.4.tgz",
1196
- "integrity": "sha512-OtvikW69RvfyP6Lsequ0fN5R49S+8QcS9zwd58k6VSr6r57T8G29BkPdyrBcSwLq6ExLs9V+rBlfxu7gDstJag==",
1197
- "dependencies": {
1198
- "agent-base": "^7.1.0"
1199
- },
1200
- "engines": {
1201
- "node": ">=14.18.0 <15.0.0 || >=16.0.0"
1202
- },
1203
- "funding": {
1204
- "url": "https://github.com/sponsors/3846masa"
1205
- },
1206
- "peerDependencies": {
1207
- "deasync": "^0.1.26",
1208
- "tough-cookie": "^4.0.0",
1209
- "undici": "^5.11.0"
1210
- },
1211
- "peerDependenciesMeta": {
1212
- "deasync": {
1213
- "optional": true
1214
- },
1215
- "undici": {
1216
- "optional": true
1217
- }
1218
- }
1219
- },
1220
- "node_modules/http-cookie-agent/node_modules/agent-base": {
1221
- "version": "7.1.0",
1222
- "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz",
1223
- "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==",
1224
- "dependencies": {
1225
- "debug": "^4.3.4"
1226
- },
1227
- "engines": {
1228
- "node": ">= 14"
1229
- }
1230
- },
1231
1170
  "node_modules/http-errors": {
1232
1171
  "version": "2.0.0",
1233
1172
  "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@@ -1889,11 +1828,6 @@
1889
1828
  "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
1890
1829
  "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
1891
1830
  },
1892
- "node_modules/psl": {
1893
- "version": "1.9.0",
1894
- "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
1895
- "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag=="
1896
- },
1897
1831
  "node_modules/public-ip": {
1898
1832
  "version": "6.0.1",
1899
1833
  "resolved": "https://registry.npmjs.org/public-ip/-/public-ip-6.0.1.tgz",
@@ -1911,14 +1845,6 @@
1911
1845
  "url": "https://github.com/sponsors/sindresorhus"
1912
1846
  }
1913
1847
  },
1914
- "node_modules/punycode": {
1915
- "version": "2.3.1",
1916
- "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
1917
- "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg==",
1918
- "engines": {
1919
- "node": ">=6"
1920
- }
1921
- },
1922
1848
  "node_modules/qs": {
1923
1849
  "version": "6.11.0",
1924
1850
  "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
@@ -1933,11 +1859,6 @@
1933
1859
  "url": "https://github.com/sponsors/ljharb"
1934
1860
  }
1935
1861
  },
1936
- "node_modules/querystringify": {
1937
- "version": "2.2.0",
1938
- "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
1939
- "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
1940
- },
1941
1862
  "node_modules/quick-lru": {
1942
1863
  "version": "5.1.1",
1943
1864
  "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
@@ -2004,11 +1925,6 @@
2004
1925
  "node": ">=4"
2005
1926
  }
2006
1927
  },
2007
- "node_modules/requires-port": {
2008
- "version": "1.0.0",
2009
- "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
2010
- "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
2011
- },
2012
1928
  "node_modules/resolve-alpn": {
2013
1929
  "version": "1.2.1",
2014
1930
  "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz",
@@ -2329,20 +2245,6 @@
2329
2245
  "node": ">=0.6"
2330
2246
  }
2331
2247
  },
2332
- "node_modules/tough-cookie": {
2333
- "version": "4.1.3",
2334
- "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
2335
- "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
2336
- "dependencies": {
2337
- "psl": "^1.1.33",
2338
- "punycode": "^2.1.1",
2339
- "universalify": "^0.2.0",
2340
- "url-parse": "^1.5.3"
2341
- },
2342
- "engines": {
2343
- "node": ">=6"
2344
- }
2345
- },
2346
2248
  "node_modules/tr46": {
2347
2249
  "version": "0.0.3",
2348
2250
  "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
@@ -2378,25 +2280,6 @@
2378
2280
  "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz",
2379
2281
  "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A=="
2380
2282
  },
2381
- "node_modules/undici": {
2382
- "version": "5.27.2",
2383
- "resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz",
2384
- "integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==",
2385
- "dependencies": {
2386
- "@fastify/busboy": "^2.0.0"
2387
- },
2388
- "engines": {
2389
- "node": ">=14.0"
2390
- }
2391
- },
2392
- "node_modules/universalify": {
2393
- "version": "0.2.0",
2394
- "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
2395
- "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg==",
2396
- "engines": {
2397
- "node": ">= 4.0.0"
2398
- }
2399
- },
2400
2283
  "node_modules/unpipe": {
2401
2284
  "version": "1.0.0",
2402
2285
  "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
@@ -2405,15 +2288,6 @@
2405
2288
  "node": ">= 0.8"
2406
2289
  }
2407
2290
  },
2408
- "node_modules/url-parse": {
2409
- "version": "1.5.10",
2410
- "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
2411
- "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
2412
- "dependencies": {
2413
- "querystringify": "^2.1.1",
2414
- "requires-port": "^1.0.0"
2415
- }
2416
- },
2417
2291
  "node_modules/util-deprecate": {
2418
2292
  "version": "1.0.2",
2419
2293
  "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -2544,6 +2418,19 @@
2544
2418
  "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
2545
2419
  "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
2546
2420
  "optional": true
2421
+ },
2422
+ "node_modules/ytdl-core": {
2423
+ "version": "4.11.5",
2424
+ "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.11.5.tgz",
2425
+ "integrity": "sha512-27LwsW4n4nyNviRCO1hmr8Wr5J1wLLMawHCQvH8Fk0hiRqrxuIu028WzbJetiYH28K8XDbeinYW4/wcHQD1EXA==",
2426
+ "dependencies": {
2427
+ "m3u8stream": "^0.8.6",
2428
+ "miniget": "^4.2.2",
2429
+ "sax": "^1.1.3"
2430
+ },
2431
+ "engines": {
2432
+ "node": ">=12"
2433
+ }
2547
2434
  }
2548
2435
  },
2549
2436
  "dependencies": {
@@ -2651,23 +2538,6 @@
2651
2538
  "tslib": "^2.2.0"
2652
2539
  }
2653
2540
  },
2654
- "@distube/ytdl-core": {
2655
- "version": "4.13.2",
2656
- "resolved": "https://registry.npmjs.org/@distube/ytdl-core/-/ytdl-core-4.13.2.tgz",
2657
- "integrity": "sha512-FBjy4LXsBv34qFrmEF1dSbKWQtqB+yd0dt4MYYUq8oYys2Bvqps3QSFGTUZO5QA6nKD/XRsMJfcG5lgEJaUqiQ==",
2658
- "requires": {
2659
- "http-cookie-agent": "^5.0.4",
2660
- "m3u8stream": "^0.8.6",
2661
- "sax": "^1.2.4",
2662
- "tough-cookie": "^4.1.3",
2663
- "undici": "^5.25.2"
2664
- }
2665
- },
2666
- "@fastify/busboy": {
2667
- "version": "2.1.0",
2668
- "resolved": "https://registry.npmjs.org/@fastify/busboy/-/busboy-2.1.0.tgz",
2669
- "integrity": "sha512-+KpH+QxZU7O4675t3mnkQKcZZg56u+K/Ct2K+N2AZYNVK8kyeo/bI18tI8aPm3tvNNRyTWfj6s5tnGNlcbQRsA=="
2670
- },
2671
2541
  "@ioredis/commands": {
2672
2542
  "version": "1.2.0",
2673
2543
  "resolved": "https://registry.npmjs.org/@ioredis/commands/-/commands-1.2.0.tgz",
@@ -3433,24 +3303,6 @@
3433
3303
  "resolved": "https://registry.npmjs.org/http-cache-semantics/-/http-cache-semantics-4.1.1.tgz",
3434
3304
  "integrity": "sha512-er295DKPVsV82j5kw1Gjt+ADA/XYHsajl82cGNQG2eyoPkvgUhX+nDIyelzhIWbbsXP39EHcI6l5tYs2FYqYXQ=="
3435
3305
  },
3436
- "http-cookie-agent": {
3437
- "version": "5.0.4",
3438
- "resolved": "https://registry.npmjs.org/http-cookie-agent/-/http-cookie-agent-5.0.4.tgz",
3439
- "integrity": "sha512-OtvikW69RvfyP6Lsequ0fN5R49S+8QcS9zwd58k6VSr6r57T8G29BkPdyrBcSwLq6ExLs9V+rBlfxu7gDstJag==",
3440
- "requires": {
3441
- "agent-base": "^7.1.0"
3442
- },
3443
- "dependencies": {
3444
- "agent-base": {
3445
- "version": "7.1.0",
3446
- "resolved": "https://registry.npmjs.org/agent-base/-/agent-base-7.1.0.tgz",
3447
- "integrity": "sha512-o/zjMZRhJxny7OyEF+Op8X+efiELC7k7yOjMzgfzVqOzXqkBkWI79YoTdOtsuWd5BWhAGAuOY/Xa6xpiaWXiNg==",
3448
- "requires": {
3449
- "debug": "^4.3.4"
3450
- }
3451
- }
3452
- }
3453
- },
3454
3306
  "http-errors": {
3455
3307
  "version": "2.0.0",
3456
3308
  "resolved": "https://registry.npmjs.org/http-errors/-/http-errors-2.0.0.tgz",
@@ -3946,11 +3798,6 @@
3946
3798
  "resolved": "https://registry.npmjs.org/proxy-from-env/-/proxy-from-env-1.1.0.tgz",
3947
3799
  "integrity": "sha512-D+zkORCbA9f1tdWRK0RaCR3GPv50cMxcrz4X8k5LTSUD1Dkw47mKJEZQNunItRTkWwgtaUSo1RVFRIG9ZXiFYg=="
3948
3800
  },
3949
- "psl": {
3950
- "version": "1.9.0",
3951
- "resolved": "https://registry.npmjs.org/psl/-/psl-1.9.0.tgz",
3952
- "integrity": "sha512-E/ZsdU4HLs/68gYzgGTkMicWTLPdAftJLfJFlLUAAKZGkStNU72sZjT66SnMDVOfOWY/YAoiD7Jxa9iHvngcag=="
3953
- },
3954
3801
  "public-ip": {
3955
3802
  "version": "6.0.1",
3956
3803
  "resolved": "https://registry.npmjs.org/public-ip/-/public-ip-6.0.1.tgz",
@@ -3962,11 +3809,6 @@
3962
3809
  "is-ip": "^4.0.0"
3963
3810
  }
3964
3811
  },
3965
- "punycode": {
3966
- "version": "2.3.1",
3967
- "resolved": "https://registry.npmjs.org/punycode/-/punycode-2.3.1.tgz",
3968
- "integrity": "sha512-vYt7UD1U9Wg6138shLtLOvdAu+8DsC/ilFtEVHcH+wydcSpNE20AfSOduf6MkRFahL5FY7X1oU7nKVZFtfq8Fg=="
3969
- },
3970
3812
  "qs": {
3971
3813
  "version": "6.11.0",
3972
3814
  "resolved": "https://registry.npmjs.org/qs/-/qs-6.11.0.tgz",
@@ -3975,11 +3817,6 @@
3975
3817
  "side-channel": "^1.0.4"
3976
3818
  }
3977
3819
  },
3978
- "querystringify": {
3979
- "version": "2.2.0",
3980
- "resolved": "https://registry.npmjs.org/querystringify/-/querystringify-2.2.0.tgz",
3981
- "integrity": "sha512-FIqgj2EUvTa7R50u0rGsyTftzjYmv/a3hO345bZNrqabNqjtgiDMgmo4mkUjd+nzU5oF3dClKqFIPUKybUyqoQ=="
3982
- },
3983
3820
  "quick-lru": {
3984
3821
  "version": "5.1.1",
3985
3822
  "resolved": "https://registry.npmjs.org/quick-lru/-/quick-lru-5.1.1.tgz",
@@ -4025,11 +3862,6 @@
4025
3862
  "redis-errors": "^1.0.0"
4026
3863
  }
4027
3864
  },
4028
- "requires-port": {
4029
- "version": "1.0.0",
4030
- "resolved": "https://registry.npmjs.org/requires-port/-/requires-port-1.0.0.tgz",
4031
- "integrity": "sha512-KigOCHcocU3XODJxsu8i/j8T9tzT4adHiecwORRQ0ZZFcp7ahwXuRU1m+yuO90C5ZUyGeGfocHDI14M3L3yDAQ=="
4032
- },
4033
3865
  "resolve-alpn": {
4034
3866
  "version": "1.2.1",
4035
3867
  "resolved": "https://registry.npmjs.org/resolve-alpn/-/resolve-alpn-1.2.1.tgz",
@@ -4271,17 +4103,6 @@
4271
4103
  "resolved": "https://registry.npmjs.org/toidentifier/-/toidentifier-1.0.1.tgz",
4272
4104
  "integrity": "sha512-o5sSPKEkg/DIQNmH43V0/uerLrpzVedkUh8tGNvaeXpfpuwjKenlSox/2O/BTlZUtEe+JG7s5YhEz608PlAHRA=="
4273
4105
  },
4274
- "tough-cookie": {
4275
- "version": "4.1.3",
4276
- "resolved": "https://registry.npmjs.org/tough-cookie/-/tough-cookie-4.1.3.tgz",
4277
- "integrity": "sha512-aX/y5pVRkfRnfmuX+OdbSdXvPe6ieKX/G2s7e98f4poJHnqH3281gDPm/metm6E/WRamfx7WC4HUqkWHfQHprw==",
4278
- "requires": {
4279
- "psl": "^1.1.33",
4280
- "punycode": "^2.1.1",
4281
- "universalify": "^0.2.0",
4282
- "url-parse": "^1.5.3"
4283
- }
4284
- },
4285
4106
  "tr46": {
4286
4107
  "version": "0.0.3",
4287
4108
  "resolved": "https://registry.npmjs.org/tr46/-/tr46-0.0.3.tgz",
@@ -4311,33 +4132,11 @@
4311
4132
  "resolved": "https://registry.npmjs.org/underscore/-/underscore-1.13.6.tgz",
4312
4133
  "integrity": "sha512-+A5Sja4HP1M08MaXya7p5LvjuM7K6q/2EaC0+iovj/wOcMsTzMvDFbasi/oSapiwOlt252IqsKqPjCl7huKS0A=="
4313
4134
  },
4314
- "undici": {
4315
- "version": "5.27.2",
4316
- "resolved": "https://registry.npmjs.org/undici/-/undici-5.27.2.tgz",
4317
- "integrity": "sha512-iS857PdOEy/y3wlM3yRp+6SNQQ6xU0mmZcwRSriqk+et/cwWAtwmIGf6WkoDN2EK/AMdCO/dfXzIwi+rFMrjjQ==",
4318
- "requires": {
4319
- "@fastify/busboy": "^2.0.0"
4320
- }
4321
- },
4322
- "universalify": {
4323
- "version": "0.2.0",
4324
- "resolved": "https://registry.npmjs.org/universalify/-/universalify-0.2.0.tgz",
4325
- "integrity": "sha512-CJ1QgKmNg3CwvAv/kOFmtnEN05f0D/cn9QntgNOQlQF9dgvVTHj3t+8JPdjqawCHk7V/KA+fbUqzZ9XWhcqPUg=="
4326
- },
4327
4135
  "unpipe": {
4328
4136
  "version": "1.0.0",
4329
4137
  "resolved": "https://registry.npmjs.org/unpipe/-/unpipe-1.0.0.tgz",
4330
4138
  "integrity": "sha512-pjy2bYhSsufwWlKwPc+l3cN7+wuJlK6uz0YdJEOlQDbl6jo/YlPi4mb8agUkVC8BF7V8NuzeyPNqRksA3hztKQ=="
4331
4139
  },
4332
- "url-parse": {
4333
- "version": "1.5.10",
4334
- "resolved": "https://registry.npmjs.org/url-parse/-/url-parse-1.5.10.tgz",
4335
- "integrity": "sha512-WypcfiRhfeUP9vvF0j6rw0J3hrWrw6iZv3+22h6iRMJ/8z1Tj6XfLP4DsUix5MhMPnXpiHDoKyoZ/bdCkwBCiQ==",
4336
- "requires": {
4337
- "querystringify": "^2.1.1",
4338
- "requires-port": "^1.0.0"
4339
- }
4340
- },
4341
4140
  "util-deprecate": {
4342
4141
  "version": "1.0.2",
4343
4142
  "resolved": "https://registry.npmjs.org/util-deprecate/-/util-deprecate-1.0.2.tgz",
@@ -4438,6 +4237,16 @@
4438
4237
  "resolved": "https://registry.npmjs.org/yallist/-/yallist-4.0.0.tgz",
4439
4238
  "integrity": "sha512-3wdGidZyq5PB084XLES5TpOSRA3wjXAlIWMhum2kRcv/41Sn2emQ0dycQW4uZXLejwKvg6EsvbdlVL+FYEct7A==",
4440
4239
  "optional": true
4240
+ },
4241
+ "ytdl-core": {
4242
+ "version": "4.11.5",
4243
+ "resolved": "https://registry.npmjs.org/ytdl-core/-/ytdl-core-4.11.5.tgz",
4244
+ "integrity": "sha512-27LwsW4n4nyNviRCO1hmr8Wr5J1wLLMawHCQvH8Fk0hiRqrxuIu028WzbJetiYH28K8XDbeinYW4/wcHQD1EXA==",
4245
+ "requires": {
4246
+ "m3u8stream": "^0.8.6",
4247
+ "miniget": "^4.2.2",
4248
+ "sax": "^1.1.3"
4249
+ }
4441
4250
  }
4442
4251
  }
4443
4252
  }
@@ -9,7 +9,6 @@
9
9
  },
10
10
  "dependencies": {
11
11
  "@azure/storage-blob": "^12.13.0",
12
- "@distube/ytdl-core": "^4.13.2",
13
12
  "axios": "^1.3.6",
14
13
  "busboy": "^1.6.0",
15
14
  "cors": "^2.8.5",
@@ -21,6 +20,7 @@
21
20
  "pdfjs-dist": "^3.9.179",
22
21
  "public-ip": "^6.0.1",
23
22
  "uuid": "^9.0.0",
24
- "xlsx": "^0.18.5"
23
+ "xlsx": "^0.18.5",
24
+ "ytdl-core": "^4.11.5"
25
25
  }
26
26
  }
@@ -0,0 +1,27 @@
1
+ **/__pycache__
2
+ **/.venv
3
+ **/.classpath
4
+ **/.dockerignore
5
+ **/.env
6
+ **/.git
7
+ **/.gitignore
8
+ **/.project
9
+ **/.settings
10
+ **/.toolstarget
11
+ **/.vs
12
+ **/.vscode
13
+ **/*.*proj.user
14
+ **/*.dbmdl
15
+ **/*.jfm
16
+ **/bin
17
+ **/charts
18
+ **/docker-compose*
19
+ **/compose*
20
+ **/Dockerfile*
21
+ **/node_modules
22
+ **/npm-debug.log
23
+ **/obj
24
+ **/secrets.dev.yaml
25
+ **/values.dev.yaml
26
+ LICENSE
27
+ README.md
@@ -0,0 +1,32 @@
1
+ # For more information, please refer to https://aka.ms/vscode-docker-python
2
+ FROM python:3.10-slim
3
+
4
+ EXPOSE 8000
5
+
6
+ ## following 3 lines are for installing ffmepg
7
+ RUN apt-get -y update
8
+ RUN apt-get -y upgrade
9
+ RUN apt-get install -y ffmpeg
10
+
11
+ # Keeps Python from generating .pyc files in the container
12
+ ENV PYTHONDONTWRITEBYTECODE=1
13
+
14
+ # Turns off buffering for easier container logging
15
+ ENV PYTHONUNBUFFERED=1
16
+
17
+ # Install pip requirements
18
+ COPY requirements.txt .
19
+ RUN python -m pip install -r requirements.txt
20
+
21
+ WORKDIR /app
22
+ COPY ./models /app/models
23
+ COPY . /app
24
+
25
+ # Creates a non-root user with an explicit UID and adds permission to access the /app folder
26
+ # For more info, please refer to https://aka.ms/vscode-docker-python-configure-containers
27
+ RUN adduser -u 5678 --disabled-password --gecos "" appuser && chown -R appuser /app
28
+ USER appuser
29
+
30
+ # During debugging, this entry point will be overridden. For more information, please refer to https://aka.ms/vscode-docker-python-debug
31
+ # CMD ["uvicorn", "app:app", "--host", "0.0.0.0", "--port", "8000"]
32
+ CMD ["gunicorn", "--bind", "0.0.0.0:8000", "--timeout", "0", "-k", "uvicorn.workers.UvicornWorker", "app:app"]