@react-frameui/loki-ai 1.0.1 → 1.0.2
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/core/agentRunner.js +7 -3
- package/package.json +1 -1
package/dist/core/agentRunner.js
CHANGED
|
@@ -111,14 +111,18 @@ Assistant:`;
|
|
|
111
111
|
// Initial pass (Non-streaming to catch JSON better, or standard)
|
|
112
112
|
// We use generated promise wrapper to allow abort
|
|
113
113
|
let initialResponse = await provider.generate(fullPrompt, undefined, options.signal);
|
|
114
|
-
// Check for
|
|
115
|
-
|
|
114
|
+
// Check for empty response
|
|
115
|
+
if (!initialResponse || initialResponse.trim() === '') {
|
|
116
|
+
throw new Error('LLM returned an empty response. Check if the model is loaded correctly.');
|
|
117
|
+
}
|
|
118
|
+
// Check for JSON tool call (support both markdown block and raw JSON)
|
|
119
|
+
const toolRegex = /(?:```json\s*)?(\{.*"tool":.*\})(?:\s*```)?/s;
|
|
116
120
|
const match = initialResponse.match(toolRegex);
|
|
117
121
|
if (match) {
|
|
118
122
|
try {
|
|
119
123
|
const toolCall = JSON.parse(match[1]);
|
|
120
124
|
if (options.onToken)
|
|
121
|
-
options.onToken(
|
|
125
|
+
options.onToken(`\u001b[33m[Executing ${toolCall.tool}...]\u001b[0m\n`);
|
|
122
126
|
const toolResult = await (0, toolRegistry_1.executeToolCall)(toolCall.tool, toolCall.args);
|
|
123
127
|
fullPrompt += `\n${initialResponse}\n\nTool Output: ${toolResult}\n\nAssistant (Interpreting result):`;
|
|
124
128
|
// Final Response
|
package/package.json
CHANGED