Skip to content

Commit 83d444e

Browse files
committed
2 parents 8c29d54 + 44d2252 commit 83d444e

File tree

28 files changed

+3734
-165
lines changed

28 files changed

+3734
-165
lines changed

.gitignore

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,4 +6,6 @@ out
66
stackRegistry.json
77
dist
88
.env
9-
.vscode/launch.json
9+
.vscode/launch.json
10+
test-workspace/.env
11+
stacks/.env

jest.config.js

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,5 @@ module.exports = {
22
preset: 'ts-jest',
33
testEnvironment: 'node',
44
setupFiles: ['<rootDir>/jest.setup.js'],
5-
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/', '<rootDir>/out/', '<rootDir>/src/test/suite'],
5+
testPathIgnorePatterns: ['<rootDir>/dist/', '<rootDir>/node_modules/', '<rootDir>/out/', '<rootDir>/src/test/suite', '<rootDir>/stacks'],
66
};

package-lock.json

Lines changed: 97 additions & 97 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

src/findStackPositions/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -35,7 +35,7 @@ export default async function findStackPositions(
3535
}
3636

3737
// Find the position of 'in:'
38-
let inputPosition = findNextKeyword('in', i, stackIndex);
38+
let inputPosition = findNextKeyword('in:', i, stackIndex);
3939
if (inputPosition) {
4040
positionObject['inputPosition'] = inputPosition;
4141
console.log('inputPosition added:', positionObject.inputPosition);

src/stack/createEmbedding/index.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
import { Pinecone, PineconeRecord } from '@pinecone-database/pinecone';
2-
import { getEmbedding } from '../../../stacks/openai/getEmbedding';
2+
import { getEmbedding } from '../../stacks/openai/getEmbedding';
33
import { BoilerplateMetadata } from '../integrations/lib/types';
44
import { combineSkeleton } from '../createSkeleton';
55

src/stack/getCaviat.ts

Lines changed: 24 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,24 @@
1+
export function getCaviat(brief: string) {
2+
// brief contains openai or gpt-4 or gpt-3.5-turbo or gpt4 or gpt3.5turbo
3+
//convert brief to lowercase
4+
brief = brief.toLowerCase();
5+
if (brief.includes('openai') || brief.includes('gpt-4') || brief.includes('gpt4') || brief.includes('gpt-3.5-turbo') || brief.includes('gpt3.5turbo')) {
6+
return `Examples:
7+
import OpenAI from 'openai';
8+
9+
const openai = new OpenAI({
10+
apiKey: process.env.OPENAI_API_KEY
11+
});
12+
13+
async function main() {
14+
const chatCompletion = await openai.chat.completions.create({
15+
messages: [{ role: 'user', content: 'Say this is a test' }],
16+
model: 'gpt-3.5-turbo',
17+
});
18+
}
19+
20+
main();
21+
`;
22+
}
23+
return ``;
24+
}

src/stack/integrations/generic/chooseBoilerplate.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
import path from 'path';
22
import OpenAI from 'openai';
33
import { Pinecone } from '@pinecone-database/pinecone';
4-
import { getEmbedding } from '../../../../stacks/openai/getEmbedding';
4+
import { getEmbedding } from '../../../stacks/openai/getEmbedding';
55
import { readExplainFiles } from '../lib/utils';
66
import { BoilerplateMetadata } from '../lib/types';
77
import { combineSkeleton } from '../../createSkeleton';

src/stack/integrations/generic/generateFunction.ts

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import { BoilerplateMetadata, Message } from '../lib/types';
33
import { processBoilerplate, readFunctionToString } from '../lib/utils';
44
import { combineSkeleton } from '../../createSkeleton';
55
import { openai } from '../openai/construct';
6+
import { getCaviat } from '../../getCaviat';
67

78
export default async function generateFunction(
89
briefSkeleton: string,
@@ -44,6 +45,7 @@ ${startingBoilerplate}`,
4445
${startingBoilerplate}`,
4546
});
4647
}
48+
const caveats = getCaviat(brief);
4749

4850
try {
4951
const response = await openai.chat.completions.create({
@@ -58,7 +60,11 @@ Ensure that you keep the return type, function name, and parameters the same. Yo
5860
},
5961
{
6062
role: 'user',
61-
content: `Here is the user brief: ${brief}.
63+
content: ``,
64+
},
65+
{
66+
role: 'user',
67+
content: `${caveats}Here is the user brief: ${brief}.
6268
Respond with just what would go in the function file and nothing else. No explanation or words, just the contents of the file. Make sure that the code is runnable if I were to execute it directly.`,
6369
},
6470
],

src/stack/integrations/lib/indexMarkdown.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
11
import { Pinecone, PineconeRecord } from '@pinecone-database/pinecone';
22

3-
import { getEmbedding } from '../../../../stacks/openai/getEmbedding';
3+
import { getEmbedding } from '../../../stacks/openai/getEmbedding';
44
import { models } from '../replicate/documentation/shortenedModels';
55

66
const pinecone = new Pinecone({

src/stack/jsonify/jsonify.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,8 @@ export default function jsonifyString(inputString) {
3030
try {
3131
// if modified string doesn't start with " or {, add { to the beginning
3232
if (modifiedString[0] !== '"' && modifiedString[0] !== '{' && modifiedString[0] !== "'") {
33-
modifiedString = `"${modifiedString}"`;
33+
return {in: modifiedString, inputValues: modifiedString};
34+
3435
}
3536
json = resilientJSONParse(modifiedString);
3637
} catch (error) {

0 commit comments

Comments
 (0)