Skip to content

Commit e55d60f

Browse files
committed
Update README.md
1 parent 92d6562 commit e55d60f

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

README.md

Lines changed: 35 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -8,4 +8,38 @@ The motivation of this `ChatModel` implementation is to use Spring AI with Sprin
88
Supported features:
99

1010
- 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+
```

0 commit comments

Comments
 (0)