@fractal-solutions/qflow 1.0.33 → 1.0.35
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/agent/agent.js +11 -12
- package/dist/nodes/user.js +3 -1
- package/package.json +1 -1
package/dist/agent/agent.js
CHANGED
|
@@ -254,15 +254,17 @@ Parameters: ${params}`;
|
|
|
254
254
|
}
|
|
255
255
|
}
|
|
256
256
|
parseLLMResponse(llmResponse) {
|
|
257
|
-
let parsed;
|
|
258
257
|
if (typeof llmResponse === 'string') {
|
|
259
|
-
|
|
260
|
-
|
|
261
|
-
const
|
|
258
|
+
let jsonString = llmResponse;
|
|
259
|
+
// Find the first '{' and the last '}' to isolate the JSON object
|
|
260
|
+
const firstBrace = jsonString.indexOf('{');
|
|
261
|
+
const lastBrace = jsonString.lastIndexOf('}');
|
|
262
|
+
if (firstBrace !== -1 && lastBrace > firstBrace) {
|
|
263
|
+
jsonString = jsonString.substring(firstBrace, lastBrace + 1);
|
|
264
|
+
}
|
|
262
265
|
try {
|
|
263
|
-
parsed = JSON.parse(jsonString);
|
|
266
|
+
const parsed = JSON.parse(jsonString);
|
|
264
267
|
if (parsed.thought && Array.isArray(parsed.tool_calls)) {
|
|
265
|
-
// This is a valid, complete tool call plan.
|
|
266
268
|
return {
|
|
267
269
|
thought: parsed.thought,
|
|
268
270
|
toolCalls: parsed.tool_calls,
|
|
@@ -271,12 +273,9 @@ Parameters: ${params}`;
|
|
|
271
273
|
}
|
|
272
274
|
}
|
|
273
275
|
catch (e) {
|
|
274
|
-
//
|
|
275
|
-
// We will fall through and treat the original response as a thought.
|
|
276
|
+
// Parsing failed, fall through to treat the original string as a thought.
|
|
276
277
|
}
|
|
277
|
-
//
|
|
278
|
-
// or it was valid JSON but didn't have the required 'thought' and 'tool_calls' keys.
|
|
279
|
-
// In either case, we treat the entire original response as a thought with no tool calls.
|
|
278
|
+
// Fallback for plain text responses or malformed JSON.
|
|
280
279
|
return { thought: llmResponse, toolCalls: [], parallel: false };
|
|
281
280
|
}
|
|
282
281
|
// This part of the function handles the case where llmResponse is an OBJECT,
|
|
@@ -294,7 +293,7 @@ Parameters: ${params}`;
|
|
|
294
293
|
}
|
|
295
294
|
else if (typeof message.content === 'string' && message.content.trim().startsWith('{')) {
|
|
296
295
|
try {
|
|
297
|
-
parsed = JSON.parse(message.content);
|
|
296
|
+
const parsed = JSON.parse(message.content);
|
|
298
297
|
if (parsed.thought && Array.isArray(parsed.tool_calls)) {
|
|
299
298
|
return {
|
|
300
299
|
thought: parsed.thought,
|
package/dist/nodes/user.js
CHANGED
|
@@ -17,7 +17,9 @@ export class UserInputNode extends AsyncNode {
|
|
|
17
17
|
output: process.stdout
|
|
18
18
|
});
|
|
19
19
|
return new Promise((resolve) => {
|
|
20
|
-
|
|
20
|
+
// ANSI escape codes for yellow text
|
|
21
|
+
const yellowPrompt = `\x1b[33m${prompt}\x1b[0m`;
|
|
22
|
+
rl.question(yellowPrompt, (answer) => {
|
|
21
23
|
rl.close();
|
|
22
24
|
resolve(answer);
|
|
23
25
|
});
|
package/package.json
CHANGED