You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: sp_BlitzCache.sql
+21-10Lines changed: 21 additions & 10 deletions
Original file line number
Diff line number
Diff line change
@@ -278,7 +278,7 @@ ALTER PROCEDURE dbo.sp_BlitzCache
278
278
@AI TINYINT=0, /* 1 = ask for advice, 2 = build prompt but don't actually call AI. Only works with a single query plan: automatically sets @ExpertMode = 1, @KeepCRLF = 1. */
279
279
@AIModel VARCHAR(200) =NULL, /* Defaults to gpt-4.1-mini */
280
280
@AIURL VARCHAR(200) =NULL, /* Defaults to https://api.openai.com/v1/chat/completions */
281
-
@AICredential VARCHAR(200) =NULL, /* Defaults to 'https://api.openai.com'*/
281
+
@AICredential VARCHAR(200) =NULL, /* Defaults to 'https://api.openai.com/' or the root of your AIURL, trailing slash included*/
282
282
@AIConfig NVARCHAR(500) =NULL, /* Table where AI config data is stored - can be in the format db.schema.table, schema.table, or just table. */
283
283
@Version VARCHAR(30) =NULLOUTPUT,
284
284
@VersionDate DATETIME=NULLOUTPUT,
@@ -492,7 +492,7 @@ IF @Help = 1
492
492
UNION ALL
493
493
SELECTN'@AICredential',
494
494
N'VARCHAR(200)',
495
-
N'The database scoped credential that you configured. Defaults to https://api.openai.com. Must be a subset of the @AIURL parameter.'
495
+
N'The database scoped credential that you configured. Defaults to https://api.openai.com/ or the root URL of your @AIURL, trailing slash included. Must be a subset of the @AIURL parameter.'
SET @AIURL =N'https://api.openai.com/v1/chat/completions';
951
951
952
-
IF @AICredential ISNULLOR @AICredential NOTLIKE'http%'
953
-
SET @AICredential =N'https://api.openai.com';
952
+
/* Try to guess the credential based on the root of their URL: */
953
+
IF @AICredential ISNULL
954
+
SET @AICredential =LEFT(@AIURL, CHARINDEX('/', @AIURL, CHARINDEX('://', @AIURL) +3));
954
955
955
956
IF @AITimeoutSeconds ISNULLOR @AITimeoutSeconds <1OR @AITimeoutSeconds >230
956
-
SET @AITimeoutSeconds =30;
957
+
SET @AITimeoutSeconds =230;
957
958
958
959
IF @AISystemPrompt ISNULLOR @AISystemPrompt =N''
959
960
SET @AISystemPrompt =N'You are a very senior database developer working with Microsoft SQL Server and Azure SQL DB. You focus on real-world, actionable advice that will make a big difference, quickly. You value everyone''s time, and while you are friendly and courteous, you do not waste time with pleasantries or emoji because you work in a fast-paced corporate environment.
@@ -962,7 +963,17 @@ IF @AI > 0
962
963
963
964
Do not offer followup options: the customer can only contact you once, so include all necessary information, tasks, and scripts in your initial reply. Render your output in Markdown, as it will be shown in plain text to the customer.';
964
965
965
-
IF @AIPayloadTemplate ISNULL
966
+
IF @AIURL LIKE'https://generativelanguage.googleapis.com%'AND @AIPayloadTemplate ISNULL
967
+
SET @AIPayloadTemplate = N'{
968
+
"contents": [
969
+
{
970
+
"parts": [
971
+
{"text": "@AISystemPrompt @CurrentAIPrompt"}
972
+
]
973
+
}
974
+
]
975
+
}';
976
+
ELSEIF @AIPayloadTemplate ISNULL/* Default to ChatGPT format */
0 commit comments