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
Generative AI support for Spring Petclinic Microservices (#281)
* updated git ignore
* New microservice for generative ai chatbot based on Spring AI. Supports listing vets, listing owners, adding owners and adding pets to owners
* Update README.md
* Use webjar as webjar
* Externalise JavaScript for handling chatbox interaction
* Use @PostMapping for the /fallback endpoint
* Configure the /fallback uri for the POST verb only
* Move the spring-ai.png to the docs directory
* Switch by default to the openai demo account
* Use lambda expression
* Remove Lombok from the genai-service
* Remove creds.yaml
* Fix SonarQube issues
* Fix SonarQube issues (second attempt)
* Add the genai-service
* Use lambda expression
* Fix Docker warnings
* Setting the GenAI environment variables
---------
Co-authored-by: Antoine Rey <[email protected]>
* Customers, Vets, Visits and GenAI Services - random port, check Eureka Dashboard
21
21
* Tracing Server (Zipkin) - http://localhost:9411/zipkin/ (we use [openzipkin](https://github.com/openzipkin/zipkin/tree/main/zipkin-server))
22
22
* Admin Server (Spring Boot Admin) - http://localhost:9090
23
23
* Grafana Dashboards - http://localhost:3000
@@ -46,7 +46,7 @@ For instance, if you target container images for an Apple M2, you could use the
46
46
```
47
47
48
48
Once images are ready, you can start them with a single command
49
-
`docker-compose up` or `podman-compose up`.
49
+
`dockercompose up` or `podman-compose up`.
50
50
51
51
Containers startup order is coordinated with the `service_healthy` condition of the Docker Compose [depends-on](https://github.com/compose-spec/compose-spec/blob/main/spec.md#depends_on) expression
52
52
and the [healthcheck](https://github.com/compose-spec/compose-spec/blob/main/spec.md#healthcheck) of the service containers.
@@ -79,6 +79,7 @@ This project consists of several microservices:
79
79
-**Customers Service**: Manages customer data.
80
80
-**Vets Service**: Handles information about veterinarians.
81
81
-**Visits Service**: Manages pet visit records.
82
+
-**GenAI Service**: Provides a chatbot interface to the application.
82
83
-**API Gateway**: Routes client requests to the appropriate services.
83
84
-**Config Server**: Centralized configuration management for all services.
84
85
-**Discovery Server**: Eureka-based service registry.
@@ -93,6 +94,41 @@ Each service has its own specific role and communicates via REST APIs.
Spring Petclinic integrates a Chatbot that allows you to interact with the application in a natural language. Here are some examples of what you could ask:
100
+
101
+
1. Please list the owners that come to the clinic.
102
+
2. Are there any vets that specialize in surgery?
103
+
3. Is there an owner named Betty?
104
+
4. Which owners have dogs?
105
+
5. Add a dog for Betty. Its name is Moopsie.
106
+
6. Create a new owner.
107
+
108
+

109
+
110
+
This `spring-petlinic-genai-service` microservice currently supports **OpenAI** (default) or **Azure's OpenAI** as the LLM provider.
111
+
In order to start the microservice, perform the following steps:
112
+
113
+
1. Decide which provider you want to use. By default, the `spring-ai-openai-spring-boot-starter` dependency is enabled.
114
+
You can change it to `spring-ai-azure-openai-spring-boot-starter`in the `pom.xml`.
115
+
2. Create an OpenAI API key or a Azure OpenAI resource in your Azure Portal.
116
+
Refer to the [OpenAI's quickstart](https://platform.openai.com/docs/quickstart) or [Azure's documentation](https://learn.microsoft.com/en-us/azure/ai-services/openai/) for further information on how to obtain these.
117
+
You only need to populate the provider you're using - either openai, or azure-openai.
118
+
If you don't have your own OpenAI API key, don't worry!
119
+
You can temporarily use the `demo` key, which OpenAI provides free of charge for demonstration purposes.
120
+
This `demo` key has a quota, is limited to the `gpt-4o-mini` model, and is intended solely for demonstration use.
121
+
With your own OpenAI account, you can test the `gpt-4o` model by modifying the `deployment-name` property of the `application.yml` file.
122
+
3. Export your API keys and endpoint as environment variables:
Copy file name to clipboardexpand all lines: spring-petclinic-api-gateway/src/main/java/org/springframework/samples/petclinic/api/ApiGatewayApplication.java
0 commit comments