cletus/bot/lib/ai-helper.js
roberts d2f34b3607
All checks were successful
Deploy Cletus Bot / deploy (push) Successful in 14s
Edited connection and creation in bot.js
2025-05-10 17:03:52 -05:00

23 lines
693 B
JavaScript

// lib/ai-helper.js
const axios = require('axios');
const config = require('../config.json');
async function chatWithAI(message, overrides = {}) {
const settings = { ...config.ai, ...overrides };
const prompt = `You are ${config.bot.name}, ${config.bot.persona}. Keep your responses around ${config.ai.responseLength} words. Respond to: ${message}`;
try {
const response = await axios.post(settings.ollamaUrl, {
model: settings.model,
prompt,
stream: false
});
return response.data.response?.trim() || '...';
} catch (err) {
console.error('[AI] Request failed:', err.message);
return 'Im confused.';
}
}
module.exports = { chatWithAI };