UNPKG

openlit

Version:

OpenTelemetry-native Auto instrumentation library for monitoring LLM Applications, facilitating the integration of observability into your GenAI-driven projects

28 lines 966 B
"use strict"; Object.defineProperty(exports, "__esModule", { value: true }); exports.llmResponseOpenAI = llmResponseOpenAI; async function llmResponseOpenAI({ prompt, model, apiKey, baseUrl }) { let OpenAI; try { // eslint-disable-next-line @typescript-eslint/no-var-requires OpenAI = require('openai').default; } catch { throw new Error("openlit eval features require the 'openai' package. Install it with: npm install openai"); } const client = new OpenAI({ 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