Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
f628c81f
Unverified
提交
f628c81f
authored
5月 13, 2025
作者:
Will Chen
提交者:
GitHub
5月 13, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Refactor constants/models and inline (#143)
上级
877c8f7f
隐藏空白字符变更
内嵌
并排
正在显示
3 个修改的文件
包含
110 行增加
和
110 行删除
+110
-110
models.ts
src/constants/models.ts
+0
-108
language_model_helpers.ts
src/ipc/shared/language_model_helpers.ts
+95
-1
get_model_client.ts
src/ipc/utils/get_model_client.ts
+15
-1
没有找到文件。
src/constants/models.ts
deleted
100644 → 0
浏览文件 @
877c8f7f
import
type
{
ModelProvider
}
from
"@/lib/schemas"
;
export
interface
ModelOption
{
name
:
string
;
displayName
:
string
;
description
:
string
;
tag
?:
string
;
maxOutputTokens
?:
number
;
contextWindow
?:
number
;
}
export
type
RegularModelProvider
=
Exclude
<
ModelProvider
,
"ollama"
|
"lmstudio"
>
;
export
const
MODEL_OPTIONS
:
Record
<
RegularModelProvider
,
ModelOption
[]
>
=
{
openai
:
[
// https://platform.openai.com/docs/models/gpt-4.1
{
name
:
"gpt-4.1"
,
displayName
:
"GPT 4.1"
,
description
:
"OpenAI's flagship model"
,
maxOutputTokens
:
32
_768
,
contextWindow
:
1
_047_576
,
},
// https://platform.openai.com/docs/models/gpt-4.1-mini
{
name
:
"gpt-4.1-mini"
,
displayName
:
"GPT 4.1 Mini"
,
description
:
"OpenAI's lightweight, but intelligent model"
,
maxOutputTokens
:
32
_768
,
contextWindow
:
1
_047_576
,
},
// https://platform.openai.com/docs/models/o3-mini
{
name
:
"o3-mini"
,
displayName
:
"o3 mini"
,
description
:
"Reasoning model"
,
maxOutputTokens
:
100
_000
,
contextWindow
:
200
_000
,
},
],
// https://docs.anthropic.com/en/docs/about-claude/models/all-models#model-comparison-table
anthropic
:
[
{
name
:
"claude-3-7-sonnet-latest"
,
displayName
:
"Claude 3.7 Sonnet"
,
description
:
"Excellent coder"
,
maxOutputTokens
:
64
_000
,
contextWindow
:
200
_000
,
},
],
google
:
[
// https://ai.google.dev/gemini-api/docs/models#gemini-2.5-pro-preview-03-25
{
name
:
"gemini-2.5-pro-exp-03-25"
,
displayName
:
"Gemini 2.5 Pro"
,
description
:
"Experimental version of Google's Gemini 2.5 Pro model"
,
tag
:
"Recommended"
,
// See Flash 2.5 comment below (go 1 below just to be safe, even though it seems OK now).
maxOutputTokens
:
65
_536
-
1
,
// Gemini context window = input token + output token
contextWindow
:
1
_048_576
,
},
// https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview
{
name
:
"gemini-2.5-flash-preview-04-17"
,
displayName
:
"Gemini 2.5 Flash"
,
description
:
"Preview version of Google's Gemini 2.5 Flash model"
,
// Weirdly for Vertex AI, the output token limit is *exclusive* of the stated limit.
maxOutputTokens
:
65
_536
-
1
,
// Gemini context window = input token + output token
contextWindow
:
1
_048_576
,
},
],
openrouter
:
[
// https://openrouter.ai/deepseek/deepseek-chat-v3-0324:free
{
name
:
"deepseek/deepseek-chat-v3-0324:free"
,
displayName
:
"DeepSeek v3 (free)"
,
description
:
"Use for free (data may be used for training)"
,
maxOutputTokens
:
32
_000
,
contextWindow
:
128
_000
,
},
],
auto
:
[
{
name
:
"auto"
,
displayName
:
"Auto"
,
description
:
"Automatically selects the best model"
,
tag
:
"Default"
,
},
],
};
export
const
AUTO_MODELS
=
[
{
provider
:
"google"
,
name
:
"gemini-2.5-pro-exp-03-25"
,
},
{
provider
:
"anthropic"
,
name
:
"claude-3-7-sonnet-latest"
,
},
{
provider
:
"openai"
,
name
:
"gpt-4.1"
,
},
];
src/ipc/shared/language_model_helpers.ts
浏览文件 @
f628c81f
...
...
@@ -3,9 +3,103 @@ import {
language_model_providers
as
languageModelProvidersSchema
,
language_models
as
languageModelsSchema
,
}
from
"@/db/schema"
;
import
{
MODEL_OPTIONS
,
RegularModelProvider
}
from
"@/constants/models"
;
import
type
{
LanguageModelProvider
,
LanguageModel
}
from
"@/ipc/ipc_types"
;
import
{
eq
}
from
"drizzle-orm"
;
import
{
ModelProvider
}
from
"@/lib/schemas"
;
export
interface
ModelOption
{
name
:
string
;
displayName
:
string
;
description
:
string
;
tag
?:
string
;
maxOutputTokens
?:
number
;
contextWindow
?:
number
;
}
export
type
RegularModelProvider
=
Exclude
<
ModelProvider
,
"ollama"
|
"lmstudio"
>
;
export
const
MODEL_OPTIONS
:
Record
<
RegularModelProvider
,
ModelOption
[]
>
=
{
openai
:
[
// https://platform.openai.com/docs/models/gpt-4.1
{
name
:
"gpt-4.1"
,
displayName
:
"GPT 4.1"
,
description
:
"OpenAI's flagship model"
,
maxOutputTokens
:
32
_768
,
contextWindow
:
1
_047_576
,
},
// https://platform.openai.com/docs/models/gpt-4.1-mini
{
name
:
"gpt-4.1-mini"
,
displayName
:
"GPT 4.1 Mini"
,
description
:
"OpenAI's lightweight, but intelligent model"
,
maxOutputTokens
:
32
_768
,
contextWindow
:
1
_047_576
,
},
// https://platform.openai.com/docs/models/o3-mini
{
name
:
"o3-mini"
,
displayName
:
"o3 mini"
,
description
:
"Reasoning model"
,
maxOutputTokens
:
100
_000
,
contextWindow
:
200
_000
,
},
],
// https://docs.anthropic.com/en/docs/about-claude/models/all-models#model-comparison-table
anthropic
:
[
{
name
:
"claude-3-7-sonnet-latest"
,
displayName
:
"Claude 3.7 Sonnet"
,
description
:
"Excellent coder"
,
maxOutputTokens
:
64
_000
,
contextWindow
:
200
_000
,
},
],
google
:
[
// https://ai.google.dev/gemini-api/docs/models#gemini-2.5-pro-preview-03-25
{
name
:
"gemini-2.5-pro-exp-03-25"
,
displayName
:
"Gemini 2.5 Pro"
,
description
:
"Experimental version of Google's Gemini 2.5 Pro model"
,
tag
:
"Recommended"
,
// See Flash 2.5 comment below (go 1 below just to be safe, even though it seems OK now).
maxOutputTokens
:
65
_536
-
1
,
// Gemini context window = input token + output token
contextWindow
:
1
_048_576
,
},
// https://ai.google.dev/gemini-api/docs/models#gemini-2.5-flash-preview
{
name
:
"gemini-2.5-flash-preview-04-17"
,
displayName
:
"Gemini 2.5 Flash"
,
description
:
"Preview version of Google's Gemini 2.5 Flash model"
,
// Weirdly for Vertex AI, the output token limit is *exclusive* of the stated limit.
maxOutputTokens
:
65
_536
-
1
,
// Gemini context window = input token + output token
contextWindow
:
1
_048_576
,
},
],
openrouter
:
[
// https://openrouter.ai/deepseek/deepseek-chat-v3-0324:free
{
name
:
"deepseek/deepseek-chat-v3-0324:free"
,
displayName
:
"DeepSeek v3 (free)"
,
description
:
"Use for free (data may be used for training)"
,
maxOutputTokens
:
32
_000
,
contextWindow
:
128
_000
,
},
],
auto
:
[
{
name
:
"auto"
,
displayName
:
"Auto"
,
description
:
"Automatically selects the best model"
,
tag
:
"Default"
,
},
],
};
export
const
PROVIDER_TO_ENV_VAR
:
Record
<
string
,
string
>
=
{
openai
:
"OPENAI_API_KEY"
,
...
...
src/ipc/utils/get_model_client.ts
浏览文件 @
f628c81f
...
...
@@ -5,11 +5,25 @@ import { createOpenRouter } from "@openrouter/ai-sdk-provider";
import
{
createOllama
}
from
"ollama-ai-provider"
;
import
{
createOpenAICompatible
}
from
"@ai-sdk/openai-compatible"
;
import
type
{
LargeLanguageModel
,
UserSettings
}
from
"../../lib/schemas"
;
import
{
AUTO_MODELS
}
from
"../../constants/models"
;
import
{
getEnvVar
}
from
"./read_env"
;
import
log
from
"electron-log"
;
import
{
getLanguageModelProviders
}
from
"../shared/language_model_helpers"
;
const
AUTO_MODELS
=
[
{
provider
:
"google"
,
name
:
"gemini-2.5-pro-exp-03-25"
,
},
{
provider
:
"anthropic"
,
name
:
"claude-3-7-sonnet-latest"
,
},
{
provider
:
"openai"
,
name
:
"gpt-4.1"
,
},
];
const
logger
=
log
.
scope
(
"getModelClient"
);
export
async
function
getModelClient
(
model
:
LargeLanguageModel
,
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论