seraph-agent
Version:
An extremely lightweight, SRE autonomous AI agent for seamless integration with common observability tasks.
27 lines (26 loc) • 923 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.OpenAIProvider = void 0;
const openai_1 = __importDefault(require("openai"));
class OpenAIProvider {
openai;
model;
constructor(config) {
if (!config.apiKey) {
throw new Error('OpenAI API key not found in config.');
}
this.openai = new openai_1.default({ apiKey: config.apiKey });
this.model = config.llm?.model || 'gpt-4-turbo';
}
async generate(prompt) {
const response = await this.openai.chat.completions.create({
model: this.model,
messages: [{ role: 'user', content: prompt }],
});
return response.choices[0].message.content || '';
}
}
exports.OpenAIProvider = OpenAIProvider;