Skip to content

Adding create chat completion sample code to readme #4

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 1 commit into from
Apr 17, 2023
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -170,6 +170,25 @@ Examples:
```
(For this to work you need to use `OpenAIServiceStreamedFactory` from `openai-scala-client-stream` lib)

- Create chat completion

```scala
val createChatCompletionSettings = CreateChatCompletionSettings(
model = ModelId.gpt_3_5_turbo_0301
)

val messages: Seq[MessageSpec] = Seq(
MessageSpec(role = ChatRole.System, content = "You are a helpful assistant."),
MessageSpec(role = ChatRole.User, content = "Who won the world series in 2020?"),
MessageSpec(role = ChatRole.Assistant, content = "The Los Angeles Dodgers won the World Series in 2020."),
MessageSpec(role = ChatRole.User, content = "Where was it played"),
)

service.createChatCompletion(messages = messages, settings = createChatCompletionSettings).map { chatCompletion =>
println(chatCompletion.choices.head.message.content)
}
```

## FAQ 🤔

1. _Wen Scala 3?_
Expand Down