-
Notifications
You must be signed in to change notification settings - Fork 5
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #34 from smallrye/20-liberty-feature
20 liberty feature
- Loading branch information
Showing
39 changed files
with
1,616 additions
and
34 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,75 @@ | ||
# Car Booking (Open Liberty) | ||
|
||
These are the steps to run this service. | ||
|
||
1. Go to the root `smallrye-llm` directory, then build it using the command: | ||
> `mvn clean install -e` | ||
2. Once the project is built, move to directory `cd examples/liberty-car-booking` and run the following command to install the bundle as a user liberty feature: | ||
> `mvn liberty:dev -e` | ||
|
||
## Application requirements: | ||
- JDK 17 and higher | ||
- Maven 3.9.9 and higher | ||
- LangChain4j 0.33.0 or higher. | ||
- Testing against GPT 3.5 and 4.0 on a dedicated Azure instance (to be customized in your context). | ||
|
||
Then you can access the application through the browser of your choice. | ||
|
||
## Differences with Quarkus-LangChain4j | ||
|
||
Quarkus provides a deep integration with LangChain4j thanks to a specific [extension](https://docs.quarkiverse.io/quarkus-langchain4j/dev/index.html). | ||
|
||
In particular, it provides a powerful `@RegisterAiService` annotation and network interactions with LLMs are managed with its own RestClient. | ||
|
||
This example is based on a standard usage of LangChain4j with Helidon. There is no such deep integration. | ||
|
||
I've added 3 technical classes to manage "the glue" (more or less the equivalent of `@RegisterAiService`): | ||
|
||
* ModelFactory: generates an OpenAI Chat model | ||
* ChatAiServiceFactory: generates a Chat assistant | ||
* FraudAiServiceFactory: generates a Fraud assistant. | ||
|
||
I've been obliged to turn FraudResponse in a POJO. It seems that Google GSON, used to deserialize OpenAI responses does not support Java Record. | ||
|
||
In contrast with Quarkus, network interactions with LLMs are based on standard LangChain4j. For instance, the Azure SDK is used with Azure OpenAI. | ||
|
||
## Packaging the application | ||
|
||
To package the application in JVM mode run: `mvn package`. | ||
|
||
## Configuration | ||
|
||
All configuration is centralized in `microprofile-config.properties`(found is `resources\META-INF` folder) and can be redefined using environment variables. | ||
|
||
## Running the application | ||
|
||
To run in dev mode with OpenLiberty: Run the following command in the CLI: `mvn liberty:dev`. | ||
|
||
To run in JVM mode (after packaging): `mvn liberty:start`. To stop the running server: `mvn liberty:stop`. | ||
|
||
|
||
## Playing with the application | ||
|
||
The application exposes a REST API documented with OpenAPI. | ||
|
||
To interact with the application go to: [http://localhost:9080/openapi/ui](http://localhost:8080/openapi/ui). | ||
|
||
|
||
Typical questions you can ask in the Chat: | ||
|
||
* Hello, how can you help me? | ||
* What is your list of cars? | ||
* What is your cancellation policy? | ||
* What is your fleet size? Be short please. | ||
* How many electric cars do you have? | ||
* My name is James Bond, please list my bookings | ||
* Is my booking 123-456 cancelable? | ||
* Is my booking 234-567 cancelable? | ||
* Can you check the duration please? | ||
* I'm James Bond, can I cancel all my booking 345-678? | ||
* Can you provide the details of all my bookings? | ||
|
||
You can ask fraud for: | ||
|
||
* James Bond | ||
* Emilio Largo |
22 changes: 22 additions & 0 deletions
22
examples/liberty-car-booking/docs-for-rag/apple-pie-recipe.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,22 @@ | ||
Special Apple Pie Recipe | ||
|
||
Here's a very brief overview of what you can expect when you make this special apple pie at home: | ||
|
||
1.Make the filling: | ||
On the stove, make a paste with flour and butter. | ||
Add the sugar and water and bring to a boil. | ||
Simmer, then remove from heat. | ||
|
||
2.Assemble the pie: | ||
Press one crust into a pie plate. | ||
Place the sliced apples on the bottom crust. | ||
Use the top crust to make a lattice crust according to the recipe below. | ||
Pour the butter-sugar mixture over the lattice crust. | ||
|
||
3.Bake the pie: | ||
Bake the pie in a preheated oven until the apples are soft and the crust is golden brown. | ||
|
||
4.How Long to Bake Apple Pie | ||
You'll bake the pie at 425 degrees F for 15 minutes, then you'll reduce the temperature to 350 degrees F and continue baking for 35-45 minutes. | ||
All in all, the pie will bake for about one hour, give or take a few minutes. | ||
You'll know the pie is done when the apples are soft and the crust is a beautiful golden brown color. |
6 changes: 6 additions & 0 deletions
6
examples/liberty-car-booking/docs-for-rag/general-information.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
Miles of Smiles general information and main figures | ||
|
||
1) Population: 500 employees | ||
2) Geography: 40 countries accross Europe, America and Asia | ||
3) Fleet: 1000 cars, 10% electric | ||
4) Satisfaction rating: 99% |
11 changes: 11 additions & 0 deletions
11
examples/liberty-car-booking/docs-for-rag/list-of-cars.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
Miles of Smiles Car Rental list of cars | ||
|
||
Aston Martin | ||
BMW | ||
DS | ||
Mercedes | ||
Renault | ||
Peugeot | ||
Porsche | ||
Tesla | ||
Toyota |
37 changes: 37 additions & 0 deletions
37
examples/liberty-car-booking/docs-for-rag/terms-of-use.txt
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,37 @@ | ||
Miles of Smiles Car Rental Services Terms of Use | ||
|
||
1. Introduction | ||
These Terms of Service (“Terms”) govern the access or use by you, an individual, from within any country in the world, of applications, websites, content, products, and services (“Services”) made available by Miles of Smiles Car Rental Services, a company registered in the United States of America. | ||
|
||
2. The Services | ||
Miles of Smiles rents out vehicles to the end user. We reserve the right to temporarily or permanently discontinue the Services at any time and are not liable for any modification, suspension or discontinuation of the Services. | ||
|
||
3. Bookings | ||
3.1 Users may make a booking through our website or mobile application. | ||
3.2 You must provide accurate, current and complete information during the reservation process. You are responsible for all charges incurred under your account. | ||
3.3 All bookings are subject to vehicle availability. | ||
|
||
4. Cancellation Policy | ||
4.1 Reservations lasting less than three days cannot be cancelled | ||
4.2 Reservations can be cancelled up to 7 days prior to the start of the booking period. | ||
|
||
5. Use of Vehicle | ||
5.1 All cars rented from Miles of Smiles must not be used: | ||
for any illegal purpose or in connection with any criminal offense. | ||
for teaching someone to drive. | ||
in any race, rally or contest. | ||
while under the influence of alcohol or drugs. | ||
|
||
6. Liability | ||
6.1 Users will be held liable for any damage, loss, or theft that occurs during the rental period. | ||
6.2 We do not accept liability for any indirect or consequential loss, damage, or expense including but not limited to loss of profits. | ||
|
||
7. Governing Law | ||
These terms will be governed by and construed in accordance with the laws of the United States of America, and any disputes relating to these terms will be subject to the exclusive jurisdiction of the courts of United States. | ||
|
||
8. Changes to These Terms | ||
We may revise these terms of use at any time by amending this page. You are expected to check this page from time to time to take notice of any changes we made. | ||
|
||
9. Acceptance of These Terms | ||
By using the Services, you acknowledge that you have read and understand these Terms and agree to be bound by them. | ||
If you do not agree to these Terms, please do not use or access our Services. |
Oops, something went wrong.