Workshop material for Spring AI
The workshop uses the Spring CLI project. If you are not using GitHub codespaces, download the Spring CLI. You can browse the Spring CLI Documentation to learn more about its features.
A quick summary is that the Spring CLI provides a command line application named spring
You will create the code for Exercise #1, the "Hello World" AI project, using the command spring boot new
. See below.
The code for additional exercises will use the command spring boot add
To access the projects used in these exercises, we first need to add the ai-azure-catalog
.
You will also need to have the curl
like tool httpie installed.
Now, let's get started!
spring project-catalog add azure-ai https://github.com/rd-1-2022/ai-azure-catalog
Create a new project using the following command. You can pick a different
- name: The following example uses the name
myai
as the project name - package name: The following example uses the name
com.xkcd.ai
in honor of XKCD.
spring boot new myai ai-azure-hello-world --package-name com.xkcd.ai
You will now have a project with the structure shown below
cd myai
$ tree
.
├── mvnw
├── mvnw.cmd
├── pom.xml
├── README.md
└── src
└── main
├── java
│ └── com
│ └── xkcd
│ └── ai
│ ├── Application.java
│ └── helloworld
│ ├── Completion.java
│ └── SimpleAiController.java
└── resources
└── application.properties
Follow the instuctions in README.md
to complete the exercise.
** MAKE SURE YOU ARE IN THE ROOT OF THE JAVA PROJECT **
Now add the code for Prompt Templating
spring boot add ai-azure-prompt-templating
Look at the README-ai-azure-prompt-templating.md
file for instructions.
Your directory tree should look like:
$ tree
.
├── mvnw
├── mvnw.cmd
├── pom.xml
├── README-ai-azure-prompt-templating.md
├── README.md
└── src
└── main
├── java
│ └── com
│ └── xkcd
│ └── ai
│ ├── Application.java
│ ├── helloworld
│ │ ├── Completion.java
│ │ └── SimpleAiController.java
│ └── prompttemplate
│ └── PromptTemplateController.java
└── resources
├── application.properties
└── prompts
└── joke-prompt.st
Now add the code for the Prompt Roles exercise.
spring boot add ai-azure-prompt-roles
Look at the README-ai-azure-prompt-roles.md
file for instructions.
Now add the code for Output Parser exercise.
spring boot add ai-azure-output-parser
Look at the README-ai-azure-output-parser.md
file for instructions.
Now add the code for Chains exercise.
spring boot add ai-azure-chains
Look at the README-ai-azure-chains.md
file for instructions.
Now add the code for the Stuff the Prompt exercise.
spring boot add ai-azure-stuff-prompt
Look at the README-ai-azure-chains.md
file for instructions.
Now add the code for the Retrieval Augmented Generation exercise.
spring boot add ai-azure-rag
Look at the README-ai-azure-retrieval-augmented-generation.md
file for instructions.