Skip to content
项目
群组
代码片段
帮助
当前项目
正在载入...
登录 / 注册
切换导航面板
B
bit-pm
项目
项目
详情
活动
周期分析
仓库
仓库
文件
提交
分支
标签
贡献者
图表
比较
统计图
议题
0
议题
0
列表
看板
标记
里程碑
合并请求
0
合并请求
0
CI / CD
CI / CD
流水线
作业
日程
统计图
Wiki
Wiki
代码片段
代码片段
成员
成员
折叠边栏
关闭边栏
活动
图像
聊天
创建新问题
作业
提交
问题看板
Open sidebar
燕伟桐
bit-pm
Commits
9a288fd8
Unverified
提交
9a288fd8
authored
5月 15, 2025
作者:
Will Chen
提交者:
GitHub
5月 15, 2025
浏览文件
操作
浏览文件
下载
电子邮件补丁
差异文件
Fix local models (#176)
Fixes #167
上级
56900ebe
显示空白字符变更
内嵌
并排
正在显示
2 个修改的文件
包含
38 行增加
和
6 行删除
+38
-6
ProviderSettings.tsx
src/components/ProviderSettings.tsx
+3
-1
language_model_helpers.ts
src/ipc/shared/language_model_helpers.ts
+35
-5
没有找到文件。
src/components/ProviderSettings.tsx
浏览文件 @
9a288fd8
...
@@ -102,7 +102,9 @@ export function ProviderSettingsGrid() {
...
@@ -102,7 +102,9 @@ export function ProviderSettingsGrid() {
<
div
className=
"p-6"
>
<
div
className=
"p-6"
>
<
h2
className=
"text-2xl font-bold mb-6"
>
AI Providers
</
h2
>
<
h2
className=
"text-2xl font-bold mb-6"
>
AI Providers
</
h2
>
<
div
className=
"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"
>
<
div
className=
"grid grid-cols-1 md:grid-cols-2 lg:grid-cols-3 gap-4"
>
{
providers
?.
map
((
provider
:
LanguageModelProvider
)
=>
{
{
providers
?.
filter
((
p
)
=>
p
.
type
!==
"local"
)
.
map
((
provider
:
LanguageModelProvider
)
=>
{
const
isCustom
=
provider
.
type
===
"custom"
;
const
isCustom
=
provider
.
type
===
"custom"
;
return
(
return
(
...
...
src/ipc/shared/language_model_helpers.ts
浏览文件 @
9a288fd8
...
@@ -113,7 +113,7 @@ export const PROVIDER_TO_ENV_VAR: Record<string, string> = {
...
@@ -113,7 +113,7 @@ export const PROVIDER_TO_ENV_VAR: Record<string, string> = {
openrouter
:
"OPENROUTER_API_KEY"
,
openrouter
:
"OPENROUTER_API_KEY"
,
};
};
export
const
PROVIDERS
:
Record
<
export
const
CLOUD_
PROVIDERS
:
Record
<
string
,
string
,
{
{
displayName
:
string
;
displayName
:
string
;
...
@@ -153,6 +153,23 @@ export const PROVIDERS: Record<
...
@@ -153,6 +153,23 @@ export const PROVIDERS: Record<
},
},
};
};
const
LOCAL_PROVIDERS
:
Record
<
string
,
{
displayName
:
string
;
hasFreeTier
:
boolean
;
}
>
=
{
ollama
:
{
displayName
:
"Ollama"
,
hasFreeTier
:
true
,
},
lmstudio
:
{
displayName
:
"LM Studio"
,
hasFreeTier
:
true
,
},
};
/**
/**
* Fetches language model providers from both the database (custom) and hardcoded constants (cloud),
* Fetches language model providers from both the database (custom) and hardcoded constants (cloud),
* merging them with custom providers taking precedence.
* merging them with custom providers taking precedence.
...
@@ -181,11 +198,11 @@ export async function getLanguageModelProviders(): Promise<
...
@@ -181,11 +198,11 @@ export async function getLanguageModelProviders(): Promise<
// Get hardcoded cloud providers
// Get hardcoded cloud providers
const
hardcodedProviders
:
LanguageModelProvider
[]
=
[];
const
hardcodedProviders
:
LanguageModelProvider
[]
=
[];
for
(
const
providerKey
in
PROVIDERS
)
{
for
(
const
providerKey
in
CLOUD_
PROVIDERS
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
PROVIDERS
,
providerKey
))
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
CLOUD_
PROVIDERS
,
providerKey
))
{
// Ensure providerKey is a key of PROVIDERS
// Ensure providerKey is a key of PROVIDERS
const
key
=
providerKey
as
keyof
typeof
PROVIDERS
;
const
key
=
providerKey
as
keyof
typeof
CLOUD_
PROVIDERS
;
const
providerDetails
=
PROVIDERS
[
key
];
const
providerDetails
=
CLOUD_
PROVIDERS
[
key
];
if
(
providerDetails
)
{
if
(
providerDetails
)
{
// Ensure providerDetails is not undefined
// Ensure providerDetails is not undefined
hardcodedProviders
.
push
({
hardcodedProviders
.
push
({
...
@@ -202,6 +219,19 @@ export async function getLanguageModelProviders(): Promise<
...
@@ -202,6 +219,19 @@ export async function getLanguageModelProviders(): Promise<
}
}
}
}
for
(
const
providerKey
in
LOCAL_PROVIDERS
)
{
if
(
Object
.
prototype
.
hasOwnProperty
.
call
(
LOCAL_PROVIDERS
,
providerKey
))
{
const
key
=
providerKey
as
keyof
typeof
LOCAL_PROVIDERS
;
const
providerDetails
=
LOCAL_PROVIDERS
[
key
];
hardcodedProviders
.
push
({
id
:
key
,
name
:
providerDetails
.
displayName
,
hasFreeTier
:
providerDetails
.
hasFreeTier
,
type
:
"local"
,
});
}
}
return
[...
hardcodedProviders
,
...
customProvidersMap
.
values
()];
return
[...
hardcodedProviders
,
...
customProvidersMap
.
values
()];
}
}
...
...
编写
预览
Markdown
格式
0%
重试
或
添加新文件
添加附件
取消
您添加了
0
人
到此讨论。请谨慎行事。
请先完成此评论的编辑!
取消
请
注册
或者
登录
后发表评论