8000 added database scoped credentials · 7effrey89/azure-sql-db-openai@146bef8 · GitHub
[go: up one dir, main page]

Skip to content

Commit 146bef8

Browse files
committed
added database scoped credentials
1 parent c9c2a9d commit 146bef8

File tree

1 file changed

+13
-2
lines changed

1 file changed

+13
-2
lines changed

vector-embeddings/03-find-similar-articles.sql

Lines changed: 13 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,24 @@
1+
/*
2+
Create database credentials to store API key
3+
*/
4+
if exists(select * from sys.[database_scoped_credentials] where name = 'https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>')
5+
begin
6+
drop database scoped credential [https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>];
7+
end
8+
create database scoped credential [https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>]
9+
with identity = 'HTTPEndpointHeaders', secret = '{"api-key": "<api-key>"}';
10+
go
11+
112
/*
213
Get the embeddings for the input text by calling the OpenAI API
314
*/
415
declare @inputText nvarchar(max) = 'the foundation series by isaac asimov';
516
declare @retval int, @response nvarchar(max);
617
declare @payload nvarchar(max) = json_object('input': @inputText);
718
exec @retval = sp_invoke_external_rest_endpoint
8-
@url = 'https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>/embeddings?api-version=2023-03-15-preview',
19+
@url = 'https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>?api-version=2023-03-15-preview',
920
@method = 'POST',
10-
@headers = '{"api-key":"<api-key>"}',
21+
@credential = [https://<your-app-name>.openai.azure.com/openai/deployments/<deployment-id>],
1122
@payload = @payload,
1223
@response = @response output;
1324
drop table if exists #response;

0 commit comments

Comments
 (0)
0