Skip to content

Commit 50543d8

Browse files
committed
edits
1 parent 6c72f31 commit 50543d8

14 files changed

+138
-143
lines changed

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/2-pgvector-azure-postgresql-setup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uid: learn.azure.build-enterprise-ai-agents-with-java-spring.2-pgvector-azure-po
33
title: Set up the pgvector extension in Azure PostgreSQL for use with Spring AI
44
metadata:
55
title: Set Up the pgvector Extension in Azure PostgreSQL for Use with Spring AI
6-
description: Learn how to use the pgvector extension in Azure PostgreSQL and apply the Vector Search Similarity abstraction in Spring AI.
6+
description: Learn how to use the pgvector extension in Azure PostgreSQL and apply the vector similarity search abstraction in Spring AI.
77
ms.date: 03/12/2024
88
author: KarlErickson
99
ms.author: karler

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/3-exercise-pgvector-azure-postgresql-setup.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uid: learn.azure.build-enterprise-ai-agents-with-java-spring.3-exercise-pgvector
33
title: Exercise - Set up the pgvector extension in Azure PostgresQL for use with Spring AI
44
metadata:
55
title: Exercise - Set Up the pgvector Extension in Azure PostgreSQL for Use with Spring AI
6-
description: Set up the pgvector extension in Azure PostgreSQL to apply the Vector Search Similarity abstraction in Spring AI.
6+
description: Set up the pgvector extension in Azure PostgreSQL to apply the vector similarity search abstraction in Spring AI.
77
ms.date: 03/12/2024
88
author: KarlErickson
99
ms.author: karler

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/5-exercise-spring-ai-development.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,7 @@ uid: learn.azure.build-enterprise-ai-agents-with-java-spring.5-exercise-spring-a
33
title: Exercise - Develop a RAG application with Spring AI and Azure OpenAI
44
metadata:
55
title: Exercise - Develop a RAG Application with Spring AI and Azure OpenAI
6-
description: Learn how to develop a Spring AI application integrated with Azure OpenAI for retrieval augmented generation (RAG) and implement an Evaluator Optimizer Agent to iteratively refine AI-generated content.
6+
description: Learn how to develop a Spring AI application integrated with Azure OpenAI for retrieval augmented generation (RAG) and implement an Evaluator-Optimizer agent to iteratively refine AI-generated content.
77
ms.date: 03/12/2024
88
author: KarlErickson
99
ms.author: karler

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/6-agent-ai-development.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
### YamlMime:ModuleUnit
22
uid: learn.azure.build-enterprise-ai-agents-with-java-spring.6-agent-ai-development
3-
title: Implement the Evaluator Optimizer Agent pattern using Spring AI
3+
title: Implement the Evaluator-Optimizer agent pattern using Spring AI
44
metadata:
5-
title: Implement the Evaluator Optimizer Agent Pattern Using Spring AI
6-
description: Learn how to implement the Evaluator Optimizer Agent pattern using Spring AI.
5+
title: Implement the Evaluator-Optimizer agent Pattern Using Spring AI
6+
description: Learn how to implement the Evaluator-Optimizer agent pattern using Spring AI.
77
ms.date: 03/12/2024
88
author: KarlErickson
99
ms.author: karler

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/7-exercise-agent-ai-development.yml

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
### YamlMime:ModuleUnit
22
uid: learn.azure.build-enterprise-ai-agents-with-java-spring.7-exercise-agent-ai-development
3-
title: Exercise - Implement the Evaluator Optimizer Agent pattern using Spring AI
3+
title: Exercise - Implement the Evaluator-Optimizer agent pattern using Spring AI
44
metadata:
5-
title: Exercise - Implement the Evaluator Optimizer Agent pattern using Spring AI
6-
description: Learn how to implement the Evaluator Optimizer Agent pattern using Spring AI.
5+
title: Exercise - Implement the Evaluator-Optimizer agent pattern using Spring AI
6+
description: Learn how to implement the Evaluator-Optimizer agent pattern using Spring AI.
77
ms.date: 03/12/2024
88
author: KarlErickson
99
ms.author: karler

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/includes/1-introduction.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -21,7 +21,7 @@ A RAG application typically has the following capabilities:
2121

2222
## Agents and workflows
2323

24-
Spring AI also empowers you to build dynamic AI agents and orchestrated workflows. While various patterns exist - like chain, parallelization and routing - this module focuses exclusively on the *Evaluator-Optimizer* workflow.
24+
Spring AI also empowers you to build dynamic AI agents and orchestrated workflows. Although various patterns exist - like chain, parallelization and routing - this module focuses exclusively on the *Evaluator-Optimizer* workflow.
2525

2626
This pattern iteratively refines outputs through a generator-evaluator loop, ensuring high-quality and adaptive AI responses.
2727

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/includes/10-summary.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,7 @@ Congratulations! You completed this comprehensive module on building AI-powered
99

1010
- AI agents:
1111
- Agent AI design patterns.
12-
- The Evaluator-Optimizer Agent pattern.
12+
- The Evaluator-Optimizer agent pattern.
1313

1414
- Azure integration:
1515
- OpenAI service configuration.

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/includes/2-pgvector-azure-postgresql-setup.md

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1-
## What is Vector Search Similarity?
1+
## What is vector similarity search?
22

3-
Vector Search Similarity is a technique used to find similar items in a dataset by comparing their vector representations. Vector similarity is commonly calculated using distance metrics, such as Euclidean distance or `cosine` similarity. In the context of AI and machine learning, vector representations or embeddings are numerical representations of data points, such as words, images, or user queries. These vectors capture the semantic meaning of the data points, enabling efficient similarity searches.
3+
Vector similarity search is a technique used to find similar items in a dataset by comparing their vector representations. Vector similarity is commonly calculated using distance metrics, such as Euclidean distance or `cosine` similarity. In the context of AI and machine learning, vector representations or embeddings are numerical representations of data points, such as words, images, or user queries. These vectors capture the semantic meaning of the data points, enabling efficient similarity searches.
44

55
For example, in a question-answering system, user queries can be converted into vector embeddings. These embeddings can then be compared to a database of precomputed embeddings of previous prompts and answers to find the most similar ones. This process is known as vector similarity search.
66

@@ -48,6 +48,6 @@ On startup, Spring Boot installs the required extensions and creates the require
4848

4949
## Unit summary
5050

51-
Vector Search Similarity and the `pgvector` extension provide powerful capabilities for building AI-powered applications that require semantic search functionality. By using these tools in Azure PostgreSQL, you can efficiently store, index, and query vector embeddings, enabling advanced search and retrieval features in your applications.
51+
Vector similarity search and the `pgvector` extension provide powerful capabilities for building AI-powered applications that require semantic search functionality. By using these tools in Azure PostgreSQL, you can efficiently store, index, and query vector embeddings, enabling advanced search and retrieval features in your applications.
5252

5353
In the next unit, you perform the steps to create and configure a PostgreSQL database, enable the `pgvector` extension, and create required tables for use with Spring AI.

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/includes/4-spring-ai-development.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
In this unit, you learn how to implement retrieval-augmented generation (RAG) in a Spring Boot application using vector search similarity provided by the `pgvector` extension in a PostgreSQL database. We introduce relevant RAG concepts such as embeddings, embedding models, and vector stores. By the end of this unit, you should understand how to apply these tools to enhance your applications with advanced search and retrieval capabilities.
1+
In this unit, you learn how to implement retrieval-augmented generation (RAG) in a Spring Boot application using vector similarity search provided by the `pgvector` extension in a PostgreSQL database. We introduce relevant RAG concepts such as embeddings, embedding models, and vector stores. By the end of this unit, you should understand how to apply these tools to enhance your applications with advanced search and retrieval capabilities.
22

33
## What are embeddings?
44

learn-pr/azure/build-enterprise-ai-agents-with-java-spring/includes/5-exercise-spring-ai-development.md

Lines changed: 26 additions & 30 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ For your application, you first need to deploy one chat model - `gpt-4o` - and o
2828

2929
### Create an Azure OpenAI account
3030

31-
Use the following command to create the Azure OpenAI account:
31+
Use the following command to create an Azure OpenAI account:
3232

3333
```azurecli
3434
az cognitiveservices account create \
@@ -93,45 +93,38 @@ curl https://start.spring.io/starter.zip \
9393

9494
The generated Spring Boot starter project includes the following configurations and dependencies:
9595

96-
- Spring Boot Version: 3.4.3
97-
- Java Version: 17
96+
- Spring Boot version: 3.4.3
97+
- Java version: 17
9898
- Dependencies:
9999
- `web`: adds support for building web applications, including RESTful services using Spring Model View Controller (MVC).
100100
- `jdbc`: provides Java Database Connectivity (JDBC) support for database access.
101101
- `azure-support`: adds support for integrating with Azure services.
102102
- `spring-ai-azure-openai`: adds support for integrating with Azure OpenAI services.
103103
- `spring-ai-vectordb-pgvector`: adds support for using `pgvector`, a PostgreSQL extension for vector embeddings.
104104

105-
Unzip the downloaded file using the command:
105+
Use the following commands to unzip the downloaded file and navigate to the created directory:
106106

107107
```bash
108108
unzip -u spring-ai-app.zip -d spring-ai-app
109-
```
110-
111-
Switch directory to this path:
112-
113-
```bash
114109
cd spring-ai-app
115110
```
116111

117-
You need to change the **pom.xml** file to include a dependency for passwordless authentication for PostgreSQL.
118-
119-
Open the **pom.xml** file, locate the `<dependencies>` section and add the following dependency:
112+
Next, you need to change the **pom.xml** file to include a dependency for passwordless authentication for PostgreSQL. Open the **pom.xml** file, locate the `<dependencies>` section, and then add the following dependency:
120113

121114
```xml
122-
<dependency>
123-
<groupId>com.azure.spring</groupId>
124-
<artifactId>spring-cloud-azure-starter-jdbc-postgresql</artifactId>
125-
</dependency>
115+
<dependency>
116+
<groupId>com.azure.spring</groupId>
117+
<artifactId>spring-cloud-azure-starter-jdbc-postgresql</artifactId>
118+
</dependency>
126119
```
127120

128-
You can compile the application skipping tests using this command:
121+
Then, use the following command to compile the application, skipping tests:
129122

130123
```bash
131124
mvn clean package -DskipTests
132125
```
133126

134-
Expect to see a successful build output:
127+
The output should include a success message similar to the following example:
135128

136129
```output
137130
[INFO] ------------------------------------------------------------------------
@@ -144,7 +137,7 @@ Expect to see a successful build output:
144137

145138
### Project structure
146139

147-
From the **spring-ai-app** directory, run the following commands to create new directories for new source files to be added:
140+
From the **spring-ai-app** directory, use the following commands to create new directories for new source files to be added:
148141

149142
```bash
150143
mkdir -p src/main/java/com/example/springaiapp/controller
@@ -210,9 +203,9 @@ az postgres flexible-server show \
210203
--output tsv
211204
```
212205

213-
#### Review the application.properties file
206+
#### Update the application.properties file
214207

215-
Locate and open the **application.properties** file in the **src/main/resources** directory. There are three properties that are initialized using values from the following environment variables: `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`, and `PGHOST`:
208+
Locate and open the **application.properties** file in the **src/main/resources** directory. There are three properties that are initialized using values from the following environment variables: `AZURE_OPENAI_API_KEY`, `AZURE_OPENAI_ENDPOINT`, and `PGHOST`. Replace the file's content with the following content:
216209

217210
```properties
218211
spring.application.name=spring-ai-app
@@ -232,7 +225,7 @@ spring.ai.vectorstore.pgvector.schema-name=postgres
232225

233226
#### Create the service
234227

235-
Within the **service** directory, create a new file named **RagService.java** with the following content:
228+
Within the **service** directory, create a new file named **RagService.java** and add the following code:
236229

237230
```java
238231
package com.example.springaiapp.service;
@@ -298,7 +291,7 @@ This code implements RAG by generating an answer to a given query, augmenting th
298291

299292
#### Create the RAG controller
300293

301-
Next, you need to expose a REST endpoint for your RAG application. Create a new file named **RagController.java** within the **controller** directory:
294+
Next, you need to expose a REST endpoint for your RAG application. Create a new file named **RagController.java** within the **controller** directory, and then add the following code:
302295

303296
```java
304297
package com.example.springaiapp.controller;
@@ -323,7 +316,7 @@ public class RagController {
323316

324317
#### Test the RAG application
325318

326-
With these changes in place, test the implementation by using the following command:
319+
With these changes in place, use the following command to compile and run the code:
327320

328321
```bash
329322
mvn spring-boot:run
@@ -332,7 +325,8 @@ mvn spring-boot:run
332325
Test the new REST endpoint either from a browser or by using the following command:
333326

334327
```bash
335-
curl -G "http://localhost:8080/api/rag" --data-urlencode "query=What is pgvector?"
328+
curl -G "http://localhost:8080/api/rag" \
329+
--data-urlencode "query=What is pgvector?"
336330
```
337331

338332
You should see a valid response similar to the following example:
@@ -345,14 +339,15 @@ and querying of vector embeddings within a PostgreSQL database.
345339
Next, try the following command:
346340

347341
```bash
348-
curl -G "http://localhost:8080/api/rag" --data-urlencode "query=How does QuestionAnswerAdvisor work in Spring AI?"
342+
curl -G "http://localhost:8080/api/rag" \
343+
--data-urlencode "query=How does QuestionAnswerAdvisor work in Spring AI?"
349344
```
350345

351-
While the answer might appear valid, it might include phrasing that indicates it's a reasoned guess.
346+
Although the answer might appear valid, it might include phrasing that indicates it's a reasoned guess.
352347

353348
#### Test the application with extra knowledge
354349

355-
Next, provide extra knowledge by adding the following documents to the vector store. Create a new file named **DocumentService.java** within the **service** directory, and then add the following contents:
350+
Next, provide extra knowledge by adding documents to the vector store. Create a new file named **DocumentService.java** within the **service** directory, and then add the following code:
356351

357352
```java
358353
package com.example.springaiapp.service;
@@ -410,7 +405,7 @@ public class DocumentService {
410405
}
411406
```
412407

413-
Test these changes by using the following commands:
408+
To test these changes, use the following command to compile and run the code:
414409

415410
```bash
416411
mvn spring-boot:run
@@ -419,7 +414,8 @@ mvn spring-boot:run
419414
Then, ask a question by using the following command:
420415

421416
```bash
422-
curl -G "http://localhost:8080/api/rag" --data-urlencode "query=How does QuestionAnswerAdvisor work in Spring AI?"
417+
curl -G "http://localhost:8080/api/rag" \
418+
--data-urlencode "query=How does QuestionAnswerAdvisor work in Spring AI?"
423419
```
424420

425421
You should now see an answer that clearly explains the role of `QuestionAnswerAdvisor` within Spring AI.

0 commit comments

Comments
 (0)