1
0
mirror of https://github.com/coalaura/whiskr.git synced 2025-12-02 20:22:52 +00:00

tool call fixes

This commit is contained in:
Laura
2025-09-12 15:11:10 +02:00
parent 44a5c1cd62
commit 49fe3798d1
2 changed files with 21 additions and 5 deletions

15
chat.go
View File

@@ -365,6 +365,8 @@ func RunCompletion(ctx context.Context, response *Stream, request *openrouter.Ch
var ( var (
id string id string
open int
close int
tool *ToolCall tool *ToolCall
) )
@@ -405,12 +407,25 @@ func RunCompletion(ctx context.Context, response *Stream, request *openrouter.Ch
if len(calls) > 0 { if len(calls) > 0 {
call := calls[0] call := calls[0]
if open > 0 && open == close {
continue
}
if tool == nil { if tool == nil {
tool = &ToolCall{} tool = &ToolCall{}
} }
if call.ID != "" && !strings.HasSuffix(tool.ID, call.ID) {
tool.ID += call.ID tool.ID += call.ID
}
if call.Function.Name != "" && !strings.HasSuffix(tool.Name, call.Function.Name) {
tool.Name += call.Function.Name tool.Name += call.Function.Name
}
open += strings.Count(call.Function.Arguments, "{")
close += strings.Count(call.Function.Arguments, "}")
tool.Args += call.Function.Arguments tool.Args += call.Function.Arguments
} else if tool != nil { } else if tool != nil {
break break

View File

@@ -18,8 +18,9 @@ Use at most 1 tool call per turn. You have %d turns with tool calls total. Choos
- ❌ "detailed analysis of current renewable energy pricing trends and cost comparisons across different technologies" - ❌ "detailed analysis of current renewable energy pricing trends and cost comparisons across different technologies"
**fetch_contents({urls})** **fetch_contents({urls})**
- Get full page content from 1-5 specific URLs via Exa's contents endpoint - Get full page content from multiple specific URLs via Exa's contents endpoint
- Use when you have exact URLs and need complete text, code, or detailed information - Use when you have exact URLs and need complete text, code, or detailed information
- `urls` is a []string of URLs to return the content of
- Provides cleaned, readable content from web pages - Provides cleaned, readable content from web pages
- Good for: documentation pages, articles, blog posts you found in search results - Good for: documentation pages, articles, blog posts you found in search results