File tree Expand file tree Collapse file tree 2 files changed +9
-1
lines changed
app/src/main/kotlin/dev/chungjungsoo/gptmobile/data Expand file tree Collapse file tree 2 files changed +9
-1
lines changed Original file line number Diff line number Diff line change @@ -9,6 +9,12 @@ data class Usage(
99 @SerialName(" input_tokens" )
1010 val inputTokens : Int ,
1111
12+ @SerialName(" cache_creation_input_tokens" )
13+ val cacheCreationInputTokens : Int? = null ,
14+
15+ @SerialName(" cache_read_input_tokens" )
16+ val cacheReadInputTokens : Int? = null ,
17+
1218 @SerialName(" output_tokens" )
1319 val outputTokens : Int
1420)
Original file line number Diff line number Diff line change @@ -71,12 +71,14 @@ class AnthropicAPIImpl @Inject constructor(
7171
7272 private suspend inline fun <reified T > FlowCollector<T>.streamEventsFrom (response : HttpResponse ) {
7373 val channel: ByteReadChannel = response.body()
74+ val jsonInstance = Json { ignoreUnknownKeys = true }
75+
7476 try {
7577 while (currentCoroutineContext().isActive && ! channel.isClosedForRead) {
7678 val line = channel.readUTF8Line() ? : continue
7779 val value: T = when {
7880 line.startsWith(STREAM_END_TOKEN ) -> break
79- line.startsWith(STREAM_PREFIX ) -> Json .decodeFromString(line.removePrefix(STREAM_PREFIX ))
81+ line.startsWith(STREAM_PREFIX ) -> jsonInstance .decodeFromString(line.removePrefix(STREAM_PREFIX ))
8082 else -> continue
8183 }
8284 emit(value)
You can’t perform that action at this time.
0 commit comments