From f109dbfbcedec8b56b4acbfde74974bb4d7d068c Mon Sep 17 00:00:00 2001 From: HugoCasa Date: Tue, 28 Nov 2023 18:51:30 +0100 Subject: [PATCH] fix: ai fix popup placement + update edit/fix prompt to return complete code (#2715) --- frontend/src/lib/components/copilot/ScriptFix.svelte | 9 +-------- frontend/src/lib/components/copilot/prompts/edit.yaml | 3 ++- .../src/lib/components/copilot/prompts/editPrompt.ts | 2 +- frontend/src/lib/components/copilot/prompts/fix.yaml | 1 + frontend/src/lib/components/copilot/prompts/fixPrompt.ts | 2 +- 5 files changed, 6 insertions(+), 11 deletions(-) diff --git a/frontend/src/lib/components/copilot/ScriptFix.svelte b/frontend/src/lib/components/copilot/ScriptFix.svelte index 4e8ace4e32..2701c3cd07 100644 --- a/frontend/src/lib/components/copilot/ScriptFix.svelte +++ b/frontend/src/lib/components/copilot/ScriptFix.svelte @@ -149,14 +149,7 @@ floatingConfig={{ middleware: [ autoPlacement({ - allowedPlacements: [ - 'bottom-start', - 'bottom-end', - 'top-start', - 'top-end', - 'top', - 'bottom' - ] + allowedPlacements: ['bottom-end', 'top-end'] }) ] }} diff --git a/frontend/src/lib/components/copilot/prompts/edit.yaml b/frontend/src/lib/components/copilot/prompts/edit.yaml index 649ee8e008..1936e8aae5 100644 --- a/frontend/src/lib/components/copilot/prompts/edit.yaml +++ b/frontend/src/lib/components/copilot/prompts/edit.yaml @@ -1,7 +1,8 @@ system: |- - You are a helpful coding assistant for Windmill, a developer platform for running scripts. You fix the code shared by the user. Each user message includes some contextual information which should guide your answer. + You are a helpful coding assistant for Windmill, a developer platform for running scripts. You modify code as instructed by the user. Each user message includes some contextual information which should guide your answer. Only output code. Wrap the code in a code block. Put explanations directly in the code as comments. + Return the complete modified code. Here's how interactions have to look like: user: {sample_question} diff --git a/frontend/src/lib/components/copilot/prompts/editPrompt.ts b/frontend/src/lib/components/copilot/prompts/editPrompt.ts index e4e517c62c..35aebc8d82 100644 --- a/frontend/src/lib/components/copilot/prompts/editPrompt.ts +++ b/frontend/src/lib/components/copilot/prompts/editPrompt.ts @@ -1,5 +1,5 @@ export const EDIT_PROMPT = { - "system": "You are a helpful coding assistant for Windmill, a developer platform for running scripts. You fix the code shared by the user. Each user message includes some contextual information which should guide your answer.\nOnly output code. Wrap the code in a code block. \nPut explanations directly in the code as comments.\n\nHere's how interactions have to look like:\nuser: {sample_question}\nassistant: ```language\n{code}\n```", + "system": "You are a helpful coding assistant for Windmill, a developer platform for running scripts. You modify code as instructed by the user. Each user message includes some contextual information which should guide your answer.\nOnly output code. Wrap the code in a code block. \nPut explanations directly in the code as comments.\nReturn the complete modified code.\n\nHere's how interactions have to look like:\nuser: {sample_question}\nassistant: ```language\n{code}\n```", "prompts": { "python3": { "prompt": "Here's my python3 code: \n```python\n{code}\n```\n\nYou have to write a function in python called \"main\". Specify the parameter types. Do not call the main function. You should generally return the result.\nYou can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:\n\n{resourceTypes}\n\nYou need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.\nThe resource type name has to be exactly as specified (has to be IN LOEWRCASE). If the type name conflicts with any imported methods, you have to rename the imported method with the conflicting name.\n\nMy instructions: {description}" diff --git a/frontend/src/lib/components/copilot/prompts/fix.yaml b/frontend/src/lib/components/copilot/prompts/fix.yaml index c95b826e8e..ff536635d9 100644 --- a/frontend/src/lib/components/copilot/prompts/fix.yaml +++ b/frontend/src/lib/components/copilot/prompts/fix.yaml @@ -3,6 +3,7 @@ system: |- Only output code. Wrap the code in a code block. Explain the error and the fix after generating the code inside an tag. Also put explanations directly in the code as comments. + Return the complete fixed code. Here's how interactions have to look like: user: {sample_question} diff --git a/frontend/src/lib/components/copilot/prompts/fixPrompt.ts b/frontend/src/lib/components/copilot/prompts/fixPrompt.ts index ee55695db9..312f1e992b 100644 --- a/frontend/src/lib/components/copilot/prompts/fixPrompt.ts +++ b/frontend/src/lib/components/copilot/prompts/fixPrompt.ts @@ -1,5 +1,5 @@ export const FIX_PROMPT = { - "system": "You are a helpful coding assistant for Windmill, a developer platform for running scripts. You fix the code shared by the user. Each user message includes some contextual information which should guide your answer.\nOnly output code. Wrap the code in a code block. \nExplain the error and the fix after generating the code inside an tag.\nAlso put explanations directly in the code as comments.\n\nHere's how interactions have to look like:\nuser: {sample_question}\nassistant: ```language\n{code}\n```\n{explanation}", + "system": "You are a helpful coding assistant for Windmill, a developer platform for running scripts. You fix the code shared by the user. Each user message includes some contextual information which should guide your answer.\nOnly output code. Wrap the code in a code block. \nExplain the error and the fix after generating the code inside an tag.\nAlso put explanations directly in the code as comments.\nReturn the complete fixed code.\n\nHere's how interactions have to look like:\nuser: {sample_question}\nassistant: ```language\n{code}\n```\n{explanation}", "prompts": { "python3": { "prompt": "Here's my python3 code: \n```python\n{code}\n```\n\nYou have to write a function in python called \"main\". Specify the parameter types. Do not call the main function. You should generally return the result.\nYou can take as parameters resources which are dictionaries containing credentials or configuration information. For Windmill to correctly detect the resources to be passed, the resource type name has to be exactly as specified in the following list:\n\n{resourceTypes}\n\nYou need to define the type of the resources that are needed before the main function, but only include them if they are actually needed to achieve the function purpose.\nThe resource type name has to be exactly as specified (has to be IN LOEWRCASE). If the type name conflicts with any imported methods, you have to rename the imported method with the conflicting name.\n\nI get the following error: {error}\nFix my code."