graphlit-client 1.0.20250613006 → 1.0.20250613008
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.
@@ -11,6 +11,27 @@ function isValidJSON(str) {
|
|
11
11
|
return false;
|
12
12
|
}
|
13
13
|
}
|
14
|
+
/**
|
15
|
+
* Clean schema for Google Gemini by removing unsupported fields
|
16
|
+
*/
|
17
|
+
function cleanSchemaForGoogle(schema) {
|
18
|
+
if (typeof schema !== "object" || schema === null) {
|
19
|
+
return schema;
|
20
|
+
}
|
21
|
+
if (Array.isArray(schema)) {
|
22
|
+
return schema.map((item) => cleanSchemaForGoogle(item));
|
23
|
+
}
|
24
|
+
const cleaned = {};
|
25
|
+
for (const [key, value] of Object.entries(schema)) {
|
26
|
+
// Skip fields that Google doesn't support
|
27
|
+
if (key === "$schema" || key === "additionalProperties") {
|
28
|
+
continue;
|
29
|
+
}
|
30
|
+
// Recursively clean nested objects
|
31
|
+
cleaned[key] = cleanSchemaForGoogle(value);
|
32
|
+
}
|
33
|
+
return cleaned;
|
34
|
+
}
|
14
35
|
/**
|
15
36
|
* Stream with OpenAI SDK
|
16
37
|
*/
|
@@ -665,11 +686,21 @@ onEvent, onComplete) {
|
|
665
686
|
const googleTools = tools && tools.length > 0
|
666
687
|
? [
|
667
688
|
{
|
668
|
-
functionDeclarations: tools.map((tool) =>
|
669
|
-
|
670
|
-
|
671
|
-
|
672
|
-
|
689
|
+
functionDeclarations: tools.map((tool) => {
|
690
|
+
const rawSchema = tool.schema ? JSON.parse(tool.schema) : {};
|
691
|
+
const cleanedSchema = cleanSchemaForGoogle(rawSchema);
|
692
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
693
|
+
const hadCleanup = JSON.stringify(rawSchema) !== JSON.stringify(cleanedSchema);
|
694
|
+
if (hadCleanup) {
|
695
|
+
console.log(`[Google] Cleaned schema for tool ${tool.name} - removed unsupported fields`);
|
696
|
+
}
|
697
|
+
}
|
698
|
+
return {
|
699
|
+
name: tool.name,
|
700
|
+
description: tool.description,
|
701
|
+
parameters: cleanedSchema,
|
702
|
+
};
|
703
|
+
}),
|
673
704
|
},
|
674
705
|
]
|
675
706
|
: undefined;
|
@@ -451,6 +451,13 @@ export class UIEventAdapter {
|
|
451
451
|
const avgDelay = this.tokenDelays.reduce((a, b) => a + b, 0) / this.tokenDelays.length;
|
452
452
|
metrics.avgTokenDelay = Math.round(avgDelay);
|
453
453
|
}
|
454
|
+
// Calculate streaming throughput (excludes TTFT)
|
455
|
+
if (this.firstTokenTime > 0 && this.streamStartTime > 0) {
|
456
|
+
const streamingTime = now - this.firstTokenTime;
|
457
|
+
if (streamingTime > 0) {
|
458
|
+
metrics.streamingThroughput = Math.round((this.currentMessage.length / streamingTime) * 1000);
|
459
|
+
}
|
460
|
+
}
|
454
461
|
this.emitUIEvent({
|
455
462
|
type: "message_update",
|
456
463
|
message,
|
@@ -23,6 +23,7 @@ export type AgentStreamEvent = {
|
|
23
23
|
conversationDuration: number;
|
24
24
|
tokenCount?: number;
|
25
25
|
avgTokenDelay?: number;
|
26
|
+
streamingThroughput?: number;
|
26
27
|
};
|
27
28
|
} | {
|
28
29
|
type: "tool_update";
|
@@ -40,6 +41,7 @@ export type AgentStreamEvent = {
|
|
40
41
|
tokenCount?: number;
|
41
42
|
llmTokens?: number;
|
42
43
|
avgTokenDelay?: number;
|
44
|
+
streamingThroughput?: number;
|
43
45
|
};
|
44
46
|
} | {
|
45
47
|
type: "error";
|