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: db/sql/11-orchestrate_request.sql
+13-8Lines changed: 13 additions & 8 deletions
Original file line number
Diff line number
Diff line change
@@ -33,12 +33,12 @@ json_object(
33
33
[updated_on] datetime2(0) not null
34
34
)
35
35
36
-
To search into "details, "notes" and "description" columns, you can use the following steps:
36
+
Any time search into "details, "notes" and "description" columns is needed, you must use the following steps:
37
37
38
-
First, generate the embedding vector for the provided question using the following T-SQL query.
38
+
First, generate the embedding vector for the provided question using the following T-SQL query. ''<search text'' must be generating taking the relevant part from the user question.
if (@retval != 0) throw 50000, ''Error in getting the embedding'',1;
43
43
44
44
The vectors for details, notes and description columns are stored in the following tables:
@@ -65,18 +65,23 @@ json_object(
65
65
left join
66
66
dbo.samples_details_embeddings de on e.id = de.id
67
67
order by
68
-
distance_score asc;
68
+
distance_score asc
69
69
70
-
always return the distance_score.
70
+
When search in description, details and notes columns is not needed then you must use the following query:
71
71
72
-
To use the LIKE operator on details column, the column must be converted to NVARCHAR(MAX) first:
72
+
select top(@k)
73
+
s.id, [name], [description], [notes], [details],
74
+
0.0 as distance_score
75
+
from
76
+
dbo.samples s
77
+
78
+
In any case to use the LIKE operator on details column, the column must be converted to NVARCHAR(MAX) first:
73
79
74
80
CAST([details] AS NVARCHAR(MAX)) LIKE ''search text''
75
81
76
-
Return the top 50 results maximum.
77
-
Always return only the following columns from the generated query: id, name, description, notes, details, distance_score
78
82
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.
79
83
Return the top 10 results if you can. Do not use semicolon to terminate the T-SQL statement.
84
+
Only return the following columns: id int, [name] nvarchar(100), [description] nvarchar(max), notes nvarchar(max), details json, distance_score float.
80
85
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.
Copy file name to clipboardExpand all lines: db/utils-scripts/hybrid-search-with-prompt-engineering.sql
+12-5Lines changed: 12 additions & 5 deletions
Original file line number
Diff line number
Diff line change
@@ -10,6 +10,7 @@ declare @text nvarchar(max);
10
10
--set @text = 'create a new table named dbo.test';
11
11
--set @text = 'how many customers there are in the customers table?';
12
12
set @text ='Find all the hybrid search samples created after 2025';
13
+
--set @text = 'Show me the latest samples'
13
14
14
15
declare @retval int, @response nvarchar(max);
15
16
@@ -38,7 +39,7 @@ json_object(
38
39
[updated_on] datetime2(0) not null
39
40
)
40
41
41
-
To search into "details, "notes" and "description" columns, you can use the following steps:
42
+
Any time search into "details, "notes" and "description" columns is needed, you must use the following steps:
42
43
43
44
First, generate the embedding vector for the provided question using the following T-SQL query. ''<search text'' must be generating taking the relevant part from the user question.
44
45
@@ -70,17 +71,23 @@ json_object(
70
71
left join
71
72
dbo.samples_details_embeddings de on e.id = de.id
72
73
order by
73
-
distance_score asc;
74
+
distance_score asc
74
75
75
-
always return the distance_score.
76
+
When search in description, details and notes columns is not needed then you must use the following query:
76
77
77
-
To use the LIKE operator on details column, the column must be converted to NVARCHAR(MAX) first:
78
+
select top(@k)
79
+
s.id, [name], [description], [notes], [details],
80
+
0.0 as distance_score
81
+
from
82
+
dbo.samples s
83
+
84
+
In any case to use the LIKE operator on details column, the column must be converted to NVARCHAR(MAX) first:
78
85
79
86
CAST([details] AS NVARCHAR(MAX)) LIKE ''search text''
80
87
81
-
Return the top 50 results maximum.
82
88
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.
83
89
Return the top 10 results if you can. Do not use semicolon to terminate the T-SQL statement.
90
+
Only return the following columns: id int, [name] nvarchar(100), [description] nvarchar(max), notes nvarchar(max), details json, distance_score float.
84
91
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.
0 commit comments