feat: add Gemini API compatibility, refactor stream rendering, and enhance tool call handling and configuration options

This commit is contained in:
CJACK
2026-02-22 20:53:42 +08:00
parent ae7dce0b32
commit a9403c5392
21 changed files with 581 additions and 297 deletions

View File

@@ -92,17 +92,29 @@ func filterToolCallsDetailed(parsed []ParsedToolCall, availableToolNames []strin
for _, name := range availableToolNames {
allowed[name] = struct{}{}
}
if len(allowed) == 0 {
rejectedSet := map[string]struct{}{}
for _, tc := range parsed {
if tc.Name == "" {
continue
}
rejectedSet[tc.Name] = struct{}{}
}
rejected := make([]string, 0, len(rejectedSet))
for name := range rejectedSet {
rejected = append(rejected, name)
}
return nil, rejected
}
out := make([]ParsedToolCall, 0, len(parsed))
rejectedSet := map[string]struct{}{}
for _, tc := range parsed {
if tc.Name == "" {
continue
}
if len(allowed) > 0 {
if _, ok := allowed[tc.Name]; !ok {
rejectedSet[tc.Name] = struct{}{}
continue
}
if _, ok := allowed[tc.Name]; !ok {
rejectedSet[tc.Name] = struct{}{}
continue
}
if tc.Input == nil {
tc.Input = map[string]any{}