fix: use lazy loading
Some checks failed
Deploy / lint-build-deploy (push) Failing after 6s

This commit is contained in:
2026-01-19 20:19:54 +01:00
parent ef333ae7f2
commit 04be7a66c0

View File

@@ -1,10 +1,17 @@
import 'dotenv/config';
import OpenAI from 'openai';
const ovhAI = new OpenAI({
let ovhAI: OpenAI | null = null;
function getClient(): OpenAI {
if (!ovhAI) {
ovhAI = new OpenAI({
apiKey: process.env.OVHCLOUD_API_KEY,
baseURL: 'https://oai.endpoints.kepler.ai.cloud.ovh.net/v1'
});
});
}
return ovhAI;
}
export interface BaseTool {
readonly name: string;
@@ -28,7 +35,7 @@ export async function makeRequest<T extends BaseTool>(
toolDef: T
): Promise<Record<string, unknown>> {
try {
const completion = await ovhAI.chat.completions.create({
const completion = await getClient().chat.completions.create({
model: 'Meta-Llama-3_3-70B-Instruct',
temperature: 1,
max_tokens: 16000,