@zenmux/rosetta-ai 1.0.16 → 1.0.17
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
|
@@ -151,6 +151,8 @@ class MessagesToChatCompletionConverter {
|
|
|
151
151
|
const outputTokens = u.completion_tokens ?? 0;
|
|
152
152
|
const totalTokens = u.total_tokens ?? inputTokens + outputTokens;
|
|
153
153
|
const cachedTokens = u.prompt_tokens_details?.cached_tokens ?? 0;
|
|
154
|
+
const cacheWriteTokens = u.prompt_tokens_details?.cache_write_tokens ?? 0;
|
|
155
|
+
const uncachedInputTokens = Math.max(0, inputTokens - cachedTokens - cacheWriteTokens);
|
|
154
156
|
const reasoningTokens = u.completion_tokens_details?.reasoning_tokens ?? 0;
|
|
155
157
|
const webSearch = u.prompt_tokens_details?.web_search ?? 0;
|
|
156
158
|
return {
|
|
@@ -166,7 +168,7 @@ class MessagesToChatCompletionConverter {
|
|
|
166
168
|
cached_tokens: cachedTokens,
|
|
167
169
|
...(webSearch > 0 ? { web_search: webSearch } : {}),
|
|
168
170
|
},
|
|
169
|
-
input_tokens:
|
|
171
|
+
input_tokens: uncachedInputTokens,
|
|
170
172
|
output_tokens: outputTokens,
|
|
171
173
|
cache_read_input_tokens: cachedTokens,
|
|
172
174
|
server_tool_use: webSearch > 0
|
|
@@ -175,7 +177,7 @@ class MessagesToChatCompletionConverter {
|
|
|
175
177
|
web_search_requests: webSearch,
|
|
176
178
|
}
|
|
177
179
|
: null,
|
|
178
|
-
cache_creation_input_tokens:
|
|
180
|
+
cache_creation_input_tokens: cacheWriteTokens,
|
|
179
181
|
service_tier: "standard",
|
|
180
182
|
audio_input_tokens: u.prompt_tokens_details?.audio_tokens ?? 0,
|
|
181
183
|
audio_cache_read_tokens: u.prompt_tokens_details?.audio_cached_tokens ?? 0,
|
package/dist/messages/gemini.js
CHANGED
|
@@ -164,6 +164,7 @@ class MessagesToGeminiConverter {
|
|
|
164
164
|
}
|
|
165
165
|
const promptTokens = promptTokenCount + toolUsePromptTokenCount;
|
|
166
166
|
const completionTokens = candidatesTokenCount + thoughtsTokenCount;
|
|
167
|
+
const uncachedInputTokens = Math.max(0, promptTokens - cachedContentTokenCount);
|
|
167
168
|
return {
|
|
168
169
|
prompt_tokens: promptTokens,
|
|
169
170
|
completion_tokens: completionTokens,
|
|
@@ -180,7 +181,7 @@ class MessagesToGeminiConverter {
|
|
|
180
181
|
web_search_queries: webSearchQueriesCount,
|
|
181
182
|
tool_use: toolUsePromptTokenCount,
|
|
182
183
|
trafficType,
|
|
183
|
-
input_tokens:
|
|
184
|
+
input_tokens: uncachedInputTokens,
|
|
184
185
|
output_tokens: completionTokens,
|
|
185
186
|
cache_read_input_tokens: cachedContentTokenCount,
|
|
186
187
|
cache_creation_input_tokens: 0,
|
|
@@ -140,6 +140,8 @@ class MessagesToResponsesConverter {
|
|
|
140
140
|
const outputTokens = u.output_tokens ?? 0;
|
|
141
141
|
const totalTokens = u.total_tokens ?? inputTokens + outputTokens;
|
|
142
142
|
const cachedTokens = u.input_tokens_details?.cached_tokens ?? 0;
|
|
143
|
+
const cacheWriteTokens = u.input_tokens_details?.cache_write_tokens ?? 0;
|
|
144
|
+
const uncachedInputTokens = Math.max(0, inputTokens - cachedTokens - cacheWriteTokens);
|
|
143
145
|
const reasoningTokens = u.output_tokens_details?.reasoning_tokens ?? 0;
|
|
144
146
|
return {
|
|
145
147
|
completion_tokens: outputTokens,
|
|
@@ -154,7 +156,7 @@ class MessagesToResponsesConverter {
|
|
|
154
156
|
cached_tokens: cachedTokens,
|
|
155
157
|
...(webSearchCount > 0 ? { web_search: webSearchCount } : {}),
|
|
156
158
|
},
|
|
157
|
-
input_tokens:
|
|
159
|
+
input_tokens: uncachedInputTokens,
|
|
158
160
|
output_tokens: outputTokens,
|
|
159
161
|
cache_read_input_tokens: cachedTokens,
|
|
160
162
|
server_tool_use: webSearchCount > 0
|
|
@@ -163,7 +165,7 @@ class MessagesToResponsesConverter {
|
|
|
163
165
|
web_search_requests: webSearchCount,
|
|
164
166
|
}
|
|
165
167
|
: null,
|
|
166
|
-
cache_creation_input_tokens:
|
|
168
|
+
cache_creation_input_tokens: cacheWriteTokens,
|
|
167
169
|
service_tier: "standard",
|
|
168
170
|
audio_input_tokens: 0,
|
|
169
171
|
audio_cache_read_tokens: 0,
|
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@zenmux/rosetta-ai",
|
|
3
|
-
"version": "1.0.
|
|
3
|
+
"version": "1.0.17",
|
|
4
4
|
"description": "Universal translator between AI provider protocols",
|
|
5
5
|
"main": "dist/index.js",
|
|
6
6
|
"types": "dist/index.d.ts",
|
|
@@ -60,4 +60,4 @@
|
|
|
60
60
|
"typescript": "^6.0.2",
|
|
61
61
|
"typescript-eslint": "^8.58.2"
|
|
62
62
|
}
|
|
63
|
-
}
|
|
63
|
+
}
|