Skip to content

Commit 0ee9bea

Browse files
Merge pull request #273529 from AlicjaKucharczyk/20240426-postgrestosql
formating
2 parents 671bcf8 + 671c0fb commit 0ee9bea

12 files changed

+75
-73
lines changed

articles/postgresql/flexible-server/generative-ai-azure-cognitive.md

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ Azure AI extension gives the ability to invoke the [Azure AI Language Services](
2727

2828
In the Language resource, under **Resource Management** > **Keys and Endpoint** you can find the endpoint, keys, and Location/Region for your language resource. Use the endpoint and key to enable `azure_ai` extension to invoke the model deployment. The Location/Region setting is only required for the translation function.
2929

30-
```postgresql
30+
```sql
3131
select azure_ai.set_setting('azure_cognitive.endpoint','https://<endpoint>.cognitiveservices.azure.com');
3232
select azure_ai.set_setting('azure_cognitive.subscription_key', '<API Key>');
3333
-- the region setting is only required for the translate function
@@ -40,7 +40,7 @@ select azure_ai.set_setting('azure_cognitive.region', '<Region>');
4040

4141
### `azure_cognitive.analyze_sentiment`
4242

43-
```postgresql
43+
```sql
4444
azure_cognitive.analyze_sentiment(text text, language text DEFAULT NULL::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
4545
azure_cognitive.analyze_sentiment(text text[], language text DEFAULT NULL::text, batch_size integer DEFAULT 10, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
4646
azure_cognitive.analyze_sentiment(text text[], language text[] DEFAULT NULL::text[], batch_size integer DEFAULT 10, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
@@ -92,7 +92,7 @@ For more information, see Cognitive Services Compliance and Privacy notes at htt
9292

9393
### `azure_cognitive.detect_language`
9494

95-
```postgresql
95+
```sql
9696
azure_cognitive.detect_language(text text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
9797
azure_cognitive.detect_language(text text[], batch_size integer DEFAULT 1000, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
9898
```
@@ -139,7 +139,7 @@ For more information, see Cognitive Services Compliance and Privacy notes at htt
139139

140140
### `azure_cognitive.extract_key_phrases`
141141

142-
```postgresql
142+
```sql
143143
azure_cognitive.extract_key_phrases(text text, language text DEFAULT NULL::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
144144
azure_cognitive.extract_key_phrases(text text[], language text DEFAULT NULL::text, batch_size integer DEFAULT 10, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
145145
azure_cognitive.extract_key_phrases(text text[], language text[] DEFAULT NULL::text[], batch_size integer DEFAULT 10, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
@@ -191,7 +191,7 @@ For more information, see Cognitive Services Compliance and Privacy notes at htt
191191

192192
### `azure_cognitive.linked_entities`
193193

194-
```postgresql
194+
```sql
195195
azure_cognitive.linked_entities(text text, language text DEFAULT NULL::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
196196
azure_cognitive.linked_entities(text text[], language text DEFAULT NULL::text, batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
197197
azure_cognitive.linked_entities(text text[], language text[] DEFAULT NULL::text[], batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
@@ -248,7 +248,7 @@ For more information, see Cognitive Services Compliance and Privacy notes at htt
248248

249249
[Named Entity Recognition (NER) feature in Azure AI](../../ai-services/language-service/named-entity-recognition/overview.md) can identify and categorize entities in unstructured text.
250250

251-
```postgresql
251+
```sql
252252
azure_cognitive.recognize_entities(text text, language text DEFAULT NULL::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
253253
azure_cognitive.recognize_entities(text text[], language text DEFAULT NULL::text, batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
254254
azure_cognitive.recognize_entities(text text[], language text[] DEFAULT NULL::text[], batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
@@ -300,7 +300,7 @@ For more information, see Cognitive Services Compliance and Privacy notes at htt
300300

301301
### `azure_cognitive.recognize_pii_entities`
302302

303-
```postgresql
303+
```sql
304304
azure_cognitive.recognize_pii_entities(text text, language text DEFAULT NULL::text, domain text DEFAULT 'none'::text, disable_service_logs boolean DEFAULT true, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
305305
azure_cognitive.recognize_pii_entities(text text[], language text DEFAULT NULL::text, domain text DEFAULT 'none'::text, batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT true, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
306306
azure_cognitive.recognize_pii_entities(text text[], language text[] DEFAULT NULL::text[], domain text DEFAULT 'none'::text, batch_size integer DEFAULT 5, disable_service_logs boolean DEFAULT true, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
@@ -358,7 +358,7 @@ For more information, see Cognitive Services Compliance and Privacy notes at htt
358358

359359
[Document abstractive summarization](../../ai-services/language-service/summarization/overview.md) produces a summary that might not use the same words in the document but yet captures the main idea.
360360

361-
```postgresql
361+
```sql
362362
azure_cognitive.summarize_abstractive(text text, language text DEFAULT NULL::text, sentence_count integer DEFAULT 3, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
363363
azure_cognitive.summarize_abstractive(text text[], language text DEFAULT NULL::text, sentence_count integer DEFAULT 3, batch_size integer DEFAULT 25, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
364364
azure_cognitive.summarize_abstractive(text text[], language text[] DEFAULT NULL::text[], sentence_count integer DEFAULT 3, batch_size integer DEFAULT 25, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
@@ -412,7 +412,7 @@ For more information, see Cognitive Services Compliance and Privacy notes at htt
412412

413413
[Document extractive summarization](../../ai-services/language-service/summarization/how-to/document-summarization.md) produces a summary extracting key sentences within the document.
414414

415-
```postgresql
415+
```sql
416416
azure_cognitive.summarize_extractive(text text, language text DEFAULT NULL::text, sentence_count integer DEFAULT 3, sort_by text DEFAULT 'offset'::text, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
417417
azure_cognitive.summarize_extractive(text text[], language text DEFAULT NULL::text, sentence_count integer DEFAULT 3, sort_by text DEFAULT 'offset'::text, batch_size integer DEFAULT 25, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
418418
azure_cognitive.summarize_extractive(text text[], language text[] DEFAULT NULL::text[], sentence_count integer DEFAULT 3, sort_by text DEFAULT 'offset'::text, batch_size integer DEFAULT 25, disable_service_logs boolean DEFAULT false, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
@@ -473,7 +473,7 @@ For example, if invoked with a `text` set to `'PostgreSQL features transactions
473473

474474
### `azure_cognitive.translate`
475475

476-
```postgresql
476+
```sql
477477
azure_cognitive.translate(text text, target_language text, source_language text DEFAULT NULL::text, text_type text DEFAULT 'Plain'::text, profanity_action text DEFAULT 'NoAction'::text, profanity_marker text DEFAULT 'Asterisk'::text, suggested_source_language text DEFAULT NULL::text, source_script text DEFAULT NULL::text, target_script text DEFAULT NULL::text, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
478478
azure_cognitive.translate(text text, target_language text[], source_language text DEFAULT NULL::text, text_type text DEFAULT 'Plain'::text, profanity_action text DEFAULT 'NoAction'::text, profanity_marker text DEFAULT 'Asterisk'::text, suggested_source_language text DEFAULT NULL::text, source_script text DEFAULT NULL::text, target_script text[] DEFAULT NULL::text[], timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
479479
azure_cognitive.translate(text text[], target_language text, source_language text DEFAULT NULL::text, text_type text DEFAULT 'Plain'::text, profanity_action text DEFAULT 'NoAction'::text, profanity_marker text DEFAULT 'Asterisk'::text, suggested_source_language text DEFAULT NULL::text, source_script text DEFAULT NULL::text, target_script text DEFAULT NULL::text, batch_size integer DEFAULT 1000, timeout_ms integer DEFAULT NULL::integer, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
@@ -483,7 +483,7 @@ azure_cognitive.translate(text text[], target_language text[], source_language t
483483
> [!NOTE]
484484
> Translation is only available in version 0.2.0 of azure_ai extension. To check the version, check the pg_available_extensions catalog view.
485485
486-
```postgresql
486+
```sql
487487
select * from pg_available_extensions where name = 'azure_ai';
488488
```
489489

@@ -551,14 +551,14 @@ For more information on parameters, see [Translator API](../../ai-services/trans
551551

552552
### Sentiment analysis examples
553553

554-
```postgresql
554+
```sql
555555
select b.*
556556
from azure_cognitive.analyze_sentiment('The book was not great, It is mediocre at best','en') b
557557
```
558558

559559
### Summarization examples
560560

561-
```postgresql
561+
```sql
562562
SELECT
563563
bill_id,
564564
unnest(azure_cognitive.summarize_abstractive(bill_text, 'en')) abstractive_summary
@@ -568,7 +568,7 @@ WHERE bill_id = '114_hr2499';
568568

569569
### Translation examples
570570

571-
```postgresql
571+
```sql
572572
-- Translate into Portuguese
573573
select a.*
574574
from azure_cognitive.translate('Language Translation in real time in multiple languages is quite cool', 'pt') a;
@@ -580,7 +580,7 @@ from azure_cognitive.translate('Language Translation in real time in multiple la
580580

581581
### Personal data detection examples
582582

583-
```postgresql
583+
```sql
584584
select
585585
'Contoso employee with email [email protected] is using our awesome API' as InputColumn,
586586
pii_entities.*

articles/postgresql/flexible-server/generative-ai-azure-machine-learning.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,7 +29,7 @@ Azure AI extension gives the ability to invoke any machine learning models deplo
2929

3030
In the Azure Machine Learning studio, under **Endpoints** > **Pick your endpoint** > **Consume** you can find the endpoint URI and Key for the online endpoint. Use these values to configure the `azure_ai` extension to use the online inferencing endpoint.
3131

32-
```postgresql
32+
```sql
3333
select azure_ai.set_setting('azure_ml.scoring_endpoint','<URI>');
3434
select azure_ai.set_setting('azure_ml.endpoint_key', '<Key>');
3535
```
@@ -38,7 +38,7 @@ select azure_ai.set_setting('azure_ml.endpoint_key', '<Key>');
3838

3939
Scores the input data invoking an Azure Machine Learning model deployment on an [online endpoint](../../machine-learning/how-to-authenticate-online-endpoint.md).
4040

41-
```postgresql
41+
```sql
4242
azure_ml.inference(input_data jsonb, timeout_ms integer DEFAULT NULL, throw_on_error boolean DEFAULT true, deployment_name text DEFAULT NULL)
4343
```
4444

@@ -70,7 +70,7 @@ azure_ml.inference(input_data jsonb, timeout_ms integer DEFAULT NULL, throw_on_e
7070

7171
This calls the model with the input_data and returns a jsonb payload.
7272

73-
```postgresql
73+
```sql
7474
-- Invoke model, input data depends on the model.
7575
SELECT * FROM azure_ml.inference('
7676
{

articles/postgresql/flexible-server/generative-ai-azure-openai.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ Invoke [Azure OpenAI embeddings](../../ai-services/openai/reference.md#embedding
2828

2929
In the Azure OpenAI resource, under **Resource Management** > **Keys and Endpoints** you can find the endpoint and the keys for your Azure OpenAI resource. To invoke the model deployment, enable the `azure_ai` extension using the endpoint and one of the keys.
3030

31-
```postgresql
31+
```sql
3232
select azure_ai.set_setting('azure_openai.endpoint', 'https://<endpoint>.openai.azure.com');
3333
select azure_ai.set_setting('azure_openai.subscription_key', '<API Key>');
3434
```
@@ -37,7 +37,7 @@ select azure_ai.set_setting('azure_openai.subscription_key', '<API Key>');
3737

3838
Invokes the Azure OpenAI API to create embeddings using the provided deployment over the given input.
3939

40-
```postgresql
40+
```sql
4141
azure_openai.create_embeddings(deployment_name text, input text, timeout_ms integer DEFAULT 3600000, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
4242
azure_openai.create_embeddings(deployment_name text, input text[], batch_size integer DEFAULT 100, timeout_ms integer DEFAULT 3600000, throw_on_error boolean DEFAULT true, max_attempts integer DEFAULT 1, retry_delay_ms integer DEFAULT 1000)
4343
```
@@ -77,7 +77,7 @@ azure_openai.create_embeddings(deployment_name text, input text[], batch_size in
7777

7878
## Use OpenAI to create embeddings and store them in a vector data type
7979

80-
```postgresql
80+
```sql
8181
-- Create tables and populate data
8282
DROP TABLE IF EXISTS conference_session_embeddings;
8383
DROP TABLE IF EXISTS conference_sessions;

articles/postgresql/flexible-server/generative-ai-azure-overview.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,7 @@ Before you can enable `azure_ai` on your Azure Database for PostgreSQL flexible
2626
2727
Then you can install the extension, by connecting to your target database and running the [CREATE EXTENSION](https://www.postgresql.org/docs/current/static/sql-createextension.html) command. You need to repeat the command separately for every database you want the extension to be available in.
2828

29-
```postgresql
29+
```sql
3030
CREATE EXTENSION azure_ai;
3131
```
3232

@@ -58,7 +58,7 @@ The `azure_ai_settings_manager` role is by default granted to the `azure_pg_admi
5858

5959
Used to set configuration options.
6060

61-
```postgresql
61+
```sql
6262
azure_ai.set_setting(key TEXT, value TEXT)
6363
```
6464

@@ -80,7 +80,7 @@ Name of a configuration option. Valid values for the `key` are:
8080

8181
Used to obtain current values of configuration options.
8282

83-
```postgresql
83+
```sql
8484
azure_ai.get_setting(key TEXT)
8585
```
8686

@@ -100,7 +100,7 @@ Name of a configuration option. Valid values for the `key` are:
100100

101101
### `azure_ai.version`
102102

103-
```postgresql
103+
```sql
104104
azure_ai.version()
105105
```
106106

@@ -112,21 +112,21 @@ azure_ai.version()
112112

113113
#### Set the Endpoint and an API Key for Azure OpenAI
114114

115-
```postgresql
115+
```sql
116116
select azure_ai.set_setting('azure_openai.endpoint','https://<endpoint>.openai.azure.com');
117117
select azure_ai.set_setting('azure_openai.subscription_key', '<API Key>');
118118
```
119119

120120
#### Get the Endpoint and API Key for Azure OpenAI
121121

122-
```postgresql
122+
```sql
123123
select azure_ai.get_setting('azure_openai.endpoint');
124124
select azure_ai.get_setting('azure_openai.subscription_key');
125125
```
126126

127127
#### Check the Azure AI extension version
128128

129-
```postgresql
129+
```sql
130130
select azure_ai.version();
131131
```
132132

articles/postgresql/flexible-server/generative-ai-recommendation-system.md

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@ Before you can enable `azure_ai` and `pgvector` on your Azure Database for Postg
3333

3434
Then you can install the extension, by connecting to your target database and running the [CREATE EXTENSION](https://www.postgresql.org/docs/current/static/sql-createextension.html) command. You need to repeat the command separately for every database you want the extension to be available in.
3535

36-
```postgresql
36+
```sql
3737
CREATE EXTENSION azure_ai;
3838
CREATE EXTENSION pgvector;
3939
```
@@ -42,7 +42,7 @@ CREATE EXTENSION pgvector;
4242

4343
In the Azure AI services under **Resource Management** > **Keys and Endpoints** you can find the endpoint and the keys for your Azure AI resource. Use the endpoint and one of the keys to enable `azure_ai` extension to invoke the model deployment.
4444

45-
```postgresql
45+
```sql
4646
select azure_ai.set_setting('azure_openai.endpoint','https://<endpoint>.openai.azure.com');
4747
select azure_ai.set_setting('azure_openai.subscription_key', '<API Key>');
4848
```
@@ -58,7 +58,7 @@ select azure_ai.set_setting('azure_openai.subscription_key', '<API Key>');
5858

5959
### Create the table
6060

61-
```postgresql
61+
```sql
6262
CREATE TABLE public.recipes(
6363
rid integer NOT NULL,
6464
recipe_name text,
@@ -101,15 +101,15 @@ psql -d <database> -h <host> -U <user> -c "\copy recipes FROM <local recipe data
101101

102102
### Add a column to store the embeddings
103103

104-
```postgresql
104+
```sql
105105
ALTER TABLE recipes ADD COLUMN embedding vector(1536);
106106
```
107107

108108
### Generate embeddings
109109

110110
Generate embeddings for your data using the azure_ai extension. In the following, we vectorize a few different fields, concatenated:
111111

112-
```postgresql
112+
```sql
113113
WITH ro AS (
114114
SELECT ro.rid
115115
FROM
@@ -136,7 +136,7 @@ Repeat the command, until there are no more rows to process.
136136
137137
Create a search function in your database for convenience:
138138

139-
```postgresql
139+
```sql
140140
create function
141141
recommend_recipe(sampleRecipeId int, numResults int)
142142
returns table(
@@ -169,7 +169,7 @@ language plpgsql;
169169

170170
Now just invoke the function to search for the recommendation:
171171

172-
```postgresql
172+
```sql
173173
select out_recipename, out_similarityscore from recommend_recipe(1, 20); -- search for 20 recipe recommendations that closest to recipeId 1
174174
```
175175

0 commit comments

Comments
 (0)