You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#customer intent: As a developer, I want to understand the architecture of AI applications deployed to Azure Container Apps.
11
11
---
@@ -20,37 +20,38 @@ The application features many different services working together to introduce t
20
20
21
21
## Architecture of the AI app in Azure Container Apps
22
22
23
-
The following diagram shows the architecture of the AI application in Azure Container Apps.
23
+
The following diagram shows the architecture of the AI application in Azure Container Apps:
24
24
25
25
:::image type="complex" source="media/first-java-ai-application/architecture-chart.png" alt-text="Diagram of the architecture of the AI application, which includes a Container Apps environment, an API gateway, Entra ID for authentication, and other components." lightbox="media/first-java-ai-application/architecture-chart.png":::
26
26
Diagram that shows the architecture of the AI application. Users access the system through authentication managed by Entra ID. The Azure Container App environment contains an API gateway that enables routing for and communication with the application. The API gateway uses managed identities to securely interact with Azure Container Registry and cognitive services. The API gateway also handles communication with external users. A virtual network between the API gateway and external systems provides secure and isolated network connectivity.
27
27
:::image-end:::
28
28
29
29
The application's API gateway, hosted in the Azure Container Apps environment, serves as the central entry point for all external requests.
30
30
31
-
This gateway:
31
+
This gateway performs the following functions:
32
32
33
-
- Routes and manages communication between application components
34
-
- Authenticates users through Microsoft Entra ID
35
-
- Secures access to Azure Container Registry and cognitive services using managed identities
36
-
- Handles all incoming external user requests
33
+
- Routes and manages communication between application components.
34
+
- Authenticates users through Microsoft Entra ID.
35
+
- Secures access to Azure Container Registry and cognitive services using managed identities.
36
+
- Handles all incoming external user requests.
37
37
38
38
The gateway operates within a dedicated virtual network, ensuring secure and isolated communication between the application and external systems.
39
39
40
40
The following are the key components and services featured in the application:
41
41
42
-
| Service or feature | Description |
43
-
|---|---|
44
-
|[Azure Container Apps](/azure/container-apps/overview)| A fully managed serverless container platform for building and deploying modern apps. Handles autoscaling, traffic splitting, and revision management of containerized applications. |
45
-
|[Azure Container Apps environment](/azure/container-apps/environment)| A secure boundary around a group of container apps that share networking, scaling, and management configurations. Provides the foundational runtime for container apps deployment. |
46
-
|[Azure OpenAI Service](/azure/ai-services/openai/overview)| Provides REST API access to OpenAI's powerful language models like GPT-4, embeddings, and ChatGPT. Enables AI capabilities with enterprise-grade security and compliance features. |
47
-
|[Azure Container Registry](/azure/container-registry/container-registry-intro)| A private Docker registry service for storing and managing container images. Supports automated container builds, vulnerability scanning, and geo-replication. |
48
-
|[Managed Identities](/entra/identity/managed-identities-azure-resources/overview)| Provides Azure services with automatically managed identities in Azure AD. Eliminates the need for credential management by allowing secure service-to-service authentication without storing credentials in code. |
49
-
|[Spring AI](https://spring.io/projects/spring-ai)| Spring framework for AI engineering that applies AI design principles to the Spring ecosystem. Alternatively, [Langchain4j](https://docs.langchain4j.dev/intro) is another AI framework with its own PetClinic sample in [spring-petclinic-langchain4j](https://github.com/Azure-Samples/spring-petclinic-langchain4j). For more information, see [Chat Client API](https://docs.spring.io/spring-ai/reference/api/chatclient.html).|
|[Azure Container Apps](/azure/container-apps/overview)| A fully managed serverless container platform for building and deploying modern apps. Handles autoscaling, traffic splitting, and revision management of containerized applications.|
45
+
|[Azure Container Apps environment](/azure/container-apps/environment)| A secure boundary around a group of container apps that share networking, scaling, and management configurations. Provides the foundational runtime for container apps deployment.|
46
+
|[Azure OpenAI Service](/azure/ai-services/openai/overview)| Provides REST API access to OpenAI's powerful language models like GPT-4, embeddings, and ChatGPT. Enables AI capabilities with enterprise-grade security and compliance features.|
47
+
|[Azure Container Registry](/azure/container-registry/container-registry-intro)| A private Docker registry service for storing and managing container images. Supports automated container builds, vulnerability scanning, and geo-replication.|
48
+
|[Managed Identities](/entra/identity/managed-identities-azure-resources/overview)| Provides Azure services with automatically managed identities in Azure AD. Eliminates the need for credential management by allowing secure service-to-service authentication without storing credentials in code. |
49
+
|[Spring AI](https://spring.io/projects/spring-ai)| Spring framework for AI engineering that applies AI design principles to the Spring ecosystem. Alternatively, [Langchain4j](https://docs.langchain4j.dev/intro) is another AI framework with its own PetClinic sample in [spring-petclinic-langchain4j](https://github.com/Azure-Samples/spring-petclinic-langchain4j). For more information, see [Chat Client API](https://docs.spring.io/spring-ai/reference/api/chatclient.html).|
50
50
51
-
For more detail on infrastructure as code elements of the application, refer to the [bicep scripts](https://github.com/Azure-Samples/spring-petclinic-ai/blob/main/infra/bicep/main.bicep) in the [spring-petclinic-ai](https://github.com/Azure-Samples/spring-petclinic-ai/) repository.
51
+
For more information on infrastructure as code elements of the application, see the [bicep scripts](https://github.com/Azure-Samples/spring-petclinic-ai/blob/main/infra/bicep/main.bicep) in the [Bring your first AI app in Azure Container Apps](https://github.com/Azure-Samples/spring-petclinic-ai/) repository
52
+
.
52
53
53
-
###Code implementation
54
+
## Code implementation
54
55
55
56
The following information is an introduction to the code for readers to understand the flow of this first AI application:
The [`ChatConfiguration`](https://github.com/Azure-Samples/spring-petclinic-ai/blob/main/src/main/java/org/springframework/samples/petclinic/genai/ChatConfiguration.java) class customizes requests sent to `chatClient`. The following are some key configuration settings of `chatClient`:
68
69
69
-
-**Connections authentication**: The client connects to Azure OpenAI. Both API key authentication and managed identity authentication are supported.
70
+
- Connections authentication: The client connects to Azure OpenAI. Both API key authentication and managed identity authentication are supported.
71
+
- Configuration settings location: For `ChatModel`, deployment `gpt-4o` and temperature `0.7` are set in the configuration file.
72
+
- Vector database: The vector database stores mathematical representations of source documents, known as *embeddings*. The vector data is used by the chat API to find documents relevant to a user's question.
73
+
- System prompt: Customize AI behavior and enhance performance.
74
+
- API endpoints: The application features customized Azure Functions endpoints so that OpenAI to interact with the application.
75
+
- Advisors: Advisors provide a flexible and powerful way to intercept, modify, and enhance AI-driven interactions in your Spring applications.
70
76
71
-
-**Configuration settings location**: For `ChatModel`, deployment `gpt-4o` and temperature `0.7` are set in the configuration file.
77
+
### Example
72
78
73
-
-**Vector database**: The vector database stores mathematical representations of source documents, known as *embeddings*. The vector data is used by the chat API to find documents relevant to a user's question.
74
-
75
-
-**System prompt**: Customize AI behavior and enhance performance.
76
-
77
-
-**API endpoints**: The application features customized Azure Functions endpoints so that OpenAI to interact with the application.
78
-
79
-
-**Advisors**: Advisors provide a flexible and powerful way to intercept, modify, and enhance AI-driven interactions in your Spring applications.
80
-
81
-
#### Example
82
-
83
-
The following code listing shows how the `ChatClientCustomizer` class loads configuration information.
79
+
The following code example shows how the `ChatClientCustomizer` class loads configuration information:
84
80
85
81
```java
86
82
@Bean
@@ -98,7 +94,7 @@ public ChatClientCustomizer chatClientCustomizer(VectorStore vectorStore, ChatMo
98
94
99
95
The beans defined under `java.util.Function` are functions defined in the application context. These functions are the interface between the AI models and the PetClinc application.
100
96
101
-
There are sample functions in [`AIFunctionConfiguration.java`](https://github.com/Azure-Samples/spring-petclinic-ai/blob/main/src/main/java/org/springframework/samples/petclinic/genai/AIFunctionConfiguration.java)which communicate with the PetClinic application.
97
+
There are sample functions in [AIFunctionConfiguration.java](https://github.com/Azure-Samples/spring-petclinic-ai/blob/main/src/main/java/org/springframework/samples/petclinic/genai/AIFunctionConfiguration.java)that communicate with the PetClinic application.
102
98
103
99
Keep in mind the following details about these functions:
104
100
@@ -107,17 +103,16 @@ Keep in mind the following details about these functions:
107
103
108
104
### Advisors
109
105
110
-
Advisors are components that modify or enhance AI prompts which act as middleware for prompt processing.
106
+
Advisors are components that modify or enhance AI prompts, which act as middleware for prompt processing.
111
107
112
108
This application uses two different advisors:
113
109
114
110
-[`QuestionAnswerAdvisor`](https://github.com/Azure-Samples/spring-petclinic-ai/blob/main/src/main/java/org/springframework/samples/petclinic/genai/ModeledQuestionAnswerAdvisor.java) calls the AI models that generate a new user which includes results from the search vector before finalizing the prompt.
115
-
116
-
-`PromptChatMemoryAdvisor`adds chat memory into the prompt and provide a conversation history to the chat model. With this context, the AI model can remember the context of the chat and improve the chat quality.
111
+
-`PromptChatMemoryAdvisor` adds chat memory into the prompt and provide a conversation history to the chat model. With this context, the AI model can remember the context of the chat and improve the chat quality.
117
112
118
113
For more information, see [Advisors API](https://docs.spring.io/spring-ai/reference/api/advisors.html).
119
114
120
115
## Next steps
121
116
122
117
> [!div class="nextstepaction"]
123
-
> [Deploy an AI-enabled instance of Spring PetClinic on Azure Container Apps](java-petclinic-ai-overview.md)
118
+
> [Deploy an AI-enabled instance of Spring PetClinic on Azure Container Apps](java-petclinic-ai-overview.md).
0 commit comments