Skip to content

Commit 990fa3a

Browse files
committed
improved prompt engineering
1 parent 9aeec36 commit 990fa3a

File tree

2 files changed

+25
-13
lines changed

2 files changed

+25
-13
lines changed

db/sql/11-orchestrate_request.sql

Lines changed: 13 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -33,12 +33,12 @@ json_object(
3333
[updated_on] datetime2(0) not null
3434
)
3535
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:
3737
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.
3939
4040
declare @retval int, @qv vector(1536)
41-
exec @retval = web.get_embedding ''<user_question>'', @qv output
41+
exec @retval = web.get_embedding ''<search text>'', @qv output
4242
if (@retval != 0) throw 50000, ''Error in getting the embedding'',1;
4343
4444
The vectors for details, notes and description columns are stored in the following tables:
@@ -65,18 +65,23 @@ json_object(
6565
left join
6666
dbo.samples_details_embeddings de on e.id = de.id
6767
order by
68-
distance_score asc;
68+
distance_score asc
6969
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:
7171
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:
7379
7480
CAST([details] AS NVARCHAR(MAX)) LIKE ''search text''
7581
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
7882
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.
7983
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.
8085
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.
8186
8287
'

db/utils-scripts/hybrid-search-with-prompt-engineering.sql

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ declare @text nvarchar(max);
1010
--set @text = 'create a new table named dbo.test';
1111
--set @text = 'how many customers there are in the customers table?';
1212
set @text = 'Find all the hybrid search samples created after 2025';
13+
--set @text = 'Show me the latest samples'
1314

1415
declare @retval int, @response nvarchar(max);
1516

@@ -38,7 +39,7 @@ json_object(
3839
[updated_on] datetime2(0) not null
3940
)
4041
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:
4243
4344
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.
4445
@@ -70,17 +71,23 @@ json_object(
7071
left join
7172
dbo.samples_details_embeddings de on e.id = de.id
7273
order by
73-
distance_score asc;
74+
distance_score asc
7475
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:
7677
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:
7885
7986
CAST([details] AS NVARCHAR(MAX)) LIKE ''search text''
8087
81-
Return the top 50 results maximum.
8288
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.
8389
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.
8491
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.
8592
8693
'

0 commit comments

Comments
 (0)