Skip to content

Commit

Permalink
fix: properly report credential info for tools with model provider cred
Browse files Browse the repository at this point in the history
The model provider credential is special and will always be set to point
back to Obot. For tools that use this credential, we now properly detect
it and report its status.

Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Jan 7, 2025
1 parent 2c6477b commit 35572d2
Show file tree
Hide file tree
Showing 3 changed files with 9 additions and 1 deletion.
4 changes: 3 additions & 1 deletion pkg/controller/handlers/toolinfo/toolinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@ import (
"github.com/obot-platform/nah/pkg/router"
"github.com/obot-platform/obot/apiclient/types"
v1 "github.com/obot-platform/obot/pkg/storage/apis/otto.otto8.ai/v1"
"github.com/obot-platform/obot/pkg/system"
apierror "k8s.io/apimachinery/pkg/api/errors"
"k8s.io/apimachinery/pkg/util/sets"
)
Expand Down Expand Up @@ -39,10 +40,11 @@ func (h *Handler) SetToolInfoStatus(req router.Request, resp router.Response) (e
if err != nil {
return err
}
credsSet := make(sets.Set[string], len(creds))
credsSet := make(sets.Set[string], len(creds)+1)
for _, cred := range creds {
credsSet.Insert(cred.ToolName)
}
credsSet.Insert(system.ModelProviderCredential)

obj := req.Object.(v1.ToolUser)
tools := obj.GetTools()
Expand Down
4 changes: 4 additions & 0 deletions pkg/controller/handlers/toolreference/toolreference.go
Original file line number Diff line number Diff line change
Expand Up @@ -524,6 +524,10 @@ func modelName(modelProviderName, modelName string) string {
}

func determineCredentialNames(prg *gptscript.Program, tool gptscript.Tool, toolName string) ([]string, error) {
if toolName == system.ModelProviderCredential {
return []string{system.ModelProviderCredential}, nil
}

var subTool string
parsedToolName, alias, args, err := gtypes.ParseCredentialArgs(toolName, "")
if err != nil {
Expand Down
2 changes: 2 additions & 0 deletions pkg/system/tools.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,4 +16,6 @@ const (
ExistingCredTool = "existing-credential"

DefaultNamespace = "default"

ModelProviderCredential = "sys.model.provider.credential"
)

0 comments on commit 35572d2

Please sign in to comment.