Skip to content

Commit

Permalink
Fixed issue where tools couldn't be used without profile
Browse files Browse the repository at this point in the history
The new profile use-tools array introduction caused regression for using
tools without any profile. Now, if the userConf.Tools is empty, all
tools will be chocen, instead of none.
  • Loading branch information
baalimago committed Jul 30, 2024
1 parent 366e44d commit c7fa64c
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 7 deletions.
3 changes: 3 additions & 0 deletions internal/text/generic/stream_completer.go
Original file line number Diff line number Diff line change
Expand Up @@ -60,6 +60,9 @@ func (s *StreamCompleter) createRequest(ctx context.Context, chat models.Chat) (
// No support for this yet since it's limited usecase and high complexity
ParalellToolCalls: false,
}
if s.debug {
ancli.PrintOK(fmt.Sprintf("streamcompleter: %v\n", debug.IndentedJsonFmt(s)))
}
if len(s.tools) > 0 {
reqData.Tools = s.tools
reqData.ToolChoice = s.ToolChoice
Expand Down
31 changes: 24 additions & 7 deletions internal/text/querier_setup.go
Original file line number Diff line number Diff line change
Expand Up @@ -62,18 +62,35 @@ func NewQuerier[C models.StreamCompleter](userConf Configurations, dfault C) (Qu
}
}

if misc.Truthy(os.Getenv("DEBUG")) {
ancli.PrintOK(fmt.Sprintf("userConf: %v\n", debug.IndentedJsonFmt(userConf)))
}
toolBox, ok := any(modelConf).(models.ToolBox)
if ok && userConf.UseTools {
if misc.Truthy(os.Getenv("DEBUG")) {
ancli.PrintOK(fmt.Sprintf("Registering tools, type: %T\n", modelConf))
ancli.PrintOK(fmt.Sprintf("Registering tools on type: %T\n", modelConf))
}
for _, t := range userConf.Tools {
tool, exists := tools.Tools[t]
if !exists {
ancli.PrintWarn(fmt.Sprintf("attempted to find tool: '%v', which doesn't exist, skipping", tool))
continue
// If usetools and no specific tools chocen, assume all are valid
if len(userConf.Tools) == 0 {
for _, tool := range tools.Tools {
if misc.Truthy(os.Getenv("DEBUG")) {
ancli.PrintOK(fmt.Sprintf("\tadding tool: %T\n", tool))
}
toolBox.RegisterTool(tool)
}
} else {
for _, t := range userConf.Tools {
tool, exists := tools.Tools[t]
if !exists {
ancli.PrintWarn(fmt.Sprintf("attempted to find tool: '%v', which doesn't exist, skipping", tool))
continue
}

if misc.Truthy(os.Getenv("DEBUG")) {
ancli.PrintOK(fmt.Sprintf("\tadding tool: %T\n", tool))
}
toolBox.RegisterTool(tool)
}
toolBox.RegisterTool(tool)
}
}

Expand Down

0 comments on commit c7fa64c

Please sign in to comment.