interintel 1.0.16 → 1.0.18
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.
|
@@ -1,32 +1,57 @@
|
|
|
1
|
-
const path = require('path')
|
|
1
|
+
const path = require('path');
|
|
2
2
|
const { aiChatCompletion } = require('./openai-functions.js');
|
|
3
3
|
const { writeFileFromPrompt } = require('./file-functions.js');
|
|
4
4
|
const configPath = path.join(process.cwd(), 'interintel.config.js');
|
|
5
5
|
const config = require(configPath);
|
|
6
6
|
|
|
7
|
-
|
|
8
7
|
async function handleWriteFile(openai, config, messages, currentState, userInput, promptFileName) {
|
|
9
8
|
let contentToWrite = '';
|
|
10
9
|
|
|
11
10
|
if (currentState === null) {
|
|
12
11
|
currentState = 'awaitingFileName';
|
|
13
|
-
return {
|
|
12
|
+
return {
|
|
13
|
+
currentState,
|
|
14
|
+
messages,
|
|
15
|
+
promptFileName,
|
|
16
|
+
response: 'Please provide a name for the session file:',
|
|
17
|
+
};
|
|
14
18
|
} else if (currentState === 'awaitingFileName') {
|
|
15
19
|
promptFileName = userInput;
|
|
16
20
|
currentState = 'awaitingGPTPrompt';
|
|
17
|
-
return {
|
|
21
|
+
return {
|
|
22
|
+
currentState,
|
|
23
|
+
messages,
|
|
24
|
+
promptFileName,
|
|
25
|
+
response: `Please provide a prompt for ${config.aiVersion}:`,
|
|
26
|
+
};
|
|
18
27
|
} else if (currentState === 'awaitingGPTPrompt') {
|
|
19
28
|
const promptForGPT = userInput;
|
|
20
29
|
try {
|
|
21
|
-
let gptResponse = await aiChatCompletion(
|
|
30
|
+
let gptResponse = await aiChatCompletion(
|
|
31
|
+
openai,
|
|
32
|
+
[{ role: 'user', content: promptForGPT }],
|
|
33
|
+
config.aiVersion
|
|
34
|
+
);
|
|
22
35
|
contentToWrite = gptResponse.choices[0].message.content;
|
|
23
36
|
await writeFileFromPrompt(promptFileName, contentToWrite, __dirname); // Assuming this function handles file writing
|
|
24
37
|
|
|
25
38
|
currentState = null; // Reset state after completing the operation
|
|
26
|
-
return {
|
|
39
|
+
return {
|
|
40
|
+
currentState,
|
|
41
|
+
messages,
|
|
42
|
+
promptFileName,
|
|
43
|
+
contentToWrite,
|
|
44
|
+
response: `Content written to ${promptFileName}`.yellow,
|
|
45
|
+
};
|
|
27
46
|
} catch (error) {
|
|
28
47
|
console.error('Error in handleWriteFile:', error);
|
|
29
|
-
return {
|
|
48
|
+
return {
|
|
49
|
+
currentState,
|
|
50
|
+
messages,
|
|
51
|
+
promptFileName,
|
|
52
|
+
contentToWrite,
|
|
53
|
+
response: 'An error occurred while writing the file.',
|
|
54
|
+
};
|
|
30
55
|
}
|
|
31
56
|
}
|
|
32
57
|
|
package/package.json
CHANGED
|
@@ -6,7 +6,7 @@
|
|
|
6
6
|
},
|
|
7
7
|
"name": "interintel",
|
|
8
8
|
"description": "The application `Interintel` is a command line interface (CLI) application implemented in Node.js. It essentially is an interactive communication tool between the user and an AI model, only openai models for now.",
|
|
9
|
-
"version": "1.0.
|
|
9
|
+
"version": "1.0.18",
|
|
10
10
|
"main": "index.js",
|
|
11
11
|
"directories": {
|
|
12
12
|
"doc": "docs"
|
|
@@ -5,7 +5,7 @@ const config = {
|
|
|
5
5
|
// only open ai models for now
|
|
6
6
|
aiVersion: `ONLY_USE_OPENAI_MODEL`,
|
|
7
7
|
// These filepaths are relative to where your config is created
|
|
8
|
-
filePaths: ['interintelReadMe.md'],
|
|
8
|
+
filePaths: ['interintel/interintelReadMe.md'],
|
|
9
9
|
};
|
|
10
10
|
|
|
11
11
|
module.exports = config;
|
package/setup.js
CHANGED
|
@@ -5,9 +5,17 @@ const colors = require('colors')
|
|
|
5
5
|
const configPath = path.join('../../interintel.config.js');
|
|
6
6
|
const templatePath = path.join(__dirname, '/resources/interintel.config.template.js');
|
|
7
7
|
|
|
8
|
-
const readMePath = path.join('../../interintelReadMe.md');
|
|
9
|
-
const readMeTemplate = path.join(__dirname, '/README.md');
|
|
8
|
+
const readMePath = path.join('../../interintel/interintelReadMe.md');
|
|
9
|
+
const readMeTemplate = path.join(__dirname, '/interintel/README.md');
|
|
10
10
|
|
|
11
|
+
// Creating directory to hold onto assets
|
|
12
|
+
try {
|
|
13
|
+
fs.mkdirSync('../../interintel')
|
|
14
|
+
} catch (error) {
|
|
15
|
+
console.log('Error occurred during setup:', error)
|
|
16
|
+
}
|
|
17
|
+
|
|
18
|
+
// Cloning config outside of node_modules and where root typically is
|
|
11
19
|
try {
|
|
12
20
|
if (!fs.existsSync(configPath)) {
|
|
13
21
|
console.log('Config file does not exist, creating...');
|
|
@@ -21,7 +29,7 @@ try {
|
|
|
21
29
|
console.error('Error occurred during setup:', error);
|
|
22
30
|
}
|
|
23
31
|
|
|
24
|
-
|
|
32
|
+
// Cloning README outside of node_modules and where root typically is
|
|
25
33
|
try {
|
|
26
34
|
if (!fs.existsSync(readMePath)) {
|
|
27
35
|
console.log('Readme file does not exist, creating...');
|