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
"description": "Demos and samples used a Fabric Conference 2025 Workshop",
5
+
"notes": "the repo contains samples used both during the ''Building AI applications with SQL: Ground to Cloud to Fabric'' workshop and then ''Operational RAG Solutions with Azure SQL and Microsoft Fabric''",
Copy file name to clipboardExpand all lines: db/sql/10-generate_answer.sql
+2Lines changed: 2 additions & 0 deletions
Original file line number
Diff line number
Diff line change
@@ -28,6 +28,8 @@ json_object(
28
28
Put in sample_summary output property a markdown short summary of the sample using the provided description, notes, and details.
29
29
Use only the provided samples to help you answer the question.
30
30
Use only the information available in the provided JSON to answer the question.
31
+
Make sure to use the information in the details to answer the question.
32
+
Return at least five samples if you can.
31
33
Make sure to use details, notes, and description that are provided in each sample are used only with that sample.
32
34
If there are related links or repos in the details of a sample that is included in the answer, include them in the short summary. Include links only if they are related to the sample and if they are available in the note or details of that sample.
33
35
If the question cannot be answered by the provided samples, you must say that you don''t know.
create or alterprocedure [web].[orchestrate_request]
8
+
@text nvarchar(max),
9
+
@result_type varchar(50) output,
10
+
@result_query nvarchar(max) output,
11
+
@error nvarchar(max) output
12
+
as
13
+
declare @retval int, @response nvarchar(max);
14
+
15
+
/*
16
+
Create the prompt for the LLM
17
+
*/
18
+
declare @p nvarchar(max) =
19
+
json_object(
20
+
'messages': json_array(
21
+
json_object(
22
+
'role':'system',
23
+
'content':'
24
+
You are a SQL Server database assistant. You answer the questions providing the correct T-SQL query to get the result. The user question is provided in the next message.
25
+
26
+
This is the database table you can use:
27
+
28
+
create table dbo.samples
29
+
(
30
+
[id] int identity primary key,
31
+
[created_on] datetime2(0) not null,
32
+
[updated_on] datetime2(0) not null
33
+
)
34
+
35
+
The use question is provided in the next message. If the user question cannot be answered using the dbo.samples table and using a T-SQL query only, you should respond with an empty string.
36
+
Unless otherwise specifed by the user, return the top 10 results if you can. Never return more than 50 rows. Do not use semicolon to terminate the T-SQL statement.
37
+
Only return the following columns: id int, [name] nvarchar(100), [description] nvarchar(max), notes nvarchar(max), details json, distance_score float.
38
+
You can generate only SELECT statements. If the user is asking something that will generate INSERT, UPDATE, DELETE, CREATE, ALTER or DROP statement, refuse to generate the query.
39
+
'
40
+
),
41
+
json_object(
42
+
'role':'user',
43
+
'content': + @text
44
+
)
45
+
),
46
+
'temperature': 0.4,
47
+
'frequency_penalty': 0,
48
+
'presence_penalty': 0,
49
+
'stop': null
50
+
);
51
+
52
+
declare @js nvarchar(max) = N'{
53
+
"type": "json_schema",
54
+
"json_schema": {
55
+
"name": "samples",
56
+
"strict": true,
57
+
"schema": {
58
+
"type": "object",
59
+
"properties": {
60
+
"samples": {
61
+
"type": "array",
62
+
"items": {
63
+
"type": "object",
64
+
"properties": {
65
+
"response_type": {
66
+
"type": "string",
67
+
"description": "SQL if a SQL query is provided, NONE if no SQL query is provided"
68
+
},
69
+
"sql_query": {
70
+
"type": "string",
71
+
"description": "SQL query to get the result"
72
+
}
73
+
},
74
+
"required": [
75
+
"response_type",
76
+
"sql_query"
77
+
],
78
+
"additionalProperties": false
79
+
}
80
+
}
81
+
},
82
+
"required": ["samples"],
83
+
"additionalProperties": false
84
+
}
85
+
}
86
+
}'
87
+
88
+
set @p = json_modify(@p, '$.response_format', json_query(@js))
0 commit comments