-
Notifications
You must be signed in to change notification settings - Fork 24
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #75 from cequence-io/feature/special-character-par…
…sing correctly parse byte arrays
- Loading branch information
Showing
2 changed files
with
63 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
33 changes: 33 additions & 0 deletions
33
...a/io/cequence/openaiscala/examples/CreateChatCompletionWithLogprobsWithSpecialChars.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,33 @@ | ||
package io.cequence.openaiscala.examples | ||
|
||
import io.cequence.openaiscala.domain._ | ||
import io.cequence.openaiscala.domain.settings.CreateChatCompletionSettings | ||
|
||
import scala.concurrent.Future | ||
|
||
object CreateChatCompletionWithLogprobsWithSpecialChars extends Example { | ||
|
||
val messages = Seq(UserMessage("Just return the string °C and nothing else")) | ||
|
||
override protected def run: Future[_] = | ||
service | ||
.createChatCompletion( | ||
messages = messages, | ||
settings = CreateChatCompletionSettings( | ||
model = ModelId.gpt_4o, | ||
temperature = Some(0), | ||
max_tokens = Some(100), | ||
logprobs = Some(true), | ||
top_logprobs = Some(3) | ||
) | ||
) | ||
.map { response => | ||
printMessageContent(response) | ||
val logprobs = response.choices.head.logprobs.map(_.content).getOrElse(Nil) | ||
logprobs.foreach { logprob => | ||
println( | ||
s"Logprob: ${logprob.token} -> ${logprob.logprob}, top: ${logprob.top_logprobs.map(_.token).mkString(", ")}" | ||
) | ||
} | ||
} | ||
} |