Skip to content

Navigation Menu

Sign in
Appearance settings

Search code, repositories, users, issues, pull requests...

Provide feedback

We read every piece of feedback, and take your input very seriously.

Saved searches

Use saved searches to filter your results more quickly

Appearance settings

Commit 146bef8

Browse filesBrowse files
committed
added database scoped credentials
1 parent c9c2a9d commit 146bef8
Copy full SHA for 146bef8

File tree

1 file changed

+13
-2
lines changed
Filter options

1 file changed

+13
-2
lines changed

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

Copy file name to clipboardExpand all lines: vector-embeddings/03-find-similar-articles.sql
+13-2Lines 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)
Morty Proxy This is a proxified and sanitized view of the page, visit original site.