Skip to content

Commit 3fe08c6

Browse files
authored
Merge pull request #613 from quarkusio/langchain4j
Replace Semantic Kernel with Quarkus LangChain4j
2 parents e35a9b7 + f57a0a9 commit 3fe08c6

14 files changed

Lines changed: 141 additions & 404 deletions

File tree

quarkus-workshop-super-heroes/docs/pom.xml

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -48,7 +48,7 @@ The default build will take around 50m.
4848
<quarkus.platform.group-id>io.quarkus</quarkus.platform.group-id>
4949
<quarkus.platform.version>3.33.1</quarkus.platform.version>
5050
<quarkus.pact.version>1.6.0</quarkus.pact.version>
51-
<semantic-kernel.version>0.2.11-alpha</semantic-kernel.version>
51+
<quarkus-langchain4j.version>1.9.2</quarkus-langchain4j.version>
5252
<compiler-plugin.version>3.15.0</compiler-plugin.version>
5353
<surefire-plugin.version>3.5.4</surefire-plugin.version>
5454
<exec-plugin.version>3.6.3</exec-plugin.version>
@@ -81,9 +81,9 @@ The default build will take around 50m.
8181
<type>pom</type>
8282
</dependency>
8383
<dependency>
84-
<groupId>com.microsoft.semantic-kernel</groupId>
85-
<artifactId>semantickernel-bom</artifactId>
86-
<version>${semantic-kernel.version}</version>
84+
<groupId>io.quarkiverse.langchain4j</groupId>
85+
<artifactId>quarkus-langchain4j-bom</artifactId>
86+
<version>${quarkus-langchain4j.version}</version>
8787
<type>pom</type>
8888
</dependency>
8989
<dependency>
@@ -158,7 +158,7 @@ The default build will take around 50m.
158158
<compiler-plugin-version>${compiler-plugin.version}</compiler-plugin-version>
159159
<surefire-plugin-version>${surefire-plugin.version}</surefire-plugin-version>
160160
<quarkus-pact-version>${quarkus.pact.version}</quarkus-pact-version>
161-
<semantic-kernel-version>${semantic-kernel.version}</semantic-kernel-version>
161+
<quarkus-langchain4j-version>${quarkus-langchain4j.version}</quarkus-langchain4j-version>
162162
</attributes>
163163
</configuration>
164164
</plugin>

quarkus-workshop-super-heroes/docs/src/docs/asciidoc/core-conclusion/conclusion.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -27,7 +27,7 @@ endif::use-messaging[]
2727

2828
ifdef::use-ai[]
2929
We've also added some Artificial Intelligence.
30-
Thanks to Semantic Kernel, with a few lines of code, we allowed our Narration microservice to narrate the fight between a Super Hero and a Super Villain.
30+
Thanks to Quarkus LangChain4j, with a few lines of code, we allowed our Narration microservice to narrate the fight between a Super Hero and a Super Villain.
3131
endif::use-ai[]
3232

3333
ifdef::use-observability[]
Lines changed: 5 additions & 71 deletions
Original file line numberDiff line numberDiff line change
@@ -1,85 +1,19 @@
11
[[introduction-installing-ai]]
22

3-
= OpenAI or Azure OpenAI Subscriptions
4-
5-
The Narration microservice needs to access an AI service to generate the text narrating the fight.
6-
You can choose between OpenAI or Azure OpenAI.
7-
Azure OpenAI, or "OpenAI on Azure" is a service that provides REST API access to OpenAI's models, including the GPT-4, GPT-3, Codex and Embeddings series.
8-
The difference between OpenAI and Azure OpenAI is that it runs on Azure global infrastructure, which meets your production needs for critical enterprise security, compliance, and regional availability.
9-
10-
== OpenAI
3+
= OpenAI
114

125
https://openai.com/[OpenAI] is a leading artificial intelligence research organization creating cutting-edge AI technologies.
136
OpenAI offers a range of APIs that enable developers to integrate AI capabilities into their applications.
14-
Some of these APIs include:
157

16-
* GPT API: This API provides access to the GPT-3 and 4 language model
17-
* Codex API: This API provides access to the Codex model, which is a language model trained on a dataset of public code
18-
* DALL-E API: This API provides access to the DALL-E model, which is a language model trained on a dataset of text-image pairs
19-
20-
We will be using the GPT-3 API to generate the text narrating the fight.
8+
We will be using the GPT API to generate the text narrating the fight.
219

2210
First, you need to have an OpenAI subscription and then generate an API key.
23-
Then you need to ge the organisation id and key to invoke the API.
24-
To get the organisation id, go to https://platform.openai.com/account/org-settings[OpenAI organisation settings] and copy the organisation id.:
25-
26-
image::openai-org.png[role=half-size]
27-
28-
Then, to get the API key, go to https://platform.openai.com/account/api-keys[OpenAI API keys] and copy the API key:
11+
To get the API key, go to https://platform.openai.com/api-keys[OpenAI API keys] and create a new API key:
2912

3013
image::openai-key.png[role=half-size]
3114

32-
You will have to https://platform.openai.com/account/billing/overview[credit your OpenAI account] with some money to be able to use the API.
15+
You will have to https://platform.openai.com/settings/organization/billing/overview[credit your OpenAI account] with some money to be able to use the API.
3316

3417
image::openai-fund.png[role=half-size]
3518

36-
== Azure OpenAI
37-
38-
If you already have an Azure subscription, you can use it to create an https://azure.microsoft.com/products/ai-services/openai-service[Azure OpenAI] resource.
39-
Otherwise, you can create a https://azure.microsoft.com/free[free Azure subscription] and use it to create an Azure OpenAI resource.
40-
Then, you need to use the Azure OpenAI service to generate the API key and endpoint URL.
41-
You can either do that using the https://portal.azure.com/[Azure Portal] or the https://learn.microsoft.com/cli/azure/[Azure CLI].
42-
43-
The easiest being use the Azure CLI, we recommend that you https://learn.microsoft.com/cli/azure/install-azure-cli[install it] and use it to create the Azure OpenAI resource and generate the API key and endpoint URL.
44-
Once Azure CLI is installed and you have your Azure subscription, sign in to your Azure account:
45-
46-
[source,shell]
47-
----
48-
az login
49-
----
50-
51-
[NOTE]
52-
====
53-
If you have several Azure subscription, make sure you are using the right one.
54-
For that, you can execute the following command to list all your subscriptions and set the one you want to use:
55-
56-
[source,shell]
57-
----
58-
az account list --output table
59-
az account set --subscription <subscription-id>
60-
az account show
61-
----
62-
====
63-
64-
Then, execute the following command to create the Azure OpenAI resources:
65-
66-
[source,bash]
67-
----
68-
include::{projectdir}/infrastructure/ai-azure-openai-create.sh[tags=adocSetup;!adocSkip]
69-
----
70-
71-
This script will create the Azure OpenAI resource and deploy the model.
72-
Once the script has executed, you can use the following command to get the API key and endpoint URL.
73-
You will need these properties later one when you will configure the Narration microservice:
74-
75-
[source,bash]
76-
----
77-
include::{projectdir}/infrastructure/ai-azure-openai-create.sh[tag=adocProperties]
78-
----
79-
80-
Once you've finished the workshop, remember to delete the Azure OpenAI resources to avoid being charged for it:
81-
82-
[source,bash]
83-
----
84-
include::{projectdir}/infrastructure/ai-azure-openai-delete.sh[tag=adocDelete]
85-
----
19+
Keep your API key handy — you will need it when configuring the Narration microservice.

quarkus-workshop-super-heroes/docs/src/docs/asciidoc/core-introduction/introduction-presentation.adoc

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -25,7 +25,7 @@ The Super Hero UI is exposed via Quarkus and invokes the Fight REST API
2525
* _Villain REST API_: A classical HTTP microservice exposing CRUD operations on Villains, stored in a PostgreSQL database
2626
* _Hero REST API_: A reactive HTTP microservice exposing CRUD operations on Heroes, stored in a Postgres database
2727
ifdef::use-ai[]
28-
* _Narration REST API_: This microservice talks to OpenAI/Azure OpenAI to generate a random narration of the fight.
28+
* _Narration REST API_: This microservice talks to OpenAI to generate a random narration of the fight using Quarkus LangChain4j.
2929
endif::use-ai[]
3030
* _Fight REST API_: This REST API invokes the Hero and Villain APIs to get a random superhero and supervillain.
3131
ifdef::use-ai[]
@@ -94,7 +94,7 @@ in this section, you will install all the tools and code to be able to develop,
9494
in this section, you will develop a microservice architecture by creating several Maven projects, write some Java code, add JPA entities, JAX-RS REST endpoints, write some tests, use a React web application, and all that on Quarkus
9595
ifdef::use-ai[]
9696
* _Artificial Intelligence_:
97-
in this section, you will use OpenAI or Azure OpenAI to invoke an AI so you can generate a random narration of the fight
97+
in this section, you will use Quarkus LangChain4j with OpenAI to generate a random narration of the fight
9898
endif::use-ai[]
9999
ifdef::use-messaging[]
100100
* _Event-driven and Reactive microservices_:
@@ -166,7 +166,7 @@ endif::use-native[]
166166
* Docker or Podman
167167
* cURL (should already be installed in your OS, if not, check xref:appendix-installing-curl[the appendix for installation instructions]) and `jq`
168168
ifdef::use-ai[]
169-
* OpenAI or Azure OpenAI keys
169+
* An OpenAI API key
170170
endif::use-ai[]
171171
ifdef::use-azure[]
172172
* An Azure subscription and the Azure CLI

quarkus-workshop-super-heroes/docs/src/docs/asciidoc/core-introduction/introduction.adoc

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -56,7 +56,7 @@ What you are going to learn:
5656
* How to build a reactive microservice, including reactive data access
5757
* How you improve the resilience of your service
5858
ifdef::use-ai[]
59-
* How to invoke OpenAI/Azure OpenAI APIs using Semantic Kernel
59+
* How to invoke OpenAI using Quarkus LangChain4j
6060
endif::use-ai[]
6161
ifdef::use-messaging[]
6262
* How to build event-driven microservices with Kafka

0 commit comments

Comments
 (0)