@proteinjs/conversation 1.0.5 → 1.0.7
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/.eslintrc.js +20 -0
- package/.prettierrc +8 -0
- package/CHANGELOG.md +7 -4
- package/LICENSE +21 -0
- package/dist/index.d.ts +1 -1
- package/dist/index.js +40 -28
- package/dist/src/CodegenConversation.d.ts +11 -11
- package/dist/src/CodegenConversation.d.ts.map +1 -1
- package/dist/src/CodegenConversation.js +294 -180
- package/dist/src/CodegenConversation.js.map +1 -1
- package/dist/src/Conversation.d.ts +52 -49
- package/dist/src/Conversation.d.ts.map +1 -1
- package/dist/src/Conversation.js +480 -274
- package/dist/src/Conversation.js.map +1 -1
- package/dist/src/ConversationModule.d.ts +6 -6
- package/dist/src/ConversationModule.js +3 -3
- package/dist/src/Function.d.ts +4 -4
- package/dist/src/Function.d.ts.map +1 -1
- package/dist/src/Function.js +3 -3
- package/dist/src/OpenAi.d.ts +42 -10
- package/dist/src/OpenAi.d.ts.map +1 -1
- package/dist/src/OpenAi.js +496 -289
- package/dist/src/OpenAi.js.map +1 -1
- package/dist/src/Paragraph.d.ts +4 -4
- package/dist/src/Paragraph.d.ts.map +1 -1
- package/dist/src/Paragraph.js +17 -16
- package/dist/src/Paragraph.js.map +1 -1
- package/dist/src/Sentence.d.ts +4 -4
- package/dist/src/Sentence.d.ts.map +1 -1
- package/dist/src/Sentence.js +21 -19
- package/dist/src/Sentence.js.map +1 -1
- package/dist/src/code_template/Code.d.ts +15 -15
- package/dist/src/code_template/Code.d.ts.map +1 -1
- package/dist/src/code_template/Code.js +167 -69
- package/dist/src/code_template/Code.js.map +1 -1
- package/dist/src/code_template/CodeTemplate.d.ts +11 -11
- package/dist/src/code_template/CodeTemplate.d.ts.map +1 -1
- package/dist/src/code_template/CodeTemplate.js +169 -79
- package/dist/src/code_template/CodeTemplate.js.map +1 -1
- package/dist/src/code_template/CodeTemplateModule.d.ts +6 -6
- package/dist/src/code_template/CodeTemplateModule.js +28 -26
- package/dist/src/code_template/Repo.d.ts +34 -38
- package/dist/src/code_template/Repo.d.ts.map +1 -1
- package/dist/src/code_template/Repo.js +291 -191
- package/dist/src/code_template/Repo.js.map +1 -1
- package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts +12 -12
- package/dist/src/fs/conversation_fs/ConversationFsModerator.d.ts.map +1 -1
- package/dist/src/fs/conversation_fs/ConversationFsModerator.js +111 -98
- package/dist/src/fs/conversation_fs/ConversationFsModerator.js.map +1 -1
- package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts +11 -11
- package/dist/src/fs/conversation_fs/ConversationFsModule.d.ts.map +1 -1
- package/dist/src/fs/conversation_fs/ConversationFsModule.js +204 -99
- package/dist/src/fs/conversation_fs/ConversationFsModule.js.map +1 -1
- package/dist/src/fs/conversation_fs/FsFunctions.d.ts +58 -62
- package/dist/src/fs/conversation_fs/FsFunctions.d.ts.map +1 -1
- package/dist/src/fs/conversation_fs/FsFunctions.js +414 -266
- package/dist/src/fs/conversation_fs/FsFunctions.js.map +1 -1
- package/dist/src/fs/git/GitModule.d.ts +8 -8
- package/dist/src/fs/git/GitModule.d.ts.map +1 -1
- package/dist/src/fs/git/GitModule.js +163 -74
- package/dist/src/fs/git/GitModule.js.map +1 -1
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts +16 -18
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.d.ts.map +1 -1
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js +158 -58
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.js.map +1 -1
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts +27 -26
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.d.ts.map +1 -1
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js +234 -133
- package/dist/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.js.map +1 -1
- package/dist/src/fs/package/PackageFunctions.d.ts +54 -60
- package/dist/src/fs/package/PackageFunctions.d.ts.map +1 -1
- package/dist/src/fs/package/PackageFunctions.js +366 -223
- package/dist/src/fs/package/PackageFunctions.js.map +1 -1
- package/dist/src/fs/package/PackageModule.d.ts +24 -24
- package/dist/src/fs/package/PackageModule.d.ts.map +1 -1
- package/dist/src/fs/package/PackageModule.js +292 -163
- package/dist/src/fs/package/PackageModule.js.map +1 -1
- package/dist/src/history/MessageHistory.d.ts +12 -12
- package/dist/src/history/MessageHistory.d.ts.map +1 -1
- package/dist/src/history/MessageHistory.js +52 -43
- package/dist/src/history/MessageHistory.js.map +1 -1
- package/dist/src/history/MessageModerator.d.ts +2 -2
- package/dist/src/history/MessageModerator.js +3 -3
- package/dist/src/template/ConversationTemplate.d.ts +8 -8
- package/dist/src/template/ConversationTemplate.d.ts.map +1 -1
- package/dist/src/template/ConversationTemplate.js +3 -3
- package/dist/src/template/ConversationTemplateFunctions.d.ts +33 -35
- package/dist/src/template/ConversationTemplateFunctions.d.ts.map +1 -1
- package/dist/src/template/ConversationTemplateFunctions.js +176 -75
- package/dist/src/template/ConversationTemplateFunctions.js.map +1 -1
- package/dist/src/template/ConversationTemplateModule.d.ts +51 -48
- package/dist/src/template/ConversationTemplateModule.d.ts.map +1 -1
- package/dist/src/template/ConversationTemplateModule.js +211 -114
- package/dist/src/template/ConversationTemplateModule.js.map +1 -1
- package/dist/src/template/createApp/CreateAppTemplate.d.ts +1 -1
- package/dist/src/template/createApp/CreateAppTemplate.js +151 -59
- package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts +1 -1
- package/dist/src/template/createCode/CreateCodeConversationTemplate.d.ts.map +1 -1
- package/dist/src/template/createCode/CreateCodeConversationTemplate.js +183 -74
- package/dist/src/template/createCode/CreateCodeConversationTemplate.js.map +1 -1
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts +1 -1
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.d.ts.map +1 -1
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.js +174 -84
- package/dist/src/template/createPackage/CreatePackageConversationTemplate.js.map +1 -1
- package/dist/src/template/createPackage/tsconfig.json +11 -11
- package/dist/test/createKeywordFilesIndex.test.d.ts +1 -1
- package/dist/test/createKeywordFilesIndex.test.js +132 -41
- package/dist/test/createKeywordFilesIndex.test.js.map +1 -1
- package/dist/test/openai/openai.generateList.test.d.ts +1 -1
- package/dist/test/openai/openai.generateList.test.js +136 -47
- package/dist/test/openai/openai.generateList.test.js.map +1 -1
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.d.ts +1 -1
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.js +15 -10
- package/dist/test/openai/openai.parseCodeFromMarkdown.test.js.map +1 -1
- package/dist/test/repo/repo.test.d.ts +1 -1
- package/dist/test/repo/repo.test.js +127 -38
- package/dist/test/repo/repo.test.js.map +1 -1
- package/jest.config.js +2 -2
- package/package.json +11 -5
- package/src/CodegenConversation.ts +6 -4
- package/src/Conversation.ts +102 -33
- package/src/ConversationModule.ts +2 -2
- package/src/Function.ts +0 -1
- package/src/OpenAi.ts +128 -63
- package/src/Paragraph.ts +3 -2
- package/src/Sentence.ts +5 -3
- package/src/code_template/Code.ts +25 -19
- package/src/code_template/CodeTemplate.ts +8 -7
- package/src/code_template/CodeTemplateModule.ts +2 -2
- package/src/code_template/Repo.ts +25 -19
- package/src/fs/conversation_fs/ConversationFsModerator.ts +34 -20
- package/src/fs/conversation_fs/ConversationFsModule.ts +13 -7
- package/src/fs/conversation_fs/FsFunctions.ts +33 -44
- package/src/fs/git/GitModule.ts +2 -4
- package/src/fs/keyword_to_files_index/KeywordToFilesIndexFunctions.ts +31 -31
- package/src/fs/keyword_to_files_index/KeywordToFilesIndexModule.ts +19 -18
- package/src/fs/package/PackageFunctions.ts +34 -41
- package/src/fs/package/PackageModule.ts +33 -21
- package/src/history/MessageHistory.ts +7 -4
- package/src/history/MessageModerator.ts +1 -1
- package/src/template/ConversationTemplate.ts +9 -9
- package/src/template/ConversationTemplateFunctions.ts +8 -7
- package/src/template/ConversationTemplateModule.ts +24 -15
- package/src/template/createApp/CreateAppTemplate.ts +1 -1
- package/src/template/createCode/CreateCodeConversationTemplate.ts +9 -11
- package/src/template/createPackage/CreatePackageConversationTemplate.ts +2 -9
- package/src/template/createPackage/jest.config.js +2 -2
- package/test/createKeywordFilesIndex.test.ts +3 -3
- package/test/openai/openai.generateList.test.ts +5 -3
- package/test/openai/openai.parseCodeFromMarkdown.test.ts +10 -5
- package/test/repo/repo.test.ts +3 -4
- package/tsconfig.json +16 -20
|
@@ -1,191 +1,305 @@
|
|
|
1
|
-
|
|
2
|
-
var __createBinding =
|
|
3
|
-
|
|
4
|
-
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
13
|
-
|
|
14
|
-
|
|
15
|
-
}
|
|
16
|
-
|
|
17
|
-
}
|
|
18
|
-
|
|
1
|
+
'use strict';
|
|
2
|
+
var __createBinding =
|
|
3
|
+
(this && this.__createBinding) ||
|
|
4
|
+
(Object.create
|
|
5
|
+
? function (o, m, k, k2) {
|
|
6
|
+
if (k2 === undefined) k2 = k;
|
|
7
|
+
var desc = Object.getOwnPropertyDescriptor(m, k);
|
|
8
|
+
if (!desc || ('get' in desc ? !m.__esModule : desc.writable || desc.configurable)) {
|
|
9
|
+
desc = {
|
|
10
|
+
enumerable: true,
|
|
11
|
+
get: function () {
|
|
12
|
+
return m[k];
|
|
13
|
+
},
|
|
14
|
+
};
|
|
15
|
+
}
|
|
16
|
+
Object.defineProperty(o, k2, desc);
|
|
17
|
+
}
|
|
18
|
+
: function (o, m, k, k2) {
|
|
19
|
+
if (k2 === undefined) k2 = k;
|
|
20
|
+
o[k2] = m[k];
|
|
21
|
+
});
|
|
22
|
+
var __setModuleDefault =
|
|
23
|
+
(this && this.__setModuleDefault) ||
|
|
24
|
+
(Object.create
|
|
25
|
+
? function (o, v) {
|
|
26
|
+
Object.defineProperty(o, 'default', { enumerable: true, value: v });
|
|
27
|
+
}
|
|
28
|
+
: function (o, v) {
|
|
29
|
+
o['default'] = v;
|
|
30
|
+
});
|
|
31
|
+
var __importStar =
|
|
32
|
+
(this && this.__importStar) ||
|
|
33
|
+
function (mod) {
|
|
19
34
|
if (mod && mod.__esModule) return mod;
|
|
20
35
|
var result = {};
|
|
21
|
-
if (mod != null)
|
|
36
|
+
if (mod != null)
|
|
37
|
+
for (var k in mod)
|
|
38
|
+
if (k !== 'default' && Object.prototype.hasOwnProperty.call(mod, k)) __createBinding(result, mod, k);
|
|
22
39
|
__setModuleDefault(result, mod);
|
|
23
40
|
return result;
|
|
24
|
-
};
|
|
25
|
-
var __awaiter =
|
|
26
|
-
|
|
41
|
+
};
|
|
42
|
+
var __awaiter =
|
|
43
|
+
(this && this.__awaiter) ||
|
|
44
|
+
function (thisArg, _arguments, P, generator) {
|
|
45
|
+
function adopt(value) {
|
|
46
|
+
return value instanceof P
|
|
47
|
+
? value
|
|
48
|
+
: new P(function (resolve) {
|
|
49
|
+
resolve(value);
|
|
50
|
+
});
|
|
51
|
+
}
|
|
27
52
|
return new (P || (P = Promise))(function (resolve, reject) {
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
53
|
+
function fulfilled(value) {
|
|
54
|
+
try {
|
|
55
|
+
step(generator.next(value));
|
|
56
|
+
} catch (e) {
|
|
57
|
+
reject(e);
|
|
58
|
+
}
|
|
59
|
+
}
|
|
60
|
+
function rejected(value) {
|
|
61
|
+
try {
|
|
62
|
+
step(generator['throw'](value));
|
|
63
|
+
} catch (e) {
|
|
64
|
+
reject(e);
|
|
65
|
+
}
|
|
66
|
+
}
|
|
67
|
+
function step(result) {
|
|
68
|
+
result.done ? resolve(result.value) : adopt(result.value).then(fulfilled, rejected);
|
|
69
|
+
}
|
|
70
|
+
step((generator = generator.apply(thisArg, _arguments || [])).next());
|
|
32
71
|
});
|
|
33
|
-
};
|
|
34
|
-
var __generator =
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
72
|
+
};
|
|
73
|
+
var __generator =
|
|
74
|
+
(this && this.__generator) ||
|
|
75
|
+
function (thisArg, body) {
|
|
76
|
+
var _ = {
|
|
77
|
+
label: 0,
|
|
78
|
+
sent: function () {
|
|
79
|
+
if (t[0] & 1) throw t[1];
|
|
80
|
+
return t[1];
|
|
81
|
+
},
|
|
82
|
+
trys: [],
|
|
83
|
+
ops: [],
|
|
84
|
+
},
|
|
85
|
+
f,
|
|
86
|
+
y,
|
|
87
|
+
t,
|
|
88
|
+
g;
|
|
89
|
+
return (
|
|
90
|
+
(g = { next: verb(0), throw: verb(1), return: verb(2) }),
|
|
91
|
+
typeof Symbol === 'function' &&
|
|
92
|
+
(g[Symbol.iterator] = function () {
|
|
93
|
+
return this;
|
|
94
|
+
}),
|
|
95
|
+
g
|
|
96
|
+
);
|
|
97
|
+
function verb(n) {
|
|
98
|
+
return function (v) {
|
|
99
|
+
return step([n, v]);
|
|
100
|
+
};
|
|
101
|
+
}
|
|
38
102
|
function step(op) {
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
|
|
52
|
-
|
|
53
|
-
|
|
54
|
-
|
|
55
|
-
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
|
|
103
|
+
if (f) throw new TypeError('Generator is already executing.');
|
|
104
|
+
while ((g && ((g = 0), op[0] && (_ = 0)), _))
|
|
105
|
+
try {
|
|
106
|
+
if (
|
|
107
|
+
((f = 1),
|
|
108
|
+
y &&
|
|
109
|
+
(t = op[0] & 2 ? y['return'] : op[0] ? y['throw'] || ((t = y['return']) && t.call(y), 0) : y.next) &&
|
|
110
|
+
!(t = t.call(y, op[1])).done)
|
|
111
|
+
)
|
|
112
|
+
return t;
|
|
113
|
+
if (((y = 0), t)) op = [op[0] & 2, t.value];
|
|
114
|
+
switch (op[0]) {
|
|
115
|
+
case 0:
|
|
116
|
+
case 1:
|
|
117
|
+
t = op;
|
|
118
|
+
break;
|
|
119
|
+
case 4:
|
|
120
|
+
_.label++;
|
|
121
|
+
return { value: op[1], done: false };
|
|
122
|
+
case 5:
|
|
123
|
+
_.label++;
|
|
124
|
+
y = op[1];
|
|
125
|
+
op = [0];
|
|
126
|
+
continue;
|
|
127
|
+
case 7:
|
|
128
|
+
op = _.ops.pop();
|
|
129
|
+
_.trys.pop();
|
|
130
|
+
continue;
|
|
131
|
+
default:
|
|
132
|
+
if (!((t = _.trys), (t = t.length > 0 && t[t.length - 1])) && (op[0] === 6 || op[0] === 2)) {
|
|
133
|
+
_ = 0;
|
|
134
|
+
continue;
|
|
135
|
+
}
|
|
136
|
+
if (op[0] === 3 && (!t || (op[1] > t[0] && op[1] < t[3]))) {
|
|
137
|
+
_.label = op[1];
|
|
138
|
+
break;
|
|
139
|
+
}
|
|
140
|
+
if (op[0] === 6 && _.label < t[1]) {
|
|
141
|
+
_.label = t[1];
|
|
142
|
+
t = op;
|
|
143
|
+
break;
|
|
144
|
+
}
|
|
145
|
+
if (t && _.label < t[2]) {
|
|
146
|
+
_.label = t[2];
|
|
147
|
+
_.ops.push(op);
|
|
148
|
+
break;
|
|
149
|
+
}
|
|
150
|
+
if (t[2]) _.ops.pop();
|
|
151
|
+
_.trys.pop();
|
|
152
|
+
continue;
|
|
153
|
+
}
|
|
154
|
+
op = body.call(thisArg, _);
|
|
155
|
+
} catch (e) {
|
|
156
|
+
op = [6, e];
|
|
157
|
+
y = 0;
|
|
158
|
+
} finally {
|
|
159
|
+
f = t = 0;
|
|
160
|
+
}
|
|
161
|
+
if (op[0] & 5) throw op[1];
|
|
162
|
+
return { value: op[0] ? op[1] : void 0, done: true };
|
|
59
163
|
}
|
|
60
|
-
};
|
|
61
|
-
Object.defineProperty(exports,
|
|
164
|
+
};
|
|
165
|
+
Object.defineProperty(exports, '__esModule', { value: true });
|
|
62
166
|
exports.CodegenConversation = void 0;
|
|
63
|
-
var readline = __importStar(require(
|
|
64
|
-
var Conversation_1 = require(
|
|
65
|
-
var KeywordToFilesIndexModule_1 = require(
|
|
66
|
-
var ConversationTemplateModule_1 = require(
|
|
67
|
-
var ConversationFsModule_1 = require(
|
|
68
|
-
var PackageModule_1 = require(
|
|
69
|
-
var util_1 = require(
|
|
70
|
-
var GitModule_1 = require(
|
|
167
|
+
var readline = __importStar(require('readline-sync'));
|
|
168
|
+
var Conversation_1 = require('./Conversation');
|
|
169
|
+
var KeywordToFilesIndexModule_1 = require('./fs/keyword_to_files_index/KeywordToFilesIndexModule');
|
|
170
|
+
var ConversationTemplateModule_1 = require('./template/ConversationTemplateModule');
|
|
171
|
+
var ConversationFsModule_1 = require('./fs/conversation_fs/ConversationFsModule');
|
|
172
|
+
var PackageModule_1 = require('./fs/package/PackageModule');
|
|
173
|
+
var util_1 = require('@proteinjs/util');
|
|
174
|
+
var GitModule_1 = require('./fs/git/GitModule');
|
|
71
175
|
var CodegenConversation = /** @class */ (function () {
|
|
72
|
-
|
|
73
|
-
|
|
74
|
-
|
|
75
|
-
|
|
76
|
-
|
|
77
|
-
|
|
78
|
-
|
|
79
|
-
|
|
80
|
-
|
|
81
|
-
|
|
82
|
-
|
|
83
|
-
|
|
84
|
-
|
|
85
|
-
|
|
86
|
-
|
|
87
|
-
|
|
88
|
-
|
|
89
|
-
|
|
90
|
-
|
|
91
|
-
|
|
92
|
-
|
|
93
|
-
|
|
94
|
-
|
|
95
|
-
|
|
96
|
-
|
|
97
|
-
|
|
98
|
-
|
|
99
|
-
}
|
|
100
|
-
|
|
101
|
-
|
|
102
|
-
|
|
103
|
-
|
|
104
|
-
|
|
105
|
-
|
|
106
|
-
|
|
107
|
-
|
|
108
|
-
|
|
109
|
-
|
|
110
|
-
|
|
111
|
-
|
|
112
|
-
|
|
113
|
-
|
|
114
|
-
|
|
115
|
-
|
|
116
|
-
|
|
117
|
-
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
|
|
121
|
-
|
|
122
|
-
|
|
123
|
-
|
|
124
|
-
|
|
125
|
-
|
|
126
|
-
|
|
127
|
-
|
|
128
|
-
|
|
129
|
-
|
|
130
|
-
|
|
131
|
-
|
|
132
|
-
|
|
133
|
-
|
|
134
|
-
|
|
135
|
-
|
|
136
|
-
|
|
137
|
-
|
|
138
|
-
|
|
139
|
-
|
|
140
|
-
|
|
141
|
-
|
|
142
|
-
|
|
143
|
-
|
|
144
|
-
|
|
145
|
-
|
|
146
|
-
|
|
147
|
-
|
|
148
|
-
|
|
149
|
-
|
|
150
|
-
|
|
151
|
-
|
|
152
|
-
|
|
153
|
-
|
|
154
|
-
|
|
155
|
-
|
|
156
|
-
|
|
157
|
-
|
|
158
|
-
|
|
159
|
-
|
|
160
|
-
|
|
161
|
-
|
|
162
|
-
|
|
163
|
-
|
|
164
|
-
|
|
165
|
-
|
|
166
|
-
|
|
167
|
-
|
|
168
|
-
|
|
169
|
-
|
|
170
|
-
|
|
171
|
-
|
|
172
|
-
|
|
173
|
-
|
|
174
|
-
|
|
175
|
-
|
|
176
|
-
|
|
177
|
-
|
|
178
|
-
|
|
179
|
-
|
|
180
|
-
|
|
181
|
-
|
|
182
|
-
|
|
183
|
-
|
|
184
|
-
|
|
185
|
-
|
|
186
|
-
|
|
187
|
-
|
|
188
|
-
|
|
189
|
-
|
|
176
|
+
function CodegenConversation(repoPath) {
|
|
177
|
+
this.repoPath = repoPath;
|
|
178
|
+
}
|
|
179
|
+
CodegenConversation.prototype.start = function () {
|
|
180
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
181
|
+
var conversation, initialUserInput, response, userInput;
|
|
182
|
+
return __generator(this, function (_a) {
|
|
183
|
+
switch (_a.label) {
|
|
184
|
+
case 0:
|
|
185
|
+
return [4 /*yield*/, this.createConversation()];
|
|
186
|
+
case 1:
|
|
187
|
+
conversation = _a.sent();
|
|
188
|
+
conversation.addAssistantMessagesToHistory([CodegenConversation.INITIAL_QUESTION]);
|
|
189
|
+
initialUserInput = this.respondToUser(CodegenConversation.INITIAL_QUESTION);
|
|
190
|
+
return [4 /*yield*/, conversation.generateResponse([initialUserInput], CodegenConversation.MODEL)];
|
|
191
|
+
case 2:
|
|
192
|
+
response = _a.sent();
|
|
193
|
+
_a.label = 3;
|
|
194
|
+
case 3:
|
|
195
|
+
if (!true) return [3 /*break*/, 5];
|
|
196
|
+
userInput = this.respondToUser(response);
|
|
197
|
+
return [4 /*yield*/, conversation.generateResponse([userInput], CodegenConversation.MODEL)];
|
|
198
|
+
case 4:
|
|
199
|
+
response = _a.sent();
|
|
200
|
+
return [3 /*break*/, 3];
|
|
201
|
+
case 5:
|
|
202
|
+
return [2 /*return*/];
|
|
203
|
+
}
|
|
204
|
+
});
|
|
205
|
+
});
|
|
206
|
+
};
|
|
207
|
+
CodegenConversation.prototype.createConversation = function () {
|
|
208
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
209
|
+
var conversation, _a;
|
|
210
|
+
var _b;
|
|
211
|
+
return __generator(this, function (_c) {
|
|
212
|
+
switch (_c.label) {
|
|
213
|
+
case 0:
|
|
214
|
+
_a = Conversation_1.Conversation.bind;
|
|
215
|
+
_b = {
|
|
216
|
+
name: this.constructor.name,
|
|
217
|
+
};
|
|
218
|
+
return [4 /*yield*/, this.getModules()];
|
|
219
|
+
case 1:
|
|
220
|
+
conversation = new (_a.apply(Conversation_1.Conversation, [
|
|
221
|
+
void 0,
|
|
222
|
+
((_b.modules = _c.sent()), (_b.logLevel = 'info'), _b),
|
|
223
|
+
]))();
|
|
224
|
+
conversation.addSystemMessagesToHistory(this.getSystemMessages());
|
|
225
|
+
return [2 /*return*/, conversation];
|
|
226
|
+
}
|
|
227
|
+
});
|
|
228
|
+
});
|
|
229
|
+
};
|
|
230
|
+
CodegenConversation.prototype.getModules = function () {
|
|
231
|
+
return __awaiter(this, void 0, void 0, function () {
|
|
232
|
+
var moduleFactories, modules, _i, moduleFactories_1, moduleFactory, _a, _b;
|
|
233
|
+
return __generator(this, function (_c) {
|
|
234
|
+
switch (_c.label) {
|
|
235
|
+
case 0:
|
|
236
|
+
moduleFactories = [
|
|
237
|
+
new ConversationFsModule_1.ConversationFsModuleFactory(),
|
|
238
|
+
new KeywordToFilesIndexModule_1.KeywordToFilesIndexModuleFactory(),
|
|
239
|
+
new PackageModule_1.PackageModuleFactory(),
|
|
240
|
+
new ConversationTemplateModule_1.ConversationTemplateModuleFactory(),
|
|
241
|
+
new GitModule_1.GitModuleFactory(),
|
|
242
|
+
];
|
|
243
|
+
modules = [];
|
|
244
|
+
(_i = 0), (moduleFactories_1 = moduleFactories);
|
|
245
|
+
_c.label = 1;
|
|
246
|
+
case 1:
|
|
247
|
+
if (!(_i < moduleFactories_1.length)) return [3 /*break*/, 4];
|
|
248
|
+
moduleFactory = moduleFactories_1[_i];
|
|
249
|
+
_b = (_a = modules).push;
|
|
250
|
+
return [4 /*yield*/, moduleFactory.createModule(this.repoPath)];
|
|
251
|
+
case 2:
|
|
252
|
+
_b.apply(_a, [_c.sent()]);
|
|
253
|
+
_c.label = 3;
|
|
254
|
+
case 3:
|
|
255
|
+
_i++;
|
|
256
|
+
return [3 /*break*/, 1];
|
|
257
|
+
case 4:
|
|
258
|
+
return [2 /*return*/, modules];
|
|
259
|
+
}
|
|
260
|
+
});
|
|
261
|
+
});
|
|
262
|
+
};
|
|
263
|
+
CodegenConversation.prototype.getSystemMessages = function () {
|
|
264
|
+
return [
|
|
265
|
+
'We are going to have a conversation with the user to generate code',
|
|
266
|
+
'Await all function calls that return a promise',
|
|
267
|
+
'Try to repspond to the user with as few words as possible while still having a conversational tone',
|
|
268
|
+
"When generating code, export the objects you create inline; do not use 'export default' syntax",
|
|
269
|
+
// `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`,
|
|
270
|
+
// `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`,
|
|
271
|
+
// `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`,
|
|
272
|
+
// `If the conversation summary indicates the user was working with a file get the file path (use the ${searchFilesFunctionName} function if needed) and read the file with the ${readFilesFunctionName} function. Use that file as context to respond to the user.`,
|
|
273
|
+
//
|
|
274
|
+
// `Use the conversation summary to identify a file as context for the user interaction`,
|
|
275
|
+
// `Use the ${searchFilesFunctionName} function to find the file if needed; read the file if needed`,
|
|
276
|
+
// `If the user is referring to a function, object, class, or type and you don't have the relevant file content, first inspect the conversation summary in the chat history (if it exists) to find a file name, and call the ${searchFilesFunctionName} function and read the file before responding to the user`,
|
|
277
|
+
// `Before calling ${searchFilesFunctionName}, ${searchLibrariesFunctionName} or ${searchPackagesFunctionName}, use the conversation summary in the chat history to identify a file or keyword to search for instead; after reading that file, respond to the user's request`,
|
|
278
|
+
//
|
|
279
|
+
// `Use the ${getRecentlyAccessedFilePathsFunctionName} function find a file that might pertain to the user's request before searching files, libraries or packages; read that file then respond to the user`,
|
|
280
|
+
// `When trying to locate code, use the ${getRecentlyAccessedFilePathsFunctionName} function to search recently accessed files first, then proceed to calling other functions: ${searchLibrariesFunctionName}, ${searchPackagesFunctionName}, ${searchFilesFunctionName}`,
|
|
281
|
+
// `The conversation summary indicates files recently worked in as well`,
|
|
282
|
+
// `If that doesn't yield results, proceed to calling the ${searchLibrariesFunctionName} function, then fall back to functions: ${searchPackagesFunctionName}, ${searchFilesFunctionName}`,
|
|
283
|
+
//
|
|
284
|
+
// `To find code, a file, or a library, call ${getRecentlyAccessedFilePathsFunctionName} and read the most recent file, after trying that call ${searchLibrariesFunctionName} then ${searchFilesFunctionName} to find a relevant file`,
|
|
285
|
+
// `The file mentioned in the conversation summary should be read if we're not already working in a file`,
|
|
286
|
+
// `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`,
|
|
287
|
+
// `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`,
|
|
288
|
+
];
|
|
289
|
+
};
|
|
290
|
+
CodegenConversation.prototype.respondToUser = function (message) {
|
|
291
|
+
return readline.question(
|
|
292
|
+
''
|
|
293
|
+
.concat(util_1.textColorMap.cyan, '[')
|
|
294
|
+
.concat(CodegenConversation.BOT_NAME, '] ')
|
|
295
|
+
.concat(message)
|
|
296
|
+
.concat(util_1.Reset, '\n')
|
|
297
|
+
);
|
|
298
|
+
};
|
|
299
|
+
CodegenConversation.INITIAL_QUESTION = 'What would you like to create?';
|
|
300
|
+
CodegenConversation.BOT_NAME = 'Alina';
|
|
301
|
+
CodegenConversation.MODEL = 'gpt-4'; //'gpt-3.5-turbo-16k';
|
|
302
|
+
return CodegenConversation;
|
|
303
|
+
})();
|
|
190
304
|
exports.CodegenConversation = CodegenConversation;
|
|
191
|
-
//# sourceMappingURL=CodegenConversation.js.map
|
|
305
|
+
//# sourceMappingURL=CodegenConversation.js.map
|
|
@@ -1 +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,qBAAM,IAAI,CAAC,kBAAkB,EAAE,EAAA;;wBAA9C,YAAY,GAAG,SAA+B;wBACpD,YAAY,CAAC,6BAA6B,CAAC,CAAC,mBA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AAC;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;IA7Ec,oCAAgB,GAAG,gCAAgC,CAAC;IACpD,4BAAQ,GAAG,OAAO,CAAC;IACnB,yBAAK,GAAkB,OAAO,CAAC,CAAC,sBAAsB;IA4EvE,0BAAC;CAAA,AA/ED,IA+EC;AA/EY,kDAAmB"}
|
|
@@ -2,59 +2,62 @@ import { LogLevel } from '@proteinjs/util';
|
|
|
2
2
|
import { ConversationModule } from './ConversationModule';
|
|
3
3
|
import { TiktokenModel } from 'tiktoken';
|
|
4
4
|
export type ConversationParams = {
|
|
5
|
-
|
|
6
|
-
|
|
7
|
-
|
|
8
|
-
|
|
9
|
-
|
|
10
|
-
|
|
11
|
-
|
|
12
|
-
|
|
5
|
+
name: string;
|
|
6
|
+
modules?: ConversationModule[];
|
|
7
|
+
logLevel?: LogLevel;
|
|
8
|
+
limits?: {
|
|
9
|
+
enforceLimits?: boolean;
|
|
10
|
+
maxMessagesInHistory?: number;
|
|
11
|
+
tokenLimit?: number;
|
|
12
|
+
};
|
|
13
13
|
};
|
|
14
14
|
export declare class Conversation {
|
|
15
|
-
|
|
16
|
-
|
|
17
|
-
|
|
18
|
-
|
|
19
|
-
|
|
20
|
-
|
|
21
|
-
|
|
22
|
-
|
|
23
|
-
|
|
24
|
-
|
|
25
|
-
|
|
26
|
-
|
|
27
|
-
|
|
28
|
-
|
|
29
|
-
|
|
30
|
-
|
|
31
|
-
|
|
32
|
-
|
|
33
|
-
|
|
34
|
-
|
|
35
|
-
|
|
36
|
-
|
|
37
|
-
|
|
38
|
-
|
|
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(
|
|
37
|
+
codeToUpdateFilePath: string,
|
|
38
|
+
dependencyCodeFilePaths: string[],
|
|
39
|
+
description: string,
|
|
40
|
+
model?: TiktokenModel
|
|
41
|
+
): Promise<string>;
|
|
42
|
+
updateCode(code: string, description: string, model?: TiktokenModel): Promise<string>;
|
|
43
|
+
generateList(description: string[], model?: TiktokenModel): Promise<string[]>;
|
|
39
44
|
}
|
|
40
|
-
export declare const summarizeConversationHistoryFunctionName =
|
|
45
|
+
export declare const summarizeConversationHistoryFunctionName = 'summarizeConversationHistory';
|
|
41
46
|
export declare const summarizeConversationHistoryFunction: (conversation: Conversation) => {
|
|
42
|
-
|
|
43
|
-
|
|
44
|
-
|
|
45
|
-
|
|
46
|
-
|
|
47
|
-
|
|
48
|
-
|
|
49
|
-
|
|
50
|
-
|
|
51
|
-
};
|
|
52
|
-
};
|
|
53
|
-
required: string[];
|
|
47
|
+
definition: {
|
|
48
|
+
name: string;
|
|
49
|
+
description: string;
|
|
50
|
+
parameters: {
|
|
51
|
+
type: string;
|
|
52
|
+
properties: {
|
|
53
|
+
summary: {
|
|
54
|
+
type: string;
|
|
55
|
+
description: string;
|
|
54
56
|
};
|
|
57
|
+
};
|
|
58
|
+
required: string[];
|
|
55
59
|
};
|
|
56
|
-
|
|
57
|
-
|
|
58
|
-
}) => Promise<void>;
|
|
60
|
+
};
|
|
61
|
+
call: (params: { summary: string }) => Promise<void>;
|
|
59
62
|
};
|
|
60
|
-
//# sourceMappingURL=Conversation.d.ts.map
|
|
63
|
+
//# sourceMappingURL=Conversation.d.ts.map
|