@aj-archipelago/cortex 0.0.10 → 1.0.0

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 (44) hide show
  1. package/README.md +192 -28
  2. package/config.js +17 -11
  3. package/graphql/chunker.js +3 -3
  4. package/graphql/graphql.js +19 -22
  5. package/graphql/parser.js +1 -1
  6. package/graphql/pathwayPrompter.js +8 -9
  7. package/graphql/pathwayResolver.js +11 -13
  8. package/graphql/pathwayResponseParser.js +2 -2
  9. package/graphql/plugins/azureTranslatePlugin.js +2 -2
  10. package/graphql/plugins/modelPlugin.js +7 -6
  11. package/graphql/plugins/openAiChatPlugin.js +2 -2
  12. package/graphql/plugins/openAiCompletionPlugin.js +4 -3
  13. package/graphql/plugins/openAiWhisperPlugin.js +7 -6
  14. package/graphql/prompt.js +1 -1
  15. package/graphql/pubsub.js +2 -2
  16. package/graphql/requestState.js +1 -1
  17. package/graphql/resolver.js +4 -4
  18. package/graphql/subscriptions.js +5 -4
  19. package/graphql/typeDef.js +53 -53
  20. package/index.js +5 -5
  21. package/lib/fileChunker.js +15 -11
  22. package/lib/keyValueStorageClient.js +5 -5
  23. package/lib/promiser.js +2 -2
  24. package/lib/request.js +11 -9
  25. package/lib/requestMonitor.js +2 -2
  26. package/package.json +4 -2
  27. package/pathways/basePathway.js +5 -4
  28. package/pathways/bias.js +2 -2
  29. package/pathways/chat.js +3 -2
  30. package/pathways/complete.js +4 -2
  31. package/pathways/edit.js +3 -2
  32. package/pathways/entities.js +3 -2
  33. package/pathways/index.js +25 -12
  34. package/pathways/lc_test.mjs +99 -0
  35. package/pathways/paraphrase.js +3 -2
  36. package/pathways/sentiment.js +3 -2
  37. package/pathways/summary.js +6 -4
  38. package/pathways/transcribe.js +4 -2
  39. package/pathways/translate.js +3 -2
  40. package/start.js +5 -2
  41. package/tests/chunkfunction.test.js +3 -4
  42. package/tests/chunking.test.js +8 -3
  43. package/tests/main.test.js +28 -14
  44. package/tests/translate.test.js +8 -4
package/start.js CHANGED
@@ -1,3 +1,6 @@
1
- const { startServer } = require('./index')();
1
+ import startServerFactory from './index.js';
2
2
 
3
- startServer && startServer();
3
+ (async () => {
4
+ const { startServer } = await startServerFactory();
5
+ startServer && startServer();
6
+ })();
@@ -1,7 +1,6 @@
1
- const test = require('ava');
2
-
3
- const { getSemanticChunks } = require('../graphql/chunker');
4
- const { encode } = require('gpt-3-encoder')
1
+ import test from 'ava';
2
+ import { getSemanticChunks } from '../graphql/chunker.js';
3
+ import { encode } from 'gpt-3-encoder';
5
4
 
6
5
  const testText = `Lorem ipsum dolor sit amet, consectetur adipiscing elit. In id erat sem. Phasellus ac dapibus purus, in fermentum nunc. Mauris quis rutrum magna. Quisque rutrum, augue vel blandit posuere, augue magna convallis turpis, nec elementum augue mauris sit amet nunc. Aenean sit amet leo est. Nunc ante ex, blandit et felis ut, iaculis lacinia est. Phasellus dictum orci id libero ullamcorper tempor.
7
6
 
@@ -1,7 +1,12 @@
1
- const test = require('ava');
2
- const { getTestServer } = require('./main.test');
1
+ import test from 'ava';
2
+ import { getTestServer, initTypeDefsResolvers } from './main.test.js';
3
3
 
4
- const testServer = getTestServer();
4
+ let testServer;
5
+
6
+ test.before(async () => {
7
+ await initTypeDefsResolvers();
8
+ testServer = getTestServer();
9
+ });
5
10
 
6
11
  test.after.always(async () => {
7
12
  await testServer.stop();
@@ -1,22 +1,35 @@
1
- const test = require('ava');
1
+ import test from 'ava';
2
+ import { ApolloServer } from 'apollo-server';
3
+ import { config } from '../config.js';
4
+ import typeDefsresolversFactory from '../index.js';
2
5
 
3
- const { ApolloServer } = require('apollo-server');
4
- const { config } = require('../config');
5
- const { typeDefs, resolvers } = require('../index')();
6
+ let typeDefs;
7
+ let resolvers;
6
8
 
7
- const getTestServer = () => {
8
- return new ApolloServer({
9
- typeDefs,
10
- resolvers,
11
- context: () => ({ config, requestState: {} }),
12
- });
13
- }
9
+ const initTypeDefsResolvers = async () => {
10
+ const result = await typeDefsresolversFactory();
11
+ typeDefs = result.typeDefs;
12
+ resolvers = result.resolvers;
13
+ };
14
14
 
15
- const testServer = getTestServer();
15
+ const getTestServer = () => {
16
+ return new ApolloServer({
17
+ typeDefs,
18
+ resolvers,
19
+ context: () => ({ config, requestState: {} }),
20
+ });
21
+ };
22
+
23
+ let testServer;
24
+
25
+ test.before(async () => {
26
+ await initTypeDefsResolvers();
27
+ testServer = getTestServer();
28
+ });
16
29
 
17
30
  //stop server after all tests
18
31
  test.after.always('cleanup', async () => {
19
- await testServer.stop();
32
+ await testServer.stop();
20
33
  });
21
34
 
22
35
  test('validates bias endpoint', async (t) => {
@@ -93,6 +106,7 @@ test('validates summary endpoint', async (t) => {
93
106
  t.truthy(response.data?.summary.result);
94
107
  });
95
108
 
96
- module.exports = {
109
+ export {
110
+ initTypeDefsResolvers,
97
111
  getTestServer,
98
112
  };
@@ -1,9 +1,13 @@
1
- const test = require('ava');
2
- const { getTestServer } = require('./main.test');
1
+ import test from 'ava';
2
+ import { getTestServer, initTypeDefsResolvers } from './main.test.js';
3
3
 
4
- const testServer = getTestServer();
4
+ let testServer;
5
+
6
+ test.before(async () => {
7
+ await initTypeDefsResolvers();
8
+ testServer = getTestServer();
9
+ });
5
10
 
6
- // stop server after all tests
7
11
  test.after.always(async () => {
8
12
  await testServer.stop();
9
13
  });