File tree Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Expand file tree Collapse file tree 1 file changed +35
-1
lines changed Original file line number Diff line number Diff line change @@ -8,4 +8,38 @@ The motivation of this `ChatModel` implementation is to use Spring AI with Sprin
8
8
Supported features:
9
9
10
10
- Chat completions
11
- - Function calling
11
+ - Function calling
12
+
13
+ ## Use ChatModel
14
+
15
+ Add Maven dependency.
16
+
17
+ ``` xml
18
+
19
+ <dependency >
20
+ <groupId >com.javaaidev</groupId >
21
+ <artifactId >openai-chatmodel-standalone</artifactId >
22
+ <version >0.2.0</version >
23
+ </dependency >
24
+ ```
25
+
26
+ To use this ` ChatModel ` ,
27
+
28
+ 1 . Create an ` OpenAIClient `
29
+ 2 . Create an ` OpenAIChatModel `
30
+ 3 . Create a Spring AI ` ChatClient.Builder ` with this ` ChatModel `
31
+ 4 . Create a Spring AI ` ChatClient ` from ` ChatClient.Builder `
32
+
33
+ See the code below:
34
+
35
+ ``` kotlin
36
+ val client = OpenAIOkHttpClient .fromEnv()
37
+ val chatModel = OpenAIChatModel (client)
38
+ val chatOptions = OpenAiChatOptions .builder()
39
+ .model(" gpt-3.5-turbo" )
40
+ .build()
41
+ val chatClient =
42
+ ChatClient .builder(chatModel).defaultOptions(chatOptions).build()
43
+ val response = chatClient.prompt().user(" tell me a joke" )
44
+ .call().content()
45
+ ```
You can’t perform that action at this time.
0 commit comments