Skip to content

Commit fec11a5

Browse files
authored
GPU docs for 1.3.0 and simple chatbot module for Cloudbank (#935)
* add simple chatbot module to cloudbank --------- Signed-off-by: Mark Nelson <mark.x.nelson@oracle.com>
1 parent 7acb5ef commit fec11a5

File tree

11 files changed

+683
-6
lines changed

11 files changed

+683
-6
lines changed

cloudbank-v4/chatbot/pom.xml

Lines changed: 75 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,75 @@
1+
<?xml version="1.0" encoding="UTF-8"?>
2+
<!-- Copyright (c) 2024, Oracle and/or its affiliates. -->
3+
<!-- Licensed under the Universal Permissive License v 1.0 as shown at
4+
https://oss.oracle.com/licenses/upl/ -->
5+
<project xmlns="http://maven.apache.org/POM/4.0.0"
6+
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
7+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
8+
<modelVersion>4.0.0</modelVersion>
9+
10+
<parent>
11+
<groupId>org.springframework.boot</groupId>
12+
<artifactId>spring-boot-starter-parent</artifactId>
13+
<version>3.3.3</version>
14+
<relativePath/> <!-- lookup parent from repository -->
15+
</parent>
16+
17+
<groupId>com.example</groupId>
18+
<artifactId>chatbot</artifactId>
19+
<version>0.0.1-SNAPSHOT</version>
20+
<name>chatbot</name>
21+
<description>A Simple ChatBot Application</description>
22+
23+
<dependencies>
24+
<dependency>
25+
<groupId>org.springframework.ai</groupId>
26+
<artifactId>spring-ai-ollama-spring-boot-starter</artifactId>
27+
</dependency>
28+
<dependency>
29+
<groupId>org.springframework.boot</groupId>
30+
<artifactId>spring-boot-starter-web</artifactId>
31+
<version>3.3.3</version>
32+
</dependency>
33+
</dependencies>
34+
35+
<repositories>
36+
<repository>
37+
<id>spring-milestones</id>
38+
<name>Spring Milestones</name>
39+
<url>https://repo.spring.io/milestone</url>
40+
<snapshots>
41+
<enabled>false</enabled>
42+
</snapshots>
43+
</repository>
44+
<repository>
45+
<id>spring-snapshots</id>
46+
<name>Spring Snapshots</name>
47+
<url>https://repo.spring.io/snapshot</url>
48+
<releases>
49+
<enabled>false</enabled>
50+
</releases>
51+
</repository>
52+
</repositories>
53+
54+
<dependencyManagement>
55+
<dependencies>
56+
<dependency>
57+
<groupId>org.springframework.ai</groupId>
58+
<artifactId>spring-ai-bom</artifactId>
59+
<version>1.0.0-SNAPSHOT</version>
60+
<type>pom</type>
61+
<scope>import</scope>
62+
</dependency>
63+
</dependencies>
64+
</dependencyManagement>
65+
66+
<build>
67+
<plugins>
68+
<plugin>
69+
<groupId>org.springframework.boot</groupId>
70+
<artifactId>spring-boot-maven-plugin</artifactId>
71+
</plugin>
72+
</plugins>
73+
</build>
74+
75+
</project>
Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
// Copyright (c) 2024, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.chatbot;
5+
6+
import org.springframework.boot.SpringApplication;
7+
import org.springframework.boot.autoconfigure.SpringBootApplication;
8+
9+
@SpringBootApplication
10+
public class ChatbotApplication {
11+
12+
public static void main(String[] args) {
13+
SpringApplication.run(ChatbotApplication.class, args);
14+
}
15+
16+
}
Lines changed: 41 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,41 @@
1+
// Copyright (c) 2024, Oracle and/or its affiliates.
2+
// Licensed under the Universal Permissive License v 1.0 as shown at https://oss.oracle.com/licenses/upl/
3+
4+
package com.example.chatbot.controller;
5+
6+
import org.springframework.web.bind.annotation.RequestMapping;
7+
import org.springframework.web.bind.annotation.RestController;
8+
import org.springframework.ai.chat.model.ChatModel;
9+
import org.springframework.ai.chat.model.ChatResponse;
10+
import org.springframework.ai.chat.prompt.Prompt;
11+
import org.springframework.ai.ollama.api.OllamaModel;
12+
import org.springframework.ai.ollama.api.OllamaOptions;
13+
import org.springframework.web.bind.annotation.PostMapping;
14+
import org.springframework.web.bind.annotation.RequestBody;
15+
16+
@RestController
17+
@RequestMapping("/chat")
18+
public class ChatController {
19+
20+
final ChatModel chatModel;
21+
22+
public ChatController(ChatModel chatModel) {
23+
this.chatModel = chatModel;
24+
}
25+
26+
@PostMapping
27+
public String chat(@RequestBody String question) {
28+
29+
ChatResponse response = chatModel.call(
30+
new Prompt(question,
31+
OllamaOptions.builder()
32+
.withModel(OllamaModel.LLAMA3)
33+
.withTemperature(0.4f)
34+
.build()
35+
));
36+
37+
return response.getResult().getOutput().getContent();
38+
39+
}
40+
41+
}
Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
spring:
2+
application:
3+
name: chatbot
4+
ai:
5+
ollama:
6+
base-url: http://ollama.ollama.svc.cluster.local:11434
7+
chat:
8+
enabled: true
9+
options:
10+
model: llama3

docs-source/cloudbank/content/_index.md

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
11
+++
22
archetype = "home"
3-
title = "CloudBank"
3+
title = "CloudBank AI"
44
+++
55

6-
Welcome to CloudBank - an on-demand, self-paced learning resource you can use
6+
Welcome to CloudBank AI - an on-demand, self-paced learning resource you can use
77
to learn about developing microservices with [Spring Boot](https://spring.io/projects/spring-boot)
88
and deploying, running and managing them with [Oracle Backend for Spring Boot and Microservices](https://bit.ly/oraclespringboot).
99

@@ -57,8 +57,6 @@ CloudBank contains the following modules:
5757
This modules introduces [Spring AI](https://github.com/spring-projects/spring-ai)
5858
and explores how it can be used to build a CloudBank AI Assistant (chatbot) that will
5959
allow users to interact with CloudBank using a chat-based interface.
60-
In this module, you will learn about Retrieval Augmented Generation, Vector
61-
Database and AI Agents.
6260
* **Module 7: Deploying the full CloudBank Application using the CLI**
6361
In this module, you will learn how to deploy the full CloudBank application
6462
to Oracle Backend for Spring Boot and Microservices using the CLI.

docs-source/cloudbank/content/springai/_index.md

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,4 +4,6 @@ title = "CloudBank AI Assistant"
44
weight = 6
55
+++
66

7-
This modules introduces [Spring AI](https://github.com/spring-projects/spring-ai) and explores how it can be used to build a CloudBank AI Assistant (chatbot) that will allow users to interact with CloudBank using a chat-based interface. In this module, you will learn about Retrieval Augmented Generation, Vector Database and AI Agents.
7+
This modules introduces [Spring AI](https://github.com/spring-projects/spring-ai) and explores how it can be used to build a CloudBank AI Assistant (chatbot) that will allow users to interact with CloudBank using a chat-based interface.
8+
9+
**Coming Soon:** We will be updating this module to help you learn about Retrieval Augmented Generation, Vector Database and AI Agents.

0 commit comments

Comments
 (0)