Skip to content

An open-source, privacy-first, self-hosted knowledge workspace where humans and AI agents work together 开源、隐私优先、自托管的知识工作空间,让人与智能体在此协作

:sparkles: AI Agent https://github.com/siyuan-note/siyuan/issues/17797

Danielc7b824f9abb8
diff --git a/kernel/agent/modelmeta.go b/kernel/agent/modelmeta.go
index d170ab4358..d17527b638 100644
--- a/kernel/agent/modelmeta.go
+++ b/kernel/agent/modelmeta.go
@@ -58,7 +58,8 @@ func loadModelContext() map[string]int {
continue
}
if entry.ContextLength > 0 {
- result[name] = entry.ContextLength
+ // key 转小写存储,使匹配大小写不敏感(用户填写 Baichuan4-Turbo / baichuan4-turbo 均可命中)。
+ result[strings.ToLower(name)] = entry.ContextLength
}
}
modelContextLimit = result
@@ -67,6 +68,7 @@ func loadModelContext() map[string]int {
}
// GetModelContextLimit 返回模型的上下文窗口大小(单位:token)。未知模型返回 0。
+// 匹配大小写不敏感(表 key 与查询参数均转小写)。
// 匹配顺序:先按完整模型名精确查找;再按「末段」(去掉 provider 前缀)查找,
// 兼容用户填写带前缀的 id(如 z-ai/glm-4.6)。表本身以末段为 key,故末段匹配即直接命中。
func GetModelContextLimit(model string) int {
@@ -77,11 +79,12 @@ func GetModelContextLimit(model string) int {
if table == nil {
return 0
}
- if limit, ok := table[model]; ok {
+ lower := strings.ToLower(model)
+ if limit, ok := table[lower]; ok {
return limit
}
- if idx := strings.LastIndexByte(model, '/'); idx >= 0 {
- if limit, ok := table[model[idx+1:]]; ok {
+ if idx := strings.LastIndexByte(lower, '/'); idx >= 0 {
+ if limit, ok := table[lower[idx+1:]]; ok {
return limit
}
}
diff --git a/kernel/agent/models.json b/kernel/agent/models.json
index 01da757a92..83a37d03b5 100644
--- a/kernel/agent/models.json
+++ b/kernel/agent/models.json
@@ -8,24 +8,6 @@
"zeroFiltered": 0,
"outputCount": 362
},
- "Baichuan-M3-Plus": {
- "contextLength": 32768
- },
- "Baichuan-NPC-Turbo": {
- "contextLength": 32768
- },
- "Baichuan3-Turbo": {
- "contextLength": 32768
- },
- "Baichuan4": {
- "contextLength": 32768
- },
- "Baichuan4-Air": {
- "contextLength": 32768
- },
- "Baichuan4-Turbo": {
- "contextLength": 32768
- },
"aion-1.0": {
"contextLength": 131072
},
@@ -41,12 +23,30 @@
"auto": {
"contextLength": 2000000
},
+ "baichuan-m3-plus": {
+ "contextLength": 32768
+ },
+ "baichuan-npc-turbo": {
+ "contextLength": 32768
+ },
"baichuan2-turbo": {
"contextLength": 32768
},
"baichuan2-turbo-192k": {
"contextLength": 196608
},
+ "baichuan3-turbo": {
+ "contextLength": 32768
+ },
+ "baichuan4": {
+ "contextLength": 32768
+ },
+ "baichuan4-air": {
+ "contextLength": 32768
+ },
+ "baichuan4-turbo": {
+ "contextLength": 32768
+ },
"bodybuilder": {
"contextLength": 128000
},