Skip to content

The Postgres development platform. Supabase gives you a dedicated Postgres database to build your web, mobile, and AI applications.

feat(sql-editor): ai prompt improvements

Greg Richardsone647f7ae4b18
diff --git a/studio/pages/api/ai/sql/debug.ts b/studio/pages/api/ai/sql/debug.ts
index 8ea235e5e13..79fc9b43950 100644
--- a/studio/pages/api/ai/sql/debug.ts
+++ b/studio/pages/api/ai/sql/debug.ts
@@ -28,6 +28,14 @@ const completionFunctions = {
description: stripIndent`
Debugs a Postgres SQL error and modifies the SQL to fix it.
- Create extensions if they are missing (only for valid extensions)
+ - Suggest creating tables if they are missing
+ - Include all of the original SQL
+ - For primary keys, always use "id bigint primary key generated always as identity" (not serial)
+ - When creating tables, always add foreign key references inline
+ - Prefer 'text' over 'varchar'
+ - Prefer 'timestamp with time zone' over 'date'
+ - Use vector(384) data type for any embedding/vector related query
+ - Always use double apostrophe in SQL strings (eg. 'Night''s watch')
`,
parameters: debugSqlSchema.schema,
},
diff --git a/studio/pages/api/ai/sql/edit.ts b/studio/pages/api/ai/sql/edit.ts
index 629e50633e4..57a26349c8e 100644
--- a/studio/pages/api/ai/sql/edit.ts
+++ b/studio/pages/api/ai/sql/edit.ts
@@ -22,6 +22,7 @@ const editSqlSchema = SchemaBuilder.emptySchema().addString('sql', {
- Prefer 'timestamp with time zone' over 'date'
- Use vector(384) data type for any embedding/vector related query
- Always use double apostrophe in SQL strings (eg. 'Night''s watch')
+ - Use real examples when possible
`,
})