feat: 设置面板 + Provider 扩展 + 构建脚本
- 设置面板:三步引导 / AI 配置 / API Key / 规则管理 / 连接测试 - Provider 重构:统一 OpenAICompatibleProvider 基类,新增 Gemini/Claude/混元/智谱等 - 审查面板 Webview:三 Tab、统计卡片、问题列表、postMessage 通信 - esbuild 构建脚本 + 生产打包 + PMD 下载 - 保存文件自动静态分析(500ms debounce)
This commit is contained in:
@@ -33,7 +33,7 @@ export abstract class AIProvider {
|
||||
|
||||
constructor(
|
||||
protected apiKey: string,
|
||||
protected endpoint: string
|
||||
protected baseUrl: string
|
||||
) {}
|
||||
|
||||
abstract chat(
|
||||
@@ -56,7 +56,7 @@ export class DeepSeekProvider extends AIProvider {
|
||||
name = 'DeepSeek';
|
||||
|
||||
async chat(systemPrompt: string, userPrompt: string, options: ChatOptions): Promise<string> {
|
||||
const url = `${this.endpoint}/chat/completions`;
|
||||
const url = `${this.baseUrl}/chat/completions`;
|
||||
|
||||
const body = JSON.stringify({
|
||||
model: options.model,
|
||||
@@ -112,7 +112,7 @@ export class OpenAIProvider extends AIProvider {
|
||||
name = 'OpenAI';
|
||||
|
||||
async chat(systemPrompt: string, userPrompt: string, options: ChatOptions): Promise<string> {
|
||||
const url = `${this.endpoint}/chat/completions`;
|
||||
const url = `${this.baseUrl}/chat/completions`;
|
||||
|
||||
const body = JSON.stringify({
|
||||
model: options.model,
|
||||
@@ -165,19 +165,19 @@ import { AIProvider } from './providers/base';
|
||||
import { DeepSeekProvider } from './providers/deepseek';
|
||||
import { OpenAIProvider } from './providers/openai';
|
||||
|
||||
type ProviderConstructor = new (apiKey: string, endpoint: string) => AIProvider;
|
||||
type ProviderConstructor = new (apiKey: string, baseUrl: string) => AIProvider;
|
||||
|
||||
const registry: Record<string, ProviderConstructor> = {
|
||||
deepseek: DeepSeekProvider,
|
||||
openai: OpenAIProvider,
|
||||
};
|
||||
|
||||
export function createProvider(providerId: string, apiKey: string, endpoint: string): AIProvider {
|
||||
export function createProvider(providerId: string, apiKey: string, baseUrl: string): AIProvider {
|
||||
const Cls = registry[providerId];
|
||||
if (!Cls) {
|
||||
throw new Error(`未知的 Provider: ${providerId}`);
|
||||
}
|
||||
return new Cls(apiKey, endpoint);
|
||||
return new Cls(apiKey, baseUrl);
|
||||
}
|
||||
|
||||
export function getProviderIds(): string[] {
|
||||
|
||||
Reference in New Issue
Block a user