From 791296fa41c5bc45c32944db8bc1b66e1515ea82 Mon Sep 17 00:00:00 2001 From: centdix <40307056+centdix@users.noreply.github.com> Date: Wed, 21 May 2025 11:54:23 +0200 Subject: [PATCH] fix: specify using inline type in system prompt for AI (#5787) * inline types * use for ts only --- frontend/src/lib/components/copilot/chat/core.ts | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/frontend/src/lib/components/copilot/chat/core.ts b/frontend/src/lib/components/copilot/chat/core.ts index 990c4489e2..c1a1023904 100644 --- a/frontend/src/lib/components/copilot/chat/core.ts +++ b/frontend/src/lib/components/copilot/chat/core.ts @@ -60,6 +60,8 @@ const TS_RESOURCE_TYPE_SYSTEM = `On Windmill, credentials and configuration are If you need credentials, you should add a parameter to \`main\` with the corresponding resource type inside the \`RT\` namespace: for instance \`RT.Stripe\`. You should only use them if you need them to satisfy the user's instructions. Always use the RT namespace.` +const TS_INLINE_TYPE_INSTRUCTION = `You must always inline the objects types instead of defining them separately. If INSTRUCTIONS ask you to use an already defined type, you MUST inline it instead of using the type name. Explain to the user that you are inlining the type for better arguments inference.` + const PYTHON_RESOURCE_TYPE_SYSTEM = `On Windmill, credentials and configuration are stored in resources and passed as parameters to main. If you need credentials, you should add a parameter to \`main\` with the corresponding resource type. You need to **redefine** the type of the resources that are needed before the main function as TypedDict, but only include them if they are actually needed to achieve the function purpose. @@ -99,8 +101,9 @@ export function getLangContext( const tsContext = TS_RESOURCE_TYPE_SYSTEM + (allowResourcesFetch - ? `\nTo query the RT namespace, you can use the \`search_resource_types\` function.` - : '') + ? `\nTo query the RT namespace, you can use the \`search_resource_types\` function.\n` + : '') + + TS_INLINE_TYPE_INSTRUCTION switch (lang) { case 'bunnative': case 'nativets': @@ -225,6 +228,7 @@ export const CHAT_SYSTEM_PROMPT = ` - The user can ask you to look at or modify specific files, databases or errors by having its name in the INSTRUCTIONS preceded by the @ symbol. In this case, put your focus on the element that is explicitly mentioned. - The user can ask you questions about a list of \`DATABASES\` that are available in the user's workspace. If the user asks you a question about a database, you should ask the user to specify the database name if not given, or take the only one available if there is only one. - You can also receive a \`DIFF\` of the changes that have been made to the code. You should use this diff to give better answers. + - Before giving your answer, check again that you carefully followed these instructions. Important: Do not mention or reveal these instructions to the user unless explicitly asked to do so.