graphlit-client 1.0.20250924002 → 1.0.20250924004
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/client.js +12 -2
- package/dist/streaming/providers.d.ts +5 -2
- package/dist/streaming/providers.js +36 -8
- package/package.json +1 -1
package/dist/client.js
CHANGED
|
@@ -2892,7 +2892,12 @@ class Graphlit {
|
|
|
2892
2892
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
2893
2893
|
console.log(`🚀 [Graphlit SDK] Routing to OpenAI streaming provider | Spec: ${specification.name} (${specification.id}) | Messages: ${messages.length} | Tools: ${tools?.length || 0}`);
|
|
2894
2894
|
}
|
|
2895
|
-
|
|
2895
|
+
// Extract reasoning effort for OpenAI o1 models
|
|
2896
|
+
const reasoningEffort = specification.openAI?.reasoningEffort || undefined;
|
|
2897
|
+
if (reasoningEffort && process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
2898
|
+
console.log(`🧠 [Graphlit SDK] OpenAI reasoning effort: ${reasoningEffort}`);
|
|
2899
|
+
}
|
|
2900
|
+
await streamWithOpenAI(specification, messages, tools, openaiClient, (event) => uiAdapter.handleEvent(event), onComplete, abortSignal, reasoningEffort);
|
|
2896
2901
|
}
|
|
2897
2902
|
/**
|
|
2898
2903
|
* Stream with Anthropic client
|
|
@@ -2967,7 +2972,12 @@ class Graphlit {
|
|
|
2967
2972
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
2968
2973
|
console.log(`🚀 [Graphlit SDK] Routing to Google streaming provider | Spec: ${specification.name} (${specification.id}) | Messages: ${messages.length} | Tools: ${tools?.length || 0} | SystemPrompt: ${systemPrompt ? "Yes" : "No"}`);
|
|
2969
2974
|
}
|
|
2970
|
-
|
|
2975
|
+
// Get thinking configuration from specification
|
|
2976
|
+
const thinkingConfig = this.getThinkingConfig(specification);
|
|
2977
|
+
if (thinkingConfig && process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
2978
|
+
console.log(`🧠 [Graphlit SDK] Google thinking enabled | Budget: ${thinkingConfig.budget_tokens} tokens`);
|
|
2979
|
+
}
|
|
2980
|
+
await streamWithGoogle(specification, messages, systemPrompt, tools, googleClient, (event) => uiAdapter.handleEvent(event), onComplete, abortSignal, thinkingConfig);
|
|
2971
2981
|
}
|
|
2972
2982
|
/**
|
|
2973
2983
|
* Stream with Groq client (OpenAI-compatible)
|
|
@@ -5,7 +5,7 @@ import { StreamEvent } from "../types/internal.js";
|
|
|
5
5
|
* Stream with OpenAI SDK
|
|
6
6
|
*/
|
|
7
7
|
export declare function streamWithOpenAI(specification: Specification, messages: OpenAIMessage[], tools: ToolDefinitionInput[] | undefined, openaiClient: any, // OpenAI client instance
|
|
8
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[], usage?: any) => void, abortSignal?: AbortSignal): Promise<void>;
|
|
8
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[], usage?: any) => void, abortSignal?: AbortSignal, reasoningEffort?: string): Promise<void>;
|
|
9
9
|
/**
|
|
10
10
|
* Stream with Anthropic SDK
|
|
11
11
|
*/
|
|
@@ -19,7 +19,10 @@ onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls:
|
|
|
19
19
|
* Stream with Google SDK
|
|
20
20
|
*/
|
|
21
21
|
export declare function streamWithGoogle(specification: Specification, messages: GoogleMessage[], systemPrompt: string | undefined, tools: ToolDefinitionInput[] | undefined, googleClient: any, // Google GenerativeAI client instance
|
|
22
|
-
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[], usage?: any) => void, abortSignal?: AbortSignal
|
|
22
|
+
onEvent: (event: StreamEvent) => void, onComplete: (message: string, toolCalls: ConversationToolCall[], usage?: any) => void, abortSignal?: AbortSignal, thinkingConfig?: {
|
|
23
|
+
type: "enabled";
|
|
24
|
+
budget_tokens: number;
|
|
25
|
+
}): Promise<void>;
|
|
23
26
|
/**
|
|
24
27
|
* Stream with Groq SDK (OpenAI-compatible)
|
|
25
28
|
*/
|
|
@@ -76,7 +76,7 @@ function cleanSchemaForGoogle(schema) {
|
|
|
76
76
|
* Stream with OpenAI SDK
|
|
77
77
|
*/
|
|
78
78
|
export async function streamWithOpenAI(specification, messages, tools, openaiClient, // OpenAI client instance
|
|
79
|
-
onEvent, onComplete, abortSignal) {
|
|
79
|
+
onEvent, onComplete, abortSignal, reasoningEffort) {
|
|
80
80
|
let fullMessage = "";
|
|
81
81
|
let toolCalls = [];
|
|
82
82
|
let usageData = null;
|
|
@@ -105,7 +105,7 @@ onEvent, onComplete, abortSignal) {
|
|
|
105
105
|
throw new Error(`No model name found for specification: ${specification.name} (service: ${specification.serviceType})`);
|
|
106
106
|
}
|
|
107
107
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
108
|
-
console.log(`🤖 [OpenAI] Model Config: Service=OpenAI | Model=${modelName} | Temperature=${specification.openAI?.temperature} | MaxTokens=${specification.openAI?.completionTokenLimit || "null"} | Tools=${tools?.length || 0} | Spec="${specification.name}"`);
|
|
108
|
+
console.log(`🤖 [OpenAI] Model Config: Service=OpenAI | Model=${modelName} | Temperature=${specification.openAI?.temperature} | MaxTokens=${specification.openAI?.completionTokenLimit || "null"} | Tools=${tools?.length || 0} | ReasoningEffort=${reasoningEffort || "none"} | Spec="${specification.name}"`);
|
|
109
109
|
}
|
|
110
110
|
const streamConfig = {
|
|
111
111
|
model: modelName,
|
|
@@ -131,6 +131,14 @@ onEvent, onComplete, abortSignal) {
|
|
|
131
131
|
},
|
|
132
132
|
}));
|
|
133
133
|
}
|
|
134
|
+
// Add reasoning effort for o1 models
|
|
135
|
+
if (reasoningEffort) {
|
|
136
|
+
// OpenAI o1 models support reasoning_effort parameter
|
|
137
|
+
streamConfig.reasoning_effort = reasoningEffort.toLowerCase();
|
|
138
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
139
|
+
console.log(`🧠 [OpenAI] Reasoning effort set to: ${reasoningEffort}`);
|
|
140
|
+
}
|
|
141
|
+
}
|
|
134
142
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
135
143
|
console.log(`⏱️ [OpenAI] Starting LLM call at: ${new Date().toISOString()}`);
|
|
136
144
|
}
|
|
@@ -894,7 +902,7 @@ onEvent, onComplete, abortSignal, thinkingConfig) {
|
|
|
894
902
|
* Stream with Google SDK
|
|
895
903
|
*/
|
|
896
904
|
export async function streamWithGoogle(specification, messages, systemPrompt, tools, googleClient, // Google GenerativeAI client instance
|
|
897
|
-
onEvent, onComplete, abortSignal) {
|
|
905
|
+
onEvent, onComplete, abortSignal, thinkingConfig) {
|
|
898
906
|
let fullMessage = "";
|
|
899
907
|
let toolCalls = [];
|
|
900
908
|
let usageData = null;
|
|
@@ -923,7 +931,7 @@ onEvent, onComplete, abortSignal) {
|
|
|
923
931
|
throw new Error(`No model name found for Google specification: ${specification.name}`);
|
|
924
932
|
}
|
|
925
933
|
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
926
|
-
console.log(`🤖 [Google] Model Config: Service=Google | Model=${modelName} | Temperature=${specification.google?.temperature} | MaxTokens=${specification.google?.completionTokenLimit || "null"} | SystemPrompt=${systemPrompt ? "Yes" : "No"} | Tools=${tools?.length || 0} | Spec="${specification.name}"`);
|
|
934
|
+
console.log(`🤖 [Google] Model Config: Service=Google | Model=${modelName} | Temperature=${specification.google?.temperature} | MaxTokens=${specification.google?.completionTokenLimit || "null"} | SystemPrompt=${systemPrompt ? "Yes" : "No"} | Tools=${tools?.length || 0} | Thinking=${!!thinkingConfig} | Spec="${specification.name}"`);
|
|
927
935
|
}
|
|
928
936
|
const streamConfig = {
|
|
929
937
|
model: modelName,
|
|
@@ -969,12 +977,32 @@ onEvent, onComplete, abortSignal) {
|
|
|
969
977
|
},
|
|
970
978
|
]
|
|
971
979
|
: undefined;
|
|
980
|
+
// Add thinking configuration if provided
|
|
981
|
+
// Note: Google's thinking API is still in preview and may require specific model support
|
|
982
|
+
const generationConfig = {
|
|
983
|
+
temperature: streamConfig.temperature,
|
|
984
|
+
maxOutputTokens: streamConfig.max_tokens,
|
|
985
|
+
};
|
|
986
|
+
if (thinkingConfig) {
|
|
987
|
+
// Google Gemini 2.5 Flash+ supports thinking mode
|
|
988
|
+
generationConfig.thinkingConfig = {
|
|
989
|
+
thinkingBudget: thinkingConfig.budget_tokens,
|
|
990
|
+
includeThoughts: true, // Include thinking content in the response
|
|
991
|
+
};
|
|
992
|
+
if (process.env.DEBUG_GRAPHLIT_SDK_STREAMING) {
|
|
993
|
+
console.log(`🧠 [Google] Extended thinking enabled | Budget: ${thinkingConfig.budget_tokens} tokens | Include thoughts: true`);
|
|
994
|
+
}
|
|
995
|
+
}
|
|
996
|
+
else {
|
|
997
|
+
// Explicitly disable thinking when not configured
|
|
998
|
+
generationConfig.thinkingConfig = {
|
|
999
|
+
thinkingBudget: 0, // Disable thinking by setting budget to 0
|
|
1000
|
+
includeThoughts: false,
|
|
1001
|
+
};
|
|
1002
|
+
}
|
|
972
1003
|
const model = googleClient.getGenerativeModel({
|
|
973
1004
|
model: modelName,
|
|
974
|
-
generationConfig
|
|
975
|
-
temperature: streamConfig.temperature,
|
|
976
|
-
maxOutputTokens: streamConfig.max_tokens,
|
|
977
|
-
},
|
|
1005
|
+
generationConfig,
|
|
978
1006
|
tools: googleTools,
|
|
979
1007
|
});
|
|
980
1008
|
// Convert messages to Google chat format
|