From 6e28d283cd58dc2bbb454f73492a0b89cf135504 Mon Sep 17 00:00:00 2001 From: Ishaan Dey Date: Fri, 3 May 2024 12:56:44 -0700 Subject: [PATCH] improve prompting + add dockerfile for ws --- .gitignore | 1 + backend/server/dist/index.js | 18 ++++++++++++------ backend/server/dockerfile | 15 +++++++++++++++ backend/server/src/index.ts | 18 ++++++++++++------ 4 files changed, 40 insertions(+), 12 deletions(-) create mode 100644 backend/server/dockerfile diff --git a/.gitignore b/.gitignore index 9e9e675..e888b6c 100644 --- a/.gitignore +++ b/.gitignore @@ -38,5 +38,6 @@ next-env.d.ts wrangler.toml +backend/server/dist backend/server/projects backend/database/drizzle \ No newline at end of file diff --git a/backend/server/dist/index.js b/backend/server/dist/index.js index c5fbff5..5ff97cb 100644 --- a/backend/server/dist/index.js +++ b/backend/server/dist/index.js @@ -185,15 +185,21 @@ io.on("connection", (socket) => __awaiter(void 0, void 0, void 0, function* () { messages: [ { role: "system", - content: "You are an expert coding assistant. You read code from a file, and you suggest new code to add to the file. You may be given instructions on what to generate, which you should follow. You should generate code that is correct, efficient, and follows best practices. You should also generate code that is clear and easy to read.", + content: "You are an expert coding assistant. You read code from a file, and you suggest new code to add to the file. You may be given instructions on what to generate, which you should follow. You should generate code that is correct, efficient, and follows best practices. You should also generate code that is clear and easy to read. When you generate code, you should only return the code, and nothing else. You should not include backticks in the code you generate.", }, { role: "user", - content: `The file is called ${fileName}. Here are my instructions on what to generate: ${instructions}. Suggest me code to insert at line ${line} in my file. - -My code file content: ${code} - -Return only the code, and nothing else. Do not include backticks.`, + content: `The file is called ${fileName}.`, + }, + { + role: "user", + content: `Here are my instructions on what to generate: ${instructions}.`, + }, + { + role: "user", + content: `Suggest me code to insert at line ${line} in my file. Give only the code, and NOTHING else. DO NOT include backticks in your response. My code file content is as follows + +${code}`, }, ], }), diff --git a/backend/server/dockerfile b/backend/server/dockerfile new file mode 100644 index 0000000..3549a6e --- /dev/null +++ b/backend/server/dockerfile @@ -0,0 +1,15 @@ +FROM node:20 + +WORKDIR /code + +COPY package*.json ./ + +RUN npm install + +COPY . . + +RUN npm run build + +EXPOSE 3000 + +CMD [ "node", "dist/index.js" ] \ No newline at end of file diff --git a/backend/server/src/index.ts b/backend/server/src/index.ts index 136eac6..835f27b 100644 --- a/backend/server/src/index.ts +++ b/backend/server/src/index.ts @@ -229,15 +229,21 @@ io.on("connection", async (socket) => { { role: "system", content: - "You are an expert coding assistant. You read code from a file, and you suggest new code to add to the file. You may be given instructions on what to generate, which you should follow. You should generate code that is correct, efficient, and follows best practices. You should also generate code that is clear and easy to read.", + "You are an expert coding assistant. You read code from a file, and you suggest new code to add to the file. You may be given instructions on what to generate, which you should follow. You should generate code that is correct, efficient, and follows best practices. You should also generate code that is clear and easy to read. When you generate code, you should only return the code, and nothing else. You should not include backticks in the code you generate.", }, { role: "user", - content: `The file is called ${fileName}. Here are my instructions on what to generate: ${instructions}. Suggest me code to insert at line ${line} in my file. - -My code file content: ${code} - -Return only the code, and nothing else. Do not include backticks.`, + content: `The file is called ${fileName}.`, + }, + { + role: "user", + content: `Here are my instructions on what to generate: ${instructions}.`, + }, + { + role: "user", + content: `Suggest me code to insert at line ${line} in my file. Give only the code, and NOTHING else. DO NOT include backticks in your response. My code file content is as follows + +${code}`, }, ], }),