Skip to content

Commit a03e125

Browse files
committed
Correcting indentation on code fences to 3 spaces
1 parent e46e549 commit a03e125

File tree

1 file changed

+132
-132
lines changed
  • articles/ai-services/openai/includes

1 file changed

+132
-132
lines changed

articles/ai-services/openai/includes/spring.md

Lines changed: 132 additions & 132 deletions
Original file line numberDiff line numberDiff line change
@@ -42,28 +42,28 @@ spring init -a ai-completion-demo -n AICompletion --force --build maven -x
4242

4343
The generated files and folders resemble the following structure:
4444

45-
```
46-
ai-completion-demo/
47-
|-- pom.xml
48-
|-- mvn
49-
|-- mvn.cmd
50-
|-- HELP.md
51-
|-- src/
52-
|-- main/
53-
| |-- resources/
54-
| | |-- application.properties
55-
| |-- java/
56-
| |-- com/
57-
| |-- example/
58-
| |-- aicompletiondemo/
59-
| |-- AiCompletionApplication.java
60-
|-- test/
61-
|-- java/
62-
|-- com/
63-
|-- example/
64-
|-- aicompletiondemo/
65-
|-- AiCompletionApplicationTests.java
66-
```
45+
```
46+
ai-completion-demo/
47+
|-- pom.xml
48+
|-- mvn
49+
|-- mvn.cmd
50+
|-- HELP.md
51+
|-- src/
52+
|-- main/
53+
| |-- resources/
54+
| | |-- application.properties
55+
| |-- java/
56+
| |-- com/
57+
| |-- example/
58+
| |-- aicompletiondemo/
59+
| |-- AiCompletionApplication.java
60+
|-- test/
61+
|-- java/
62+
|-- com/
63+
|-- example/
64+
|-- aicompletiondemo/
65+
|-- AiCompletionApplicationTests.java
66+
```
6767

6868
## Edit the Spring application
6969

@@ -72,111 +72,111 @@ ai-completion-demo/
7272
From the root of the project directory, open the *pom.xml* file in your preferred editor or IDE and overwrite the file with following content:
7373

7474
```xml
75-
<?xml version="1.0" encoding="UTF-8"?>
76-
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77-
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
78-
<modelVersion>4.0.0</modelVersion>
79-
<parent>
80-
<groupId>org.springframework.boot</groupId>
81-
<artifactId>spring-boot-starter-parent</artifactId>
82-
<version>3.3.4</version>
83-
<relativePath/> <!-- lookup parent from repository -->
84-
</parent>
85-
<groupId>com.example</groupId>
86-
<artifactId>ai-completion-demo</artifactId>
87-
<version>0.0.1-SNAPSHOT</version>
88-
<name>AICompletion</name>
89-
<description>Demo project for Spring Boot</description>
90-
<properties>
91-
<java.version>17</java.version>
92-
<spring-ai.version>1.0.0-M5</spring-ai.version>
93-
</properties>
94-
<dependencies>
95-
<dependency>
75+
<?xml version="1.0" encoding="UTF-8"?>
76+
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
77+
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 https://maven.apache.org/xsd/maven-4.0.0.xsd">
78+
<modelVersion>4.0.0</modelVersion>
79+
<parent>
9680
<groupId>org.springframework.boot</groupId>
97-
<artifactId>spring-boot-starter</artifactId>
98-
</dependency>
99-
<dependency>
100-
<groupId>org.springframework.ai</groupId>
101-
<artifactId>spring-ai-azure-openai-spring-boot-starter</artifactId>
102-
</dependency>
103-
<dependency>
104-
<groupId>org.springframework.boot</groupId>
105-
<artifactId>spring-boot-starter-test</artifactId>
106-
<scope>test</scope>
107-
</dependency>
108-
</dependencies>
109-
110-
<dependencyManagement>
81+
<artifactId>spring-boot-starter-parent</artifactId>
82+
<version>3.3.4</version>
83+
<relativePath/> <!-- lookup parent from repository -->
84+
</parent>
85+
<groupId>com.example</groupId>
86+
<artifactId>ai-completion-demo</artifactId>
87+
<version>0.0.1-SNAPSHOT</version>
88+
<name>AICompletion</name>
89+
<description>Demo project for Spring Boot</description>
90+
<properties>
91+
<java.version>17</java.version>
92+
<spring-ai.version>1.0.0-M5</spring-ai.version>
93+
</properties>
11194
<dependencies>
95+
<dependency>
96+
<groupId>org.springframework.boot</groupId>
97+
<artifactId>spring-boot-starter</artifactId>
98+
</dependency>
11299
<dependency>
113100
<groupId>org.springframework.ai</groupId>
114-
<artifactId>spring-ai-bom</artifactId>
115-
<version>${spring-ai.version}</version>
116-
<type>pom</type>
117-
<scope>import</scope>
101+
<artifactId>spring-ai-azure-openai-spring-boot-starter</artifactId>
102+
</dependency>
103+
<dependency>
104+
<groupId>org.springframework.boot</groupId>
105+
<artifactId>spring-boot-starter-test</artifactId>
106+
<scope>test</scope>
118107
</dependency>
119108
</dependencies>
120-
</dependencyManagement>
121109

122-
<build>
123-
<plugins>
124-
<plugin>
125-
<groupId>org.springframework.boot</groupId>
126-
<artifactId>spring-boot-maven-plugin</artifactId>
127-
</plugin>
128-
</plugins>
129-
</build>
130-
<repositories>
131-
<repository>
132-
<id>spring-milestones</id>
133-
<name>Spring Milestones</name>
134-
<url>https://repo.spring.io/milestone</url>
135-
<snapshots>
136-
<enabled>false</enabled>
137-
</snapshots>
138-
</repository>
139-
</repositories>
140-
</project>
110+
<dependencyManagement>
111+
<dependencies>
112+
<dependency>
113+
<groupId>org.springframework.ai</groupId>
114+
<artifactId>spring-ai-bom</artifactId>
115+
<version>${spring-ai.version}</version>
116+
<type>pom</type>
117+
<scope>import</scope>
118+
</dependency>
119+
</dependencies>
120+
</dependencyManagement>
121+
122+
<build>
123+
<plugins>
124+
<plugin>
125+
<groupId>org.springframework.boot</groupId>
126+
<artifactId>spring-boot-maven-plugin</artifactId>
127+
</plugin>
128+
</plugins>
129+
</build>
130+
<repositories>
131+
<repository>
132+
<id>spring-milestones</id>
133+
<name>Spring Milestones</name>
134+
<url>https://repo.spring.io/milestone</url>
135+
<snapshots>
136+
<enabled>false</enabled>
137+
</snapshots>
138+
</repository>
139+
</repositories>
140+
</project>
141141
```
142142

143143
1. From the *src/main/java/com/example/aicompletiondemo* folder, open *AiCompletionApplication.java* in your preferred editor or IDE and paste in the following code:
144144

145-
```java
146-
package com.example.aicompletiondemo;
147-
148-
import org.slf4j.Logger;
149-
import org.slf4j.LoggerFactory;
150-
import org.springframework.ai.chat.client.ChatClient;
151-
import org.springframework.boot.CommandLineRunner;
152-
import org.springframework.boot.SpringApplication;
153-
import org.springframework.boot.autoconfigure.SpringBootApplication;
154-
import org.springframework.context.annotation.Bean;
155-
156-
@SpringBootApplication
157-
public class AiCompletionApplication {
158-
159-
private static final Logger log = LoggerFactory.getLogger(AiCompletionApplication.class);
160-
161-
public static void main(String[] args) {
162-
SpringApplication.run(AiCompletionApplication.class, args);
163-
}
164-
165-
@Bean
166-
CommandLineRunner commandLineRunner(ChatClient.Builder builder) {
167-
return args -> {
168-
var chatClient = builder.build();
169-
log.info("Sending completion prompt to AI service. One moment please...");
170-
var response = chatClient.prompt()
171-
.user("When was Microsoft founded?")
172-
.call()
173-
.content();
174-
175-
log.info("Response: {}", response);
176-
};
177-
}
178-
}
179-
```
145+
```java
146+
package com.example.aicompletiondemo;
147+
148+
import org.slf4j.Logger;
149+
import org.slf4j.LoggerFactory;
150+
import org.springframework.ai.chat.client.ChatClient;
151+
import org.springframework.boot.CommandLineRunner;
152+
import org.springframework.boot.SpringApplication;
153+
import org.springframework.boot.autoconfigure.SpringBootApplication;
154+
import org.springframework.context.annotation.Bean;
155+
156+
@SpringBootApplication
157+
public class AiCompletionApplication {
158+
159+
private static final Logger log = LoggerFactory.getLogger(AiCompletionApplication.class);
160+
161+
public static void main(String[] args) {
162+
SpringApplication.run(AiCompletionApplication.class, args);
163+
}
164+
165+
@Bean
166+
CommandLineRunner commandLineRunner(ChatClient.Builder builder) {
167+
return args -> {
168+
var chatClient = builder.build();
169+
log.info("Sending completion prompt to AI service. One moment please...");
170+
var response = chatClient.prompt()
171+
.user("When was Microsoft founded?")
172+
.call()
173+
.content();
174+
175+
log.info("Response: {}", response);
176+
};
177+
}
178+
}
179+
```
180180

181181
> [!IMPORTANT]
182182
> For production, use a secure way of storing and accessing your credentials like [Azure Key Vault](/azure/key-vault/general/overview). For more information about credential security, see the Azure AI services [security](../../security-features.md) article.
@@ -189,22 +189,22 @@ public class AiCompletionApplication {
189189

190190
## Output
191191

192-
```output
193-
. ____ _ __ _ _
194-
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
195-
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
196-
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
197-
' |____| .__|_| |_|_| |_\__, | / / / /
198-
=========|_|==============|___/=/_/_/_/
199-
200-
:: Spring Boot :: (v3.3.4)
201-
202-
2025-01-09T13:51:48.426-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : Starting AiCompletionApplication using Java 17.0.12 with PID 8264 (/Users/vega/dev/msft/spring-ai-samples/ai-completion-demo/target/classes started by vega in /Users/vega/dev/msft/spring-ai-samples/ai-completion-demo)
203-
2025-01-09T13:51:48.427-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : No active profile set, falling back to 1 default profile: "default"
204-
2025-01-09T13:51:48.781-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : Started AiCompletionApplication in 0.465 seconds (process running for 0.624)
205-
2025-01-09T13:51:48.782-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : Sending completion prompt to AI service. One moment please...
206-
2025-01-09T13:51:50.447-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : Response: Microsoft was founded on April 4, 1975, by Bill Gates and Paul Allen.
207-
```
192+
```output
193+
. ____ _ __ _ _
194+
/\\ / ___'_ __ _ _(_)_ __ __ _ \ \ \ \
195+
( ( )\___ | '_ | '_| | '_ \/ _` | \ \ \ \
196+
\\/ ___)| |_)| | | | | || (_| | ) ) ) )
197+
' |____| .__|_| |_|_| |_\__, | / / / /
198+
=========|_|==============|___/=/_/_/_/
199+
200+
:: Spring Boot :: (v3.3.4)
201+
202+
2025-01-09T13:51:48.426-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : Starting AiCompletionApplication using Java 17.0.12 with PID 8264 (/Users/vega/dev/msft/spring-ai-samples/ai-completion-demo/target/classes started by vega in /Users/vega/dev/msft/spring-ai-samples/ai-completion-demo)
203+
2025-01-09T13:51:48.427-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : No active profile set, falling back to 1 default profile: "default"
204+
2025-01-09T13:51:48.781-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : Started AiCompletionApplication in 0.465 seconds (process running for 0.624)
205+
2025-01-09T13:51:48.782-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : Sending completion prompt to AI service. One moment please...
206+
2025-01-09T13:51:50.447-05:00 INFO 8264 --- [AICompletion] [ main] c.e.a.AiCompletionApplication : Response: Microsoft was founded on April 4, 1975, by Bill Gates and Paul Allen.
207+
```
208208

209209

210210
## Clean up resources

0 commit comments

Comments
 (0)