@cartanova/qgrid-ai-sdk 2.2.0 → 2.3.1
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.d.ts +1 -1
- package/dist/index.js +19 -26
- package/package.json +1 -1
package/dist/index.d.ts
CHANGED
|
@@ -75,4 +75,4 @@ declare function createQgridLogger(config?: QgridLoggerConfig): TelemetrySetting
|
|
|
75
75
|
//#region src/index.d.ts
|
|
76
76
|
declare function qgrid(modelId: QgridSupportedModel, config?: QgridProviderConfig): LanguageModelV3;
|
|
77
77
|
//#endregion
|
|
78
|
-
export { type QgridLoggerConfig, type QgridProviderOptions, createQgridLogger, qgrid as default, qgrid };
|
|
78
|
+
export { type QgridLoggerConfig, type QgridProviderOptions, type QgridSupportedModel, createQgridLogger, qgrid as default, qgrid };
|
package/dist/index.js
CHANGED
|
@@ -478,6 +478,23 @@ function setThreadCoord(sessionKey, coord) {
|
|
|
478
478
|
expiresAt: Date.now() + THREAD_COORD_TTL_MS
|
|
479
479
|
});
|
|
480
480
|
}
|
|
481
|
+
function toAiSdkUsage(usage) {
|
|
482
|
+
const cacheRead = usage.cache_read_input_tokens;
|
|
483
|
+
const cacheWrite = usage.cache_creation_input_tokens;
|
|
484
|
+
return {
|
|
485
|
+
inputTokens: {
|
|
486
|
+
total: usage.input_tokens,
|
|
487
|
+
noCache: Math.max(usage.input_tokens - cacheRead - cacheWrite, 0),
|
|
488
|
+
cacheRead,
|
|
489
|
+
cacheWrite
|
|
490
|
+
},
|
|
491
|
+
outputTokens: {
|
|
492
|
+
total: usage.output_tokens,
|
|
493
|
+
text: usage.output_tokens,
|
|
494
|
+
reasoning: void 0
|
|
495
|
+
}
|
|
496
|
+
};
|
|
497
|
+
}
|
|
481
498
|
function qgrid(modelId, config) {
|
|
482
499
|
const serverUrl = config?.serverUrl ?? process.env.QGRID_URL ?? DEFAULT_SERVER_URL;
|
|
483
500
|
const effort = config?.defaultEffort ?? DEFAULT_EFFORT;
|
|
@@ -579,19 +596,7 @@ function qgrid(modelId, config) {
|
|
|
579
596
|
return {
|
|
580
597
|
content,
|
|
581
598
|
finishReason,
|
|
582
|
-
usage:
|
|
583
|
-
inputTokens: {
|
|
584
|
-
total: data.usage.input_tokens,
|
|
585
|
-
noCache: data.usage.input_tokens - data.usage.cache_read_input_tokens,
|
|
586
|
-
cacheRead: data.usage.cache_read_input_tokens,
|
|
587
|
-
cacheWrite: data.usage.cache_creation_input_tokens
|
|
588
|
-
},
|
|
589
|
-
outputTokens: {
|
|
590
|
-
total: data.usage.output_tokens,
|
|
591
|
-
text: data.usage.output_tokens,
|
|
592
|
-
reasoning: void 0
|
|
593
|
-
}
|
|
594
|
-
},
|
|
599
|
+
usage: toAiSdkUsage(data.usage),
|
|
595
600
|
warnings: [],
|
|
596
601
|
providerMetadata: { qgrid: {
|
|
597
602
|
model: data.model,
|
|
@@ -748,19 +753,7 @@ function qgrid(modelId, config) {
|
|
|
748
753
|
unified: "stop",
|
|
749
754
|
raw: "stop"
|
|
750
755
|
},
|
|
751
|
-
usage:
|
|
752
|
-
inputTokens: {
|
|
753
|
-
total: done.usage.input_tokens,
|
|
754
|
-
noCache: done.usage.input_tokens - done.usage.cache_read_input_tokens,
|
|
755
|
-
cacheRead: done.usage.cache_read_input_tokens,
|
|
756
|
-
cacheWrite: done.usage.cache_creation_input_tokens
|
|
757
|
-
},
|
|
758
|
-
outputTokens: {
|
|
759
|
-
total: done.usage.output_tokens,
|
|
760
|
-
text: done.usage.output_tokens,
|
|
761
|
-
reasoning: void 0
|
|
762
|
-
}
|
|
763
|
-
}
|
|
756
|
+
usage: toAiSdkUsage(done.usage)
|
|
764
757
|
});
|
|
765
758
|
streamCompleted = true;
|
|
766
759
|
controller.close();
|