openlit
Version:
OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects
24 lines • 887 B
JavaScript
;
var __importDefault = (this && this.__importDefault) || function (mod) {
return (mod && mod.__esModule) ? mod : { "default": mod };
};
Object.defineProperty(exports, "__esModule", { value: true });
exports.llmResponseOpenAI = llmResponseOpenAI;
const openai_1 = __importDefault(require("openai"));
async function llmResponseOpenAI({ prompt, model, apiKey, baseUrl }) {
const client = new openai_1.default({
apiKey,
baseURL: baseUrl || 'https://api.openai.com/v1',
});
const usedModel = model || 'gpt-4o';
const response = await client.chat.completions.create({
model: usedModel,
messages: [
{ role: 'user', content: prompt }
],
temperature: 0.0,
response_format: { type: 'json_object' }
});
return response.choices[0].message.content || '';
}
//# sourceMappingURL=openai.js.map