// 模型网关配置。字段和团队的 provider 配置保持一致: // // eastmoney: // displayName: 东财AI网关 // apiKeyEnv: EASTMONEY_API_KEY // api: openai-completions // baseURL: https://dd-ai-api.eastmoney.com/coding/v1 // models: [DeepSeek-V4.1-Flash-1017] // // 密钥只从环境变量读取。项目根目录的 .env.local(不进 git)会在启动时加载。 import { existsSync } from 'node:fs'; import { fileURLToPath } from 'node:url'; import type { Provider } from './llm.ts'; export const PROJECT_ROOT = fileURLToPath(new URL('..', import.meta.url)); const eastmoney = { displayName: '东财AI网关', apiKeyEnv: 'EASTMONEY_API_KEY', api: 'openai-completions' as const, baseURL: 'https://dd-ai-api.eastmoney.com/coding/v1', model: 'DeepSeek-V4.1-Flash-1017', }; export function loadProvider(): Provider { const envFile = `${PROJECT_ROOT}.env.local`; if (existsSync(envFile)) process.loadEnvFile(envFile); const apiKey = process.env[eastmoney.apiKeyEnv]; if (!apiKey) { throw new Error( `缺少模型网关密钥。请设置环境变量 ${eastmoney.apiKeyEnv},或写进 ${envFile}(参考 .env.example)。`, ); } return { displayName: eastmoney.displayName, api: eastmoney.api, baseURL: process.env.LLM_BASE_URL ?? eastmoney.baseURL, model: process.env.LLM_MODEL ?? eastmoney.model, apiKey, }; }