mirror of
https://github.com/foxhui/WebAI2API.git
synced 2026-06-16 21:03:59 +08:00
28 lines
887 B
JavaScript
28 lines
887 B
JavaScript
import { loadConfig } from '../config.js';
|
|
import * as lmarenaBackend from './lmarena.js';
|
|
import * as geminiBackend from './gemini_biz.js';
|
|
|
|
const config = loadConfig();
|
|
|
|
let activeBackend;
|
|
|
|
if (config.backend?.type === 'gemini_biz') {
|
|
activeBackend = {
|
|
name: 'gemini_biz',
|
|
initBrowser: (cfg) => geminiBackend.initBrowser(cfg),
|
|
generateImage: (ctx, prompt, paths, model, meta) => geminiBackend.generateImage(ctx, prompt, paths, model, meta),
|
|
TEMP_DIR: geminiBackend.TEMP_DIR
|
|
};
|
|
} else {
|
|
activeBackend = {
|
|
name: 'lmarena',
|
|
initBrowser: (cfg) => lmarenaBackend.initBrowser(cfg),
|
|
generateImage: (ctx, prompt, paths, model, meta) => lmarenaBackend.generateImage(ctx, prompt, paths, model, meta),
|
|
TEMP_DIR: lmarenaBackend.TEMP_DIR
|
|
};
|
|
}
|
|
|
|
export function getBackend() {
|
|
return { config, ...activeBackend };
|
|
}
|