You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
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:
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
+
```
180
180
181
181
> [!IMPORTANT]
182
182
> 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 {
189
189
190
190
## Output
191
191
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.
0 commit comments