adding support for generic AI provider (OpenAI compatible)
This commit is contained in:
@@ -2,9 +2,22 @@ import OpenAI from 'openai';
|
||||
import * as dotenv from 'dotenv';
|
||||
dotenv.config({ path: ['.env.local', '.env'] });
|
||||
|
||||
export const openai = new OpenAI({
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
});
|
||||
const AI_PROVIDER = process.env.AI_PROVIDER ?? 'OPENAI';
|
||||
const isGeneric = AI_PROVIDER === 'GENERIC';
|
||||
|
||||
export const openai = isGeneric
|
||||
? new OpenAI({
|
||||
apiKey: process.env.BEARER_TOKEN,
|
||||
baseURL: process.env.PROVIDER_URL,
|
||||
})
|
||||
: new OpenAI({
|
||||
apiKey: process.env.OPENAI_API_KEY,
|
||||
});
|
||||
|
||||
export const defaultModel = isGeneric ? (process.env.MODEL_NAME ?? 'default') : 'gpt-5.4';
|
||||
export const miniModel = isGeneric ? (process.env.MODEL_NAME ?? 'default') : 'gpt-5.4-mini';
|
||||
export const serviceOptions = isGeneric ? {} : { service_tier: 'flex' as const };
|
||||
export const supportsWebSearch = !isGeneric;
|
||||
|
||||
export async function askAgent(prompt: string) {
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user