@kenkaiiii/gg-ai 4.3.179 → 4.3.181
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.
- package/dist/index.cjs +14 -2
- package/dist/index.cjs.map +1 -1
- package/dist/index.js +14 -2
- package/dist/index.js.map +1 -1
- package/package.json +1 -1
package/dist/index.cjs
CHANGED
|
@@ -1300,6 +1300,9 @@ async function* runStream2(options) {
|
|
|
1300
1300
|
if (!cacheRead && typeof usageAny.cached_tokens === "number" && usageAny.cached_tokens > 0) {
|
|
1301
1301
|
cacheRead = usageAny.cached_tokens;
|
|
1302
1302
|
}
|
|
1303
|
+
if (!cacheRead && typeof usageAny.prompt_cache_hit_tokens === "number" && usageAny.prompt_cache_hit_tokens > 0) {
|
|
1304
|
+
cacheRead = usageAny.prompt_cache_hit_tokens;
|
|
1305
|
+
}
|
|
1303
1306
|
inputTokens = chunk.usage.prompt_tokens - cacheRead;
|
|
1304
1307
|
}
|
|
1305
1308
|
if (!choice) continue;
|
|
@@ -1465,6 +1468,9 @@ function completionToResponse(completion) {
|
|
|
1465
1468
|
if (!cacheRead && typeof usageAny.cached_tokens === "number" && usageAny.cached_tokens > 0) {
|
|
1466
1469
|
cacheRead = usageAny.cached_tokens;
|
|
1467
1470
|
}
|
|
1471
|
+
if (!cacheRead && typeof usageAny.prompt_cache_hit_tokens === "number" && usageAny.prompt_cache_hit_tokens > 0) {
|
|
1472
|
+
cacheRead = usageAny.prompt_cache_hit_tokens;
|
|
1473
|
+
}
|
|
1468
1474
|
inputTokens = completion.usage.prompt_tokens - cacheRead;
|
|
1469
1475
|
}
|
|
1470
1476
|
const stopReason = normalizeOpenAIStopReason(choice?.finish_reason ?? null);
|
|
@@ -1536,8 +1542,9 @@ async function* runStream3(options) {
|
|
|
1536
1542
|
if (options.tools?.length) {
|
|
1537
1543
|
body.tools = toCodexTools(options.tools);
|
|
1538
1544
|
}
|
|
1539
|
-
|
|
1540
|
-
|
|
1545
|
+
body.prompt_cache_key = options.promptCacheKey ?? "ggcoder";
|
|
1546
|
+
if (options.cacheRetention === "long") {
|
|
1547
|
+
body.prompt_cache_retention = "24h";
|
|
1541
1548
|
}
|
|
1542
1549
|
if (options.temperature != null && !options.thinking) {
|
|
1543
1550
|
body.temperature = options.temperature;
|
|
@@ -1559,6 +1566,11 @@ async function* runStream3(options) {
|
|
|
1559
1566
|
if (options.accountId) {
|
|
1560
1567
|
headers["chatgpt-account-id"] = options.accountId;
|
|
1561
1568
|
}
|
|
1569
|
+
const cacheScopeId = body.prompt_cache_key;
|
|
1570
|
+
if (cacheScopeId) {
|
|
1571
|
+
headers["session_id"] = cacheScopeId;
|
|
1572
|
+
headers["x-client-request-id"] = cacheScopeId;
|
|
1573
|
+
}
|
|
1562
1574
|
const response = await fetch(url, {
|
|
1563
1575
|
method: "POST",
|
|
1564
1576
|
headers,
|