From e3fb2d434c4f7317944b7c77781599528d766a39 Mon Sep 17 00:00:00 2001 From: Agando Date: Sat, 30 May 2026 06:00:47 +0200 Subject: auto: 2026-05-30_06:00 changes --- modules/core/ollama-manager.js | 22 ++++++++++++++++++++++ 1 file changed, 22 insertions(+) (limited to 'modules/core/ollama-manager.js') 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); } -- cgit v1.2.3