Skip to content

Commit

Permalink
fix: fix tool reference credentials that have sub tools
Browse files Browse the repository at this point in the history
The credential parsing was not correct for credentials in the sub tool
format. This change fixes that parsing.

Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Jan 7, 2025
1 parent 672d8c1 commit 2c6477b
Showing 1 changed file with 10 additions and 2 deletions.
12 changes: 10 additions & 2 deletions pkg/controller/handlers/toolreference/toolreference.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,9 +524,14 @@ func modelName(modelProviderName, modelName string) string {
}

func determineCredentialNames(prg *gptscript.Program, tool gptscript.Tool, toolName string) ([]string, error) {
toolName, alias, args, err := gtypes.ParseCredentialArgs(toolName, "")
var subTool string
parsedToolName, alias, args, err := gtypes.ParseCredentialArgs(toolName, "")
if err != nil {
return nil, err
parsedToolName, subTool = gtypes.SplitToolRef(toolName)
parsedToolName, alias, args, err = gtypes.ParseCredentialArgs(parsedToolName, "")
if err != nil {
return nil, err
}
}

if alias != "" {
Expand All @@ -536,6 +541,9 @@ func determineCredentialNames(prg *gptscript.Program, tool gptscript.Tool, toolN
if args == nil {
// This is a tool and not the credential format. Parse the tool from the program to determine the alias
toolNames := make([]string, 0, len(tool.Credentials))
if subTool == "" {
toolName = parsedToolName
}
for _, cred := range tool.Credentials {
if cred == toolName {
if len(tool.ToolMapping[cred]) == 0 {
Expand Down

0 comments on commit 2c6477b

Please sign in to comment.