rashi-discord-bot-lib
Version:
🚀 Powerful Discord bot framework with built-in database, event handling, and utilities
31 lines • 937 B
JavaScript
;
Object.defineProperty(exports, "__esModule", { value: true });
exports.AIChat = void 0;
const openai_1 = require("openai");
class AIChat {
openai;
model;
temperature;
constructor(options) {
this.openai = new openai_1.OpenAI({ apiKey: options.apiKey });
this.model = options.model || 'gpt-4o';
this.temperature = options.temperature ?? 0.8;
// 🔧 tutaj poprawiamy:
}
async ask(prompt) {
try {
const res = await this.openai.chat.completions.create({
model: this.model,
messages: [{ role: 'user', content: prompt }],
temperature: this.temperature,
});
const reply = res.choices?.[0]?.message?.content ?? '[No reply]';
return reply;
}
catch (err) {
throw err;
}
}
}
exports.AIChat = AIChat;
//# sourceMappingURL=AIChat.js.map