Skip to content

Commit

Permalink
fix: filter out the model provider credential when reporting tool info
Browse files Browse the repository at this point in the history
The model provider credential cannot be set by the user nor can it be
deleted. Therefore, it doesn't make sense to include it when report tool
infos on agents and workflows.

Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Jan 9, 2025
1 parent c77a7b8 commit c7604ed
Show file tree
Hide file tree
Showing 2 changed files with 13 additions and 6 deletions.
10 changes: 8 additions & 2 deletions pkg/controller/handlers/toolinfo/toolinfo.go
Original file line number Diff line number Diff line change
Expand Up @@ -44,11 +44,10 @@ func (h *Handler) SetToolInfoStatus(req router.Request, resp router.Response) (e
return err
}

credsSet := make(sets.Set[string], len(creds)+1)
credsSet := make(sets.Set[string], len(creds))
for _, cred := range creds {
credsSet.Insert(cred.ToolName)
}
credsSet.Insert(system.ModelProviderCredential)

obj := req.Object.(v1.ToolUser)
tools := obj.GetTools()
Expand Down Expand Up @@ -78,6 +77,13 @@ func (h *Handler) SetToolInfoStatus(req router.Request, resp router.Response) (e
toolRef.Status.Tool.CredentialNames = nil
}

for i := 0; i < len(credNames); i++ {
if credNames[i] == system.ModelProviderCredential {
credNames = append(credNames[:i], credNames[i+1:]...)
i--
}
}

toolInfos[tool] = types.ToolInfo{
CredentialNames: credNames,
Authorized: credsSet.HasAll(credNames...),
Expand Down
9 changes: 5 additions & 4 deletions pkg/storage/apis/obot.obot.ai/v1/file.go
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,11 @@ import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

var (
_ fields.Fields = (*KnowledgeFile)(nil)
_ DeleteRefs = (*KnowledgeFile)(nil)
)

// +k8s:deepcopy-gen:interfaces=k8s.io/apimachinery/pkg/runtime.Object

type KnowledgeFile struct {
Expand All @@ -19,8 +24,6 @@ type KnowledgeFile struct {
Status KnowledgeFileStatus `json:"status,omitempty"`
}

var _ fields.Fields = (*KnowledgeFile)(nil)

func (k *KnowledgeFile) GetColumns() [][]string {
return [][]string{
{"Name", "Name"},
Expand Down Expand Up @@ -75,8 +78,6 @@ func (*KnowledgeFile) FieldNames() []string {
return []string{"spec.knowledgeSourceName", "spec.knowledgeSetName"}
}

var _ fields.Fields = (*KnowledgeFile)(nil)

type KnowledgeFileSpec struct {
KnowledgeSetName string `json:"knowledgeSetName,omitempty"`
KnowledgeSourceName string `json:"knowledgeSourceName,omitempty"`
Expand Down

0 comments on commit c7604ed

Please sign in to comment.