@@ -38,6 +38,7 @@ import java.{util => ju}
38
38
import scala .collection .convert .ImplicitConversions .`iterable asJava`
39
39
import scala .collection .convert .ImplicitConversions .`map AsJavaMap`
40
40
import scala .collection .convert .ImplicitConversions .`list asScalaBuffer`
41
+ import io .cequence .openaiscala .domain .response .PromptTokensDetails
41
42
42
43
package object impl {
43
44
@@ -100,7 +101,7 @@ package object impl {
100
101
.addParts(0 , Part .newBuilder().setText(content).build())
101
102
.build()
102
103
103
- case _ => throw new OpenAIScalaClientException (" Unsupported message type" )
104
+ case x : BaseMessage => throw new OpenAIScalaClientException (s " Unsupported message type: ${x.getClass().getName()} " )
104
105
}
105
106
106
107
def toSystemVertexAI (
@@ -267,7 +268,7 @@ package object impl {
267
268
index = candidate.getIndex,
268
269
message = toOpenAIAssistantMessage(candidate.getContent),
269
270
finish_reason =
270
- Some (candidate.getFinishReason.getNumber + " : " + candidate.getFinishMessage ),
271
+ Some (candidate.getFinishReason.toString() ),
271
272
logprobs = None
272
273
)
273
274
},
@@ -288,13 +289,13 @@ package object impl {
288
289
OpenAIUsageInfo (
289
290
prompt_tokens = usageInfo.getPromptTokenCount,
290
291
total_tokens = usageInfo.getTotalTokenCount,
291
- completion_tokens = Some (usageInfo.getPromptTokenCount)
292
- // prompt_tokens_details = Some(
293
- // PromptTokensDetails(
294
- // cached_tokens = usageInfo.getCachedContentTokenCount.getOrElse(0), TODO: add once available
295
- // audio_tokens = 0
296
- // )
297
- // )
292
+ completion_tokens = Some (usageInfo.getCandidatesTokenCount),
293
+ // prompt_tokens_details = Some(
294
+ // PromptTokensDetails(
295
+ // cached_tokens = usageInfo.getCachedContentTokenCount.getOrElse(0),
296
+ // audio_tokens = None
297
+ // )
298
+ // )
298
299
)
299
300
}
300
301
}
0 commit comments