Add experimental Lingma remote backend

This commit is contained in:
lutc5
2026-04-30 12:09:51 +08:00
parent 1c188fcf17
commit 2bcb0a6715
15 changed files with 1543 additions and 37 deletions

View File

@@ -9,8 +9,11 @@ func TestLooksLikeMissedToolUseDetectsLocalToolAvoidance(t *testing.T) {
cases := []string{
"我需要使用终端工具来查看内存。",
"由于当前环境限制,请手动运行 top。",
"当前环境限制,我无法直接执行系统命令查看你的内存占用。",
"你可以在终端中运行 top -l 1 | grep PhysMem。",
"I need to read the file first.",
"Let me use the web search tool.",
"You can run the following command in your terminal.",
"现在我需要切换到计划模式。",
}
for _, tc := range cases {
@@ -20,6 +23,42 @@ func TestLooksLikeMissedToolUseDetectsLocalToolAvoidance(t *testing.T) {
}
}
func TestLooksLikeRefusalDetectsLocalAccessRefusals(t *testing.T) {
cases := []string{
"当前环境限制,我无法直接执行系统命令查看你的内存占用。",
"我无法访问你的电脑或本机文件。",
"I cannot execute commands in your local machine.",
"I can't access your computer directly.",
}
for _, tc := range cases {
if !LooksLikeRefusal(tc) {
t.Fatalf("LooksLikeRefusal(%q) = false", tc)
}
}
}
func TestInferToolCallsFromTextConvertsMemoryRefusalToBash(t *testing.T) {
calls := InferToolCallsFromText("当前无法执行系统命令。你可以运行 vm_stat 查看内存占用。", []ToolDef{{
Name: "Bash",
InputSchema: map[string]any{
"properties": map[string]any{
"command": map[string]any{"type": "string"},
},
"required": []any{"command"},
},
}})
if len(calls) != 1 {
t.Fatalf("call count = %d", len(calls))
}
if calls[0].Name != "Bash" {
t.Fatalf("tool name = %q", calls[0].Name)
}
command, _ := calls[0].Arguments["command"].(string)
if !strings.Contains(command, "vm_stat") || !strings.Contains(command, "memory_pressure") {
t.Fatalf("unexpected command = %q", command)
}
}
func TestLooksLikeMissedToolUseIgnoresFinalAnswers(t *testing.T) {
text := "这个文件负责 HTTP API 路由和 OpenAI 兼容响应。"
if LooksLikeMissedToolUse(text) {