@proteinjs/conversation 1.0.1 → 1.0.2

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 (134) hide show
  1. package/CHANGELOG.md +8 -0
  2. package/dist/index.d.ts +12 -0
  3. package/dist/index.d.ts.map +1 -0
  4. package/dist/index.js +1 -0
  5. package/dist/index.js.map +1 -0
  6. package/dist/src/CodegenConversation.d.ts +13 -0
  7. package/dist/src/CodegenConversation.d.ts.map +1 -0
  8. package/dist/src/CodegenConversation.js +128 -57
  9. package/dist/src/CodegenConversation.js.map +1 -0
  10. package/dist/src/Conversation.d.ts +60 -0
  11. package/dist/src/Conversation.d.ts.map +1 -0
  12. package/dist/src/Conversation.js +202 -102
  13. package/dist/src/Conversation.js.map +1 -0
  14. package/dist/src/ConversationModule.d.ts +12 -0
  15. package/dist/src/ConversationModule.d.ts.map +1 -0
  16. package/dist/src/ConversationModule.js +1 -0
  17. package/dist/src/ConversationModule.js.map +1 -0
  18. package/dist/src/Function.d.ts +7 -0
  19. package/dist/src/Function.d.ts.map +1 -0
  20. package/dist/src/Function.js +1 -0
  21. package/dist/src/Function.js.map +1 -0
  22. package/dist/src/OpenAi.d.ts +18 -0
  23. package/dist/src/OpenAi.d.ts.map +1 -0
  24. package/dist/src/OpenAi.js +265 -169
  25. package/dist/src/OpenAi.js.map +1 -0
  26. package/dist/src/Paragraph.d.ts +7 -0
  27. package/dist/src/Paragraph.d.ts.map +1 -0
  28. package/dist/src/Paragraph.js +9 -7
  29. package/dist/src/Paragraph.js.map +1 -0
  30. package/dist/src/Sentence.d.ts +6 -0
  31. package/dist/src/Sentence.d.ts.map +1 -0
  32. package/dist/src/Sentence.js +10 -8
  33. package/dist/src/Sentence.js.map +1 -0
  34. package/dist/src/code_template/Code.d.ts +24 -0
  35. package/dist/src/code_template/Code.d.ts.map +1 -0
  36. package/dist/src/code_template/Code.js +57 -22
  37. package/dist/src/code_template/Code.js.map +1 -0
  38. package/dist/src/code_template/CodeTemplate.d.ts +18 -0
  39. package/dist/src/code_template/CodeTemplate.d.ts.map +1 -0
  40. package/dist/src/code_template/CodeTemplate.js +68 -20
  41. package/dist/src/code_template/CodeTemplate.js.map +1 -0
  42. package/dist/src/code_template/CodeTemplateModule.d.ts +11 -0
  43. package/dist/src/code_template/CodeTemplateModule.d.ts.map +1 -0
  44. package/dist/src/code_template/CodeTemplateModule.js +20 -16
  45. package/dist/src/code_template/CodeTemplateModule.js.map +1 -0
  46. package/dist/src/code_template/Repo.d.ts +50 -0
  47. package/dist/src/code_template/Repo.d.ts.map +1 -0
  48. package/dist/src/code_template/Repo.js +161 -80
  49. package/dist/src/code_template/Repo.js.map +1 -0
  50. package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts +24 -0
  51. package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts.map +1 -0
  52. package/dist/src/fs/conversation_fs/ConversationFsModerator.js +45 -36
  53. package/dist/src/fs/conversation_fs/ConversationFsModerator.js.map +1 -0
  54. package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts +18 -0
  55. package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts.map +1 -0
  56. package/dist/src/fs/conversation_fs/ConversationFsModule.js +84 -41
  57. package/dist/src/fs/conversation_fs/ConversationFsModule.js.map +1 -0
  58. package/dist/src/fs/conversation_fs/FsFunctions.d.ts +82 -0
  59. package/dist/src/fs/conversation_fs/FsFunctions.d.ts.map +1 -0
  60. package/dist/src/fs/conversation_fs/FsFunctions.js +105 -30
  61. package/dist/src/fs/conversation_fs/FsFunctions.js.map +1 -0
  62. package/dist/src/fs/git/GitModule.d.ts +14 -0
  63. package/dist/src/fs/git/GitModule.d.ts.map +1 -0
  64. package/dist/src/fs/git/GitModule.js +65 -24
  65. package/dist/src/fs/git/GitModule.js.map +1 -0
  66. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts +23 -0
  67. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts.map +1 -0
  68. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js +35 -5
  69. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js.map +1 -0
  70. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts +34 -0
  71. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts.map +1 -0
  72. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js +107 -50
  73. package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js.map +1 -0
  74. package/dist/src/fs/package/PackageFunctions.d.ts +79 -0
  75. package/dist/src/fs/package/PackageFunctions.d.ts.map +1 -0
  76. package/dist/src/fs/package/PackageFunctions.js +78 -16
  77. package/dist/src/fs/package/PackageFunctions.js.map +1 -0
  78. package/dist/src/fs/package/PackageModule.d.ts +34 -0
  79. package/dist/src/fs/package/PackageModule.d.ts.map +1 -0
  80. package/dist/src/fs/package/PackageModule.js +135 -62
  81. package/dist/src/fs/package/PackageModule.js.map +1 -0
  82. package/dist/src/history/MessageHistory.d.ts +17 -0
  83. package/dist/src/history/MessageHistory.d.ts.map +1 -0
  84. package/dist/src/history/MessageHistory.js +25 -22
  85. package/dist/src/history/MessageHistory.js.map +1 -0
  86. package/dist/src/history/MessageModerator.d.ts +5 -0
  87. package/dist/src/history/MessageModerator.d.ts.map +1 -0
  88. package/dist/src/history/MessageModerator.js +1 -0
  89. package/dist/src/history/MessageModerator.js.map +1 -0
  90. package/dist/src/template/ConversationTemplate.d.ts +12 -0
  91. package/dist/src/template/ConversationTemplate.d.ts.map +1 -0
  92. package/dist/src/template/ConversationTemplate.js +1 -0
  93. package/dist/src/template/ConversationTemplate.js.map +1 -0
  94. package/dist/src/template/ConversationTemplateFunctions.d.ts +44 -0
  95. package/dist/src/template/ConversationTemplateFunctions.d.ts.map +1 -0
  96. package/dist/src/template/ConversationTemplateFunctions.js +39 -4
  97. package/dist/src/template/ConversationTemplateFunctions.js.map +1 -0
  98. package/dist/src/template/ConversationTemplateModule.d.ts +65 -0
  99. package/dist/src/template/ConversationTemplateModule.d.ts.map +1 -0
  100. package/dist/src/template/ConversationTemplateModule.js +92 -47
  101. package/dist/src/template/ConversationTemplateModule.js.map +1 -0
  102. package/dist/src/template/createApp/CreateAppTemplate.d.ts +3 -0
  103. package/dist/src/template/createApp/CreateAppTemplate.d.ts.map +1 -0
  104. package/dist/src/template/createApp/CreateAppTemplate.js +44 -14
  105. package/dist/src/template/createApp/CreateAppTemplate.js.map +1 -0
  106. package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts +3 -0
  107. package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts.map +1 -0
  108. package/dist/src/template/createCode/CreateCodeConversationTemplate.js +56 -26
  109. package/dist/src/template/createCode/CreateCodeConversationTemplate.js.map +1 -0
  110. package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts +3 -0
  111. package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts.map +1 -0
  112. package/dist/src/template/createPackage/CreatePackageConversationTemplate.js +63 -26
  113. package/dist/src/template/createPackage/CreatePackageConversationTemplate.js.map +1 -0
  114. package/dist/test/createKeywordFilesIndex.test.d.ts +2 -0
  115. package/dist/test/createKeywordFilesIndex.test.d.ts.map +1 -0
  116. package/dist/test/createKeywordFilesIndex.test.js +37 -6
  117. package/dist/test/createKeywordFilesIndex.test.js.map +1 -0
  118. package/dist/test/openai/openai.generateList.test.d.ts +2 -0
  119. package/dist/test/openai/openai.generateList.test.d.ts.map +1 -0
  120. package/dist/test/openai/openai.generateList.test.js +43 -5
  121. package/dist/test/openai/openai.generateList.test.js.map +1 -0
  122. package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts +2 -0
  123. package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts.map +1 -0
  124. package/dist/test/openai/openai.parseCodeFromMarkdown.test.js +11 -10
  125. package/dist/test/openai/openai.parseCodeFromMarkdown.test.js.map +1 -0
  126. package/dist/test/repo/repo.test.d.ts +2 -0
  127. package/dist/test/repo/repo.test.d.ts.map +1 -0
  128. package/dist/test/repo/repo.test.js +33 -4
  129. package/dist/test/repo/repo.test.js.map +1 -0
  130. package/package.json +3 -2
  131. package/tsconfig.json +20 -106
  132. package/dist/jest.config.js +0 -10
  133. package/dist/src/template/createPackage/jest.config.js +0 -10
  134. package/dist/test/setup.js +0 -1
package/CHANGELOG.md CHANGED
@@ -3,6 +3,14 @@
3
3
  All notable changes to this project will be documented in this file.
4
4
  See [Conventional Commits](https://conventionalcommits.org) for commit guidelines.
5
5
 
6
+ ## [1.0.2](https://github.com/proteinjs/conversation/compare/@proteinjs/conversation@1.0.1...@proteinjs/conversation@1.0.2) (2024-04-19)
7
+
8
+ **Note:** Version bump only for package @proteinjs/conversation
9
+
10
+
11
+
12
+
13
+
6
14
  ## 1.0.1 (2024-04-19)
7
15
 
8
16
  **Note:** Version bump only for package @proteinjs/conversation
@@ -0,0 +1,12 @@
1
+ export * from './src/Sentence';
2
+ export * from './src/Paragraph';
3
+ export * from './src/OpenAi';
4
+ export * from './src/code_template/CodeTemplate';
5
+ export * from './src/Conversation';
6
+ export * from './src/CodegenConversation';
7
+ export * from './src/code_template/Code';
8
+ export * from './src/ConversationModule';
9
+ export * from './src/Function';
10
+ export * from './src/history/MessageModerator';
11
+ export * from './src/history/MessageHistory';
12
+ //# sourceMappingURL=index.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.d.ts","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":"AAAA,cAAc,gBAAgB,CAAC;AAC/B,cAAc,iBAAiB,CAAC;AAChC,cAAc,cAAc,CAAC;AAC7B,cAAc,kCAAkC,CAAC;AACjD,cAAc,oBAAoB,CAAC;AACnC,cAAc,2BAA2B,CAAC;AAC1C,cAAc,0BAA0B,CAAC;AACzC,cAAc,0BAA0B,CAAC;AACzC,cAAc,gBAAgB,CAAC;AAC/B,cAAc,gCAAgC,CAAC;AAC/C,cAAc,8BAA8B,CAAC"}
package/dist/index.js CHANGED
@@ -25,3 +25,4 @@ __exportStar(require("./src/ConversationModule"), exports);
25
25
  __exportStar(require("./src/Function"), exports);
26
26
  __exportStar(require("./src/history/MessageModerator"), exports);
27
27
  __exportStar(require("./src/history/MessageHistory"), exports);
28
+ //# sourceMappingURL=index.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"index.js","sourceRoot":"","sources":["../index.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;AAAA,iDAA+B;AAC/B,kDAAgC;AAChC,+CAA6B;AAC7B,mEAAiD;AACjD,qDAAmC;AACnC,4DAA0C;AAC1C,2DAAyC;AACzC,2DAAyC;AACzC,iDAA+B;AAC/B,iEAA+C;AAC/C,+DAA6C"}
@@ -0,0 +1,13 @@
1
+ export declare class CodegenConversation {
2
+ private static INITIAL_QUESTION;
3
+ private static BOT_NAME;
4
+ private static MODEL;
5
+ private repoPath;
6
+ constructor(repoPath: string);
7
+ start(): Promise<void>;
8
+ private createConversation;
9
+ private getModules;
10
+ private getSystemMessages;
11
+ private respondToUser;
12
+ }
13
+ //# sourceMappingURL=CodegenConversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodegenConversation.d.ts","sourceRoot":"","sources":["../../src/CodegenConversation.ts"],"names":[],"mappings":"AAcA,qBAAa,mBAAmB;IAC9B,OAAO,CAAC,MAAM,CAAC,gBAAgB,CAAoC;IACnE,OAAO,CAAC,MAAM,CAAC,QAAQ,CAAW;IAClC,OAAO,CAAC,MAAM,CAAC,KAAK,CAA0B;IAC9C,OAAO,CAAC,QAAQ,CAAS;gBAEb,QAAQ,EAAE,MAAM;IAItB,KAAK;YAWG,kBAAkB;YAUlB,UAAU;IAexB,OAAO,CAAC,iBAAiB;IA4BzB,OAAO,CAAC,aAAa;CAGtB"}
@@ -31,64 +31,133 @@ var __awaiter = (this && this.__awaiter) || function (thisArg, _arguments, P, ge
31
31
  step((generator = generator.apply(thisArg, _arguments || [])).next());
32
32
  });
33
33
  };
34
+ var __generator = (this && this.__generator) || function (thisArg, body) {
35
+ var _ = { label: 0, sent: function() { if (t[0] & 1) throw t[1]; return t[1]; }, trys: [], ops: [] }, f, y, t, g;
36
+ return g = { next: verb(0), "throw": verb(1), "return": verb(2) }, typeof Symbol === "function" && (g[Symbol.iterator] = function() { return this; }), g;
37
+ function verb(n) { return function (v) { return step([n, v]); }; }
38
+ function step(op) {
39
+ if (f) throw new TypeError("Generator is already executing.");
40
+ while (g && (g = 0, op[0] && (_ = 0)), _) try {
41
+ if (f = 1, y && (t = op[0] & 2 ? y["return"] : op[0] ? y["throw"] || ((t = y["return"]) && t.call(y), 0) : y.next) && !(t = t.call(y, op[1])).done) return t;
42
+ if (y = 0, t) op = [op[0] & 2, t.value];
43
+ switch (op[0]) {
44
+ case 0: case 1: t = op; break;
45
+ case 4: _.label++; return { value: op[1], done: false };
46
+ case 5: _.label++; y = op[1]; op = [0]; continue;
47
+ case 7: op = _.ops.pop(); _.trys.pop(); continue;
48
+ default:
49
+ if (!(t = _.trys, t = t.length > 0 && t[t.length - 1]) && (op[0] === 6 || op[0] === 2)) { _ = 0; continue; }
50
+ if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) { _.label = op[1]; break; }
51
+ if (op[0] === 6 && _.label < t[1]) { _.label = t[1]; t = op; break; }
52
+ if (t && _.label < t[2]) { _.label = t[2]; _.ops.push(op); break; }
53
+ if (t[2]) _.ops.pop();
54
+ _.trys.pop(); continue;
55
+ }
56
+ op = body.call(thisArg, _);
57
+ } catch (e) { op = [6, e]; y = 0; } finally { f = t = 0; }
58
+ if (op[0] & 5) throw op[1]; return { value: op[0] ? op[1] : void 0, done: true };
59
+ }
60
+ };
34
61
  Object.defineProperty(exports, "__esModule", { value: true });
35
62
  exports.CodegenConversation = void 0;
36
- const readline = __importStar(require("readline-sync"));
37
- const Conversation_1 = require("./Conversation");
38
- const KeywordToFilesIndexModule_1 = require("./fs/keyword_to_files_index/KeywordToFilesIndexModule");
39
- const ConversationTemplateModule_1 = require("./template/ConversationTemplateModule");
40
- const ConversationFsModule_1 = require("./fs/conversation_fs/ConversationFsModule");
41
- const PackageModule_1 = require("./fs/package/PackageModule");
42
- const util_1 = require("@proteinjs/util");
43
- const GitModule_1 = require("./fs/git/GitModule");
44
- class CodegenConversation {
45
- constructor(repoPath) {
63
+ var readline = __importStar(require("readline-sync"));
64
+ var Conversation_1 = require("./Conversation");
65
+ var KeywordToFilesIndexModule_1 = require("./fs/keyword_to_files_index/KeywordToFilesIndexModule");
66
+ var ConversationTemplateModule_1 = require("./template/ConversationTemplateModule");
67
+ var ConversationFsModule_1 = require("./fs/conversation_fs/ConversationFsModule");
68
+ var PackageModule_1 = require("./fs/package/PackageModule");
69
+ var util_1 = require("@proteinjs/util");
70
+ var GitModule_1 = require("./fs/git/GitModule");
71
+ var CodegenConversation = /** @class */ (function () {
72
+ function CodegenConversation(repoPath) {
46
73
  this.repoPath = repoPath;
47
74
  }
48
- start() {
49
- return __awaiter(this, void 0, void 0, function* () {
50
- const conversation = yield this.createConversation();
51
- conversation.addAssistantMessagesToHistory([CodegenConversation.INITIAL_QUESTION]);
52
- const initialUserInput = this.respondToUser(CodegenConversation.INITIAL_QUESTION);
53
- let response = yield conversation.generateResponse([initialUserInput], CodegenConversation.MODEL);
54
- while (true) {
55
- const userInput = this.respondToUser(response);
56
- response = yield conversation.generateResponse([userInput], CodegenConversation.MODEL);
57
- }
75
+ CodegenConversation.prototype.start = function () {
76
+ return __awaiter(this, void 0, void 0, function () {
77
+ var conversation, initialUserInput, response, userInput;
78
+ return __generator(this, function (_a) {
79
+ switch (_a.label) {
80
+ case 0: return [4 /*yield*/, this.createConversation()];
81
+ case 1:
82
+ conversation = _a.sent();
83
+ conversation.addAssistantMessagesToHistory([CodegenConversation.INITIAL_QUESTION]);
84
+ initialUserInput = this.respondToUser(CodegenConversation.INITIAL_QUESTION);
85
+ return [4 /*yield*/, conversation.generateResponse([initialUserInput], CodegenConversation.MODEL)];
86
+ case 2:
87
+ response = _a.sent();
88
+ _a.label = 3;
89
+ case 3:
90
+ if (!true) return [3 /*break*/, 5];
91
+ userInput = this.respondToUser(response);
92
+ return [4 /*yield*/, conversation.generateResponse([userInput], CodegenConversation.MODEL)];
93
+ case 4:
94
+ response = _a.sent();
95
+ return [3 /*break*/, 3];
96
+ case 5: return [2 /*return*/];
97
+ }
98
+ });
58
99
  });
59
- }
60
- createConversation() {
61
- return __awaiter(this, void 0, void 0, function* () {
62
- const conversation = new Conversation_1.Conversation({
63
- name: this.constructor.name,
64
- modules: yield this.getModules(),
65
- logLevel: 'info',
100
+ };
101
+ CodegenConversation.prototype.createConversation = function () {
102
+ return __awaiter(this, void 0, void 0, function () {
103
+ var conversation, _a;
104
+ var _b;
105
+ return __generator(this, function (_c) {
106
+ switch (_c.label) {
107
+ case 0:
108
+ _a = Conversation_1.Conversation.bind;
109
+ _b = {
110
+ name: this.constructor.name
111
+ };
112
+ return [4 /*yield*/, this.getModules()];
113
+ case 1:
114
+ conversation = new (_a.apply(Conversation_1.Conversation, [void 0, (_b.modules = _c.sent(),
115
+ _b.logLevel = 'info',
116
+ _b)]))();
117
+ conversation.addSystemMessagesToHistory(this.getSystemMessages());
118
+ return [2 /*return*/, conversation];
119
+ }
66
120
  });
67
- conversation.addSystemMessagesToHistory(this.getSystemMessages());
68
- return conversation;
69
121
  });
70
- }
71
- getModules() {
72
- return __awaiter(this, void 0, void 0, function* () {
73
- const moduleFactories = [
74
- new ConversationFsModule_1.ConversationFsModuleFactory(),
75
- new KeywordToFilesIndexModule_1.KeywordToFilesIndexModuleFactory(),
76
- new PackageModule_1.PackageModuleFactory(),
77
- new ConversationTemplateModule_1.ConversationTemplateModuleFactory(),
78
- new GitModule_1.GitModuleFactory(),
79
- ];
80
- const modules = [];
81
- for (let moduleFactory of moduleFactories)
82
- modules.push(yield moduleFactory.createModule(this.repoPath));
83
- return modules;
122
+ };
123
+ CodegenConversation.prototype.getModules = function () {
124
+ return __awaiter(this, void 0, void 0, function () {
125
+ var moduleFactories, modules, _i, moduleFactories_1, moduleFactory, _a, _b;
126
+ return __generator(this, function (_c) {
127
+ switch (_c.label) {
128
+ case 0:
129
+ moduleFactories = [
130
+ new ConversationFsModule_1.ConversationFsModuleFactory(),
131
+ new KeywordToFilesIndexModule_1.KeywordToFilesIndexModuleFactory(),
132
+ new PackageModule_1.PackageModuleFactory(),
133
+ new ConversationTemplateModule_1.ConversationTemplateModuleFactory(),
134
+ new GitModule_1.GitModuleFactory(),
135
+ ];
136
+ modules = [];
137
+ _i = 0, moduleFactories_1 = moduleFactories;
138
+ _c.label = 1;
139
+ case 1:
140
+ if (!(_i < moduleFactories_1.length)) return [3 /*break*/, 4];
141
+ moduleFactory = moduleFactories_1[_i];
142
+ _b = (_a = modules).push;
143
+ return [4 /*yield*/, moduleFactory.createModule(this.repoPath)];
144
+ case 2:
145
+ _b.apply(_a, [_c.sent()]);
146
+ _c.label = 3;
147
+ case 3:
148
+ _i++;
149
+ return [3 /*break*/, 1];
150
+ case 4: return [2 /*return*/, modules];
151
+ }
152
+ });
84
153
  });
85
- }
86
- getSystemMessages() {
154
+ };
155
+ CodegenConversation.prototype.getSystemMessages = function () {
87
156
  return [
88
- `We are going to have a conversation with the user to generate code`,
89
- `Await all function calls that return a promise`,
90
- `Try to repspond to the user with as few words as possible while still having a conversational tone`,
91
- `When generating code, export the objects you create inline; do not use 'export default' syntax`,
157
+ "We are going to have a conversation with the user to generate code",
158
+ "Await all function calls that return a promise",
159
+ "Try to repspond to the user with as few words as possible while still having a conversational tone",
160
+ "When generating code, export the objects you create inline; do not use 'export default' syntax",
92
161
  // `After finding a file to work with, assume the user's following question pertains to that file and use ${readFilesFunctionName} to read the file if needed`,
93
162
  // `If a conversation summary exists, if you aren't already working with a file, use the most relevant keyword mentioned in the conversation summary to find a file to read (using the ${searchFilesFunctionName} function) and then respond to the user after reading the file`,
94
163
  // `Use the most relevant keyword mentioned in the conversation summary to find a file to read (using the ${searchFilesFunctionName} function) and then respond to the user after reading the file`,
@@ -109,12 +178,14 @@ class CodegenConversation {
109
178
  // `If there is a conversation summary assistant message, use that to pick a file to read before responding to the user if not already working with a specific file`,
110
179
  // `Check for a previous conversation summary assistant message in the chat history; if there is one and it mentions a file the user was working with, call ${searchLibrariesFunctionName} to find the file path then call ${readFilesFunctionName} to read the file. Do this to build context before responding to the user`,
111
180
  ];
112
- }
113
- respondToUser(message) {
114
- return readline.question(`${util_1.textColorMap.cyan}[${CodegenConversation.BOT_NAME}] ${message}${util_1.Reset}\n`);
115
- }
116
- }
181
+ };
182
+ CodegenConversation.prototype.respondToUser = function (message) {
183
+ return readline.question("".concat(util_1.textColorMap.cyan, "[").concat(CodegenConversation.BOT_NAME, "] ").concat(message).concat(util_1.Reset, "\n"));
184
+ };
185
+ CodegenConversation.INITIAL_QUESTION = 'What would you like to create?';
186
+ CodegenConversation.BOT_NAME = 'Alina';
187
+ CodegenConversation.MODEL = 'gpt-4'; //'gpt-3.5-turbo-16k';
188
+ return CodegenConversation;
189
+ }());
117
190
  exports.CodegenConversation = CodegenConversation;
118
- CodegenConversation.INITIAL_QUESTION = 'What would you like to create?';
119
- CodegenConversation.BOT_NAME = 'Alina';
120
- CodegenConversation.MODEL = 'gpt-4'; //'gpt-3.5-turbo-16k';
191
+ //# sourceMappingURL=CodegenConversation.js.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"CodegenConversation.js","sourceRoot":"","sources":["../../src/CodegenConversation.ts"],"names":[],"mappings":";;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;;AAAA,sDAA0C;AAC1C,+CAA8C;AAC9C,mGAAyG;AACzG,oFAA0F;AAC1F,kFAAwF;AACxF,4DAAkE;AAElE,wCAAsD;AACtD,gDAAsD;AAMtD;IAME,6BAAY,QAAgB;QAC1B,IAAI,CAAC,QAAQ,GAAG,QAAQ,CAAC;IAC3B,CAAC;IAEK,mCAAK,GAAX;;;;;4BACuB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AAA,CAAA,KAAA,OAAO,CAAA,CAAC,IAAI,CAAA;wBAAC,qBAAM,aAAa,CAAC,YAAY,CAAC,IAAI,CAAC,QAAQ,CAAC,EAAA;;wBAA5D,cAAa,SAA+C,EAAC,CAAC;;;wBADtC,IAAe,CAAA;;4BAGzC,sBAAO,OAAO,EAAC;;;;KAChB;IAEO,+CAAiB,GAAzB;QACE,OAAO;YACL,oEAAoE;YACpE,gDAAgD;YAChD,oGAAoG;YACpG,gGAAgG;YAChG,+JAA+J;YAC/J,iRAAiR;YACjR,oMAAoM;YACpM,qQAAqQ;YACrQ,EAAE;YACF,yFAAyF;YACzF,qGAAqG;YACrG,kTAAkT;YAClT,8QAA8Q;YAC9Q,GAAG;YACH,8MAA8M;YAC9M,0QAA0Q;YAC1Q,yEAAyE;YACzE,2LAA2L;YAC3L,GAAG;YACH,uOAAuO;YACvO,0GAA0G;YAC1G,qKAAqK;YACrK,8TAA8T;SAC/T,CAAC;IACJ,CAAC;IAEO,2CAAa,GAArB,UAAsB,OAAe;QACnC,OAAO,QAAQ,CAAC,QAAQ,CAAC,UAAG,mBAAY,CAAC,IAAI,cAAI,mBAAmB,CAAC,QAAQ,eAAK,OAAO,SAAG,YAAK,OAAI,CAAC,CAAC;IACzG,CAAC;IA3Ec,oCAAgB,GAAG,gCAAgC,CAAC;IACpD,4BAAQ,GAAG,OAAO,CAAC;IACnB,yBAAK,GAAkB,OAAO,CAAC,CAAC,sBAAsB;IA0EvE,0BAAC;CAAA,AA7ED,IA6EC;AA7EY,kDAAmB"}
@@ -0,0 +1,60 @@
1
+ import { LogLevel } from '@proteinjs/util';
2
+ import { ConversationModule } from './ConversationModule';
3
+ import { TiktokenModel } from 'tiktoken';
4
+ export type ConversationParams = {
5
+ name: string;
6
+ modules?: ConversationModule[];
7
+ logLevel?: LogLevel;
8
+ limits?: {
9
+ enforceLimits?: boolean;
10
+ maxMessagesInHistory?: number;
11
+ tokenLimit?: number;
12
+ };
13
+ };
14
+ export declare class Conversation {
15
+ private tokenLimit;
16
+ private history;
17
+ private systemMessages;
18
+ private functions;
19
+ private messageModerators;
20
+ private generatedCode;
21
+ private generatedList;
22
+ private logger;
23
+ private params;
24
+ constructor(params: ConversationParams);
25
+ private addModules;
26
+ private addFunctions;
27
+ private addMessageModerators;
28
+ private enforceTokenLimit;
29
+ summarizeConversationHistory(summary: string): void;
30
+ private clearHistory;
31
+ addSystemMessagesToHistory(messages: string[], unshift?: boolean): void;
32
+ addAssistantMessagesToHistory(messages: string[], unshift?: boolean): void;
33
+ addUserMessagesToHistory(messages: string[], unshift?: boolean): void;
34
+ generateResponse(messages: string[], model?: TiktokenModel): Promise<string>;
35
+ generateCode(description: string[], model?: TiktokenModel): Promise<string>;
36
+ updateCodeFromFile(codeToUpdateFilePath: string, dependencyCodeFilePaths: string[], description: string, model?: TiktokenModel): Promise<string>;
37
+ updateCode(code: string, description: string, model?: TiktokenModel): Promise<string>;
38
+ generateList(description: string[], model?: TiktokenModel): Promise<string[]>;
39
+ }
40
+ export declare const summarizeConversationHistoryFunctionName = "summarizeConversationHistory";
41
+ export declare const summarizeConversationHistoryFunction: (conversation: Conversation) => {
42
+ definition: {
43
+ name: string;
44
+ description: string;
45
+ parameters: {
46
+ type: string;
47
+ properties: {
48
+ summary: {
49
+ type: string;
50
+ description: string;
51
+ };
52
+ };
53
+ required: string[];
54
+ };
55
+ };
56
+ call: (params: {
57
+ summary: string;
58
+ }) => Promise<void>;
59
+ };
60
+ //# sourceMappingURL=Conversation.d.ts.map
@@ -0,0 +1 @@
1
+ {"version":3,"file":"Conversation.d.ts","sourceRoot":"","sources":["../../src/Conversation.ts"],"names":[],"mappings":"AAIA,OAAO,EAAU,QAAQ,EAAE,MAAM,iBAAiB,CAAC;AAGnD,OAAO,EAAE,kBAAkB,EAAE,MAAM,sBAAsB,CAAC;AAC1D,OAAO,EAAE,aAAa,EAAsB,MAAM,UAAU,CAAC;AAG7D,MAAM,MAAM,kBAAkB,GAAG;IAC/B,IAAI,EAAE,M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