aboutsummaryrefslogtreecommitdiff
path: root/modules/core/ollama-manager.js
diff options
context:
space:
mode:
authorAgando <roduccomm@gmail.com>2026-05-30 06:00:47 +0200
committerAgando <roduccomm@gmail.com>2026-05-30 06:00:47 +0200
commite3fb2d434c4f7317944b7c77781599528d766a39 (patch)
tree8f9f9c94b19d46f42f8086adb6b68ee07dfce5c6 /modules/core/ollama-manager.js
parentd570f86177c514ae888fb63fc0bb0da7dd4d5097 (diff)
auto: 2026-05-30_06:00 changes
Diffstat (limited to 'modules/core/ollama-manager.js')
-rw-r--r--modules/core/ollama-manager.js22
1 files changed, 22 insertions, 0 deletions
diff --git a/modules/core/ollama-manager.js b/modules/core/ollama-manager.js
index 34ece29..420cbc3 100644
--- a/modules/core/ollama-manager.js
+++ b/modules/core/ollama-manager.js
@@ -927,6 +927,28 @@ class OllamaManager {
this.saveSettings();
}
+ async validateToolResult(toolName, args, result, aiAnswer) {
+ if (!this.validatorEnabled || !this.validatorModel) return true;
+ const endpoint = this.validatorEndpoint || this.endpoint;
+ const prompt = 'Tool called: ' + toolName + '(' + JSON.stringify(args) + ')\n' +
+ 'Tool returned: ' + ((result || '').substring(0, 500)) + '\n' +
+ 'AI answered: ' + ((aiAnswer || '').substring(0, 500)) + '\n' +
+ 'QUESTION: Is the AI answer consistent with the tool result?\nAnswer only YES or NO.';
+ try {
+ const res = await fetch(endpoint + '/api/chat', {
+ method: 'POST',
+ headers: { 'Content-Type': 'application/json' },
+ body: JSON.stringify({ model: this.validatorModel, messages: [{ role: 'user', content: prompt }], stream: false })
+ });
+ const data = await res.json();
+ const answer = (data.message?.content || '').trim().toUpperCase();
+ return answer === 'YES';
+ } catch (e) {
+ if (this.terminal) this.terminal.print('⚠️ Validator error: ' + e.message, 'warning');
+ return true;
+ }
+ }
+
getModels() { return this.models; }
addResponseHook(fn) { this.responseHooks.push(fn); }