n8n-nodes-coding-stream 0.1.2 → 0.1.5
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.
|
@@ -47,9 +47,12 @@ class CodingStreamChatModel {
|
|
|
47
47
|
displayName: 'Options', name: 'options', type: 'collection', placeholder: 'Add Option', default: {},
|
|
48
48
|
options: [
|
|
49
49
|
{ displayName: 'Temperature', name: 'temperature', type: 'number', typeOptions: { minValue: 0, maxValue: 2 }, default: 0.3 },
|
|
50
|
-
{ displayName: 'Max Tokens', name: 'maxTokens', type: 'number', typeOptions: { minValue: 1 }, default:
|
|
50
|
+
{ displayName: 'Max Tokens', name: 'maxTokens', type: 'number', typeOptions: { minValue: 1 }, default: undefined },
|
|
51
51
|
{ displayName: 'Top P', name: 'topP', type: 'number', typeOptions: { minValue: 0, maxValue: 1 }, default: 0.6 },
|
|
52
52
|
{ displayName: 'Timeout (ms)', name: 'timeout', type: 'number', typeOptions: { minValue: 1000 }, default: 120000 },
|
|
53
|
+
{ displayName: 'Reasoning Effort', name: 'reasoningEffort', type: 'string', default: 'low' },
|
|
54
|
+
{ displayName: 'Streaming', name: 'streaming', type: 'boolean', default: true },
|
|
55
|
+
{ displayName: 'Extra Body (JSON)', name: 'extraBody', type: 'json', default: '{}' },
|
|
53
56
|
],
|
|
54
57
|
},
|
|
55
58
|
],
|
|
@@ -71,6 +74,29 @@ class CodingStreamChatModel {
|
|
|
71
74
|
if (!requestBy) {
|
|
72
75
|
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'X-Request-By cannot be empty.');
|
|
73
76
|
}
|
|
77
|
+
const extraBodyRaw = options.extraBody ?? '{}';
|
|
78
|
+
let extraBody;
|
|
79
|
+
try {
|
|
80
|
+
const parsed = typeof extraBodyRaw === 'string'
|
|
81
|
+
? JSON.parse(extraBodyRaw)
|
|
82
|
+
: extraBodyRaw;
|
|
83
|
+
if (!parsed || typeof parsed !== 'object' || Array.isArray(parsed)) {
|
|
84
|
+
throw new Error('Expected a JSON object');
|
|
85
|
+
}
|
|
86
|
+
extraBody = parsed;
|
|
87
|
+
}
|
|
88
|
+
catch {
|
|
89
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Extra Body must be a valid JSON object');
|
|
90
|
+
}
|
|
91
|
+
const reserved = ['model', 'messages', 'tools', 'tool_choice', 'stream'];
|
|
92
|
+
const conflicting = reserved.filter(key => key in extraBody);
|
|
93
|
+
if (conflicting.length) {
|
|
94
|
+
throw new n8n_workflow_1.NodeOperationError(this.getNode(), 'Extra Body cannot override: ' + conflicting.join(', '));
|
|
95
|
+
}
|
|
96
|
+
const modelKwargs = { ...extraBody };
|
|
97
|
+
if (options.reasoningEffort?.trim()) {
|
|
98
|
+
modelKwargs.reasoning_effort = options.reasoningEffort.trim();
|
|
99
|
+
}
|
|
74
100
|
// OpenAI SDK itself creates Authorization: Bearer <apiKey> for every request.
|
|
75
101
|
// No manual SSE parsing and no workflow-to-workflow proxying.
|
|
76
102
|
const model = new openai_1.ChatOpenAI({
|
|
@@ -81,8 +107,10 @@ class CodingStreamChatModel {
|
|
|
81
107
|
defaultHeaders: { 'X-Request-By': requestBy },
|
|
82
108
|
},
|
|
83
109
|
temperature: options.temperature ?? 0.3,
|
|
84
|
-
maxTokens: options.maxTokens
|
|
110
|
+
...(options.maxTokens != null ? { maxTokens: Number(options.maxTokens) } : {}),
|
|
85
111
|
topP: options.topP ?? 0.6,
|
|
112
|
+
streaming: options.streaming ?? true,
|
|
113
|
+
modelKwargs,
|
|
86
114
|
timeout: options.timeout ?? 120000,
|
|
87
115
|
maxRetries: 0,
|
|
88
116
|
supportsStrictToolCalling: false,
|