Skip to content

Commit

Permalink
fix: use default model alias instead of looking for a model with default
Browse files Browse the repository at this point in the history
Signed-off-by: Donnie Adams <[email protected]>
  • Loading branch information
thedadams committed Nov 24, 2024
1 parent d05210b commit 6be36e4
Showing 1 changed file with 1 addition and 26 deletions.
27 changes: 1 addition & 26 deletions pkg/invoke/invoker.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,6 @@ import (
"github.com/otto8-ai/otto8/pkg/wait"
apierror "k8s.io/apimachinery/pkg/api/errors"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
"k8s.io/apimachinery/pkg/fields"
"k8s.io/client-go/util/retry"
kclient "sigs.k8s.io/controller-runtime/pkg/client"
)
Expand Down Expand Up @@ -289,32 +288,9 @@ func (i *Invoker) Agent(ctx context.Context, c kclient.WithWatch, agent *v1.Agen
}
}

defaultModel := agent.Spec.Manifest.Model
if defaultModel == "" {
var models v1.ModelList
if err := c.List(ctx, &models, &kclient.ListOptions{
FieldSelector: fields.SelectorFromSet(map[string]string{
"spec.manifest.default": "true",
}),
Namespace: agent.Namespace,
}); err != nil {
return nil, err
}

if len(models.Items) > 0 {
for _, model := range models.Items {
if model.Spec.Manifest.Active {
defaultModel = model.Name
break
}
}
}
}

return i.createRun(ctx, c, thread, tools, input, runOptions{
Synchronous: opt.Synchronous,
AgentName: agent.Name,
DefaultModel: defaultModel,
Env: extraEnv,
CredentialContextIDs: credContextIDs,
WorkflowStepName: opt.WorkflowStepName,
Expand All @@ -336,7 +312,6 @@ type runOptions struct {
ForceNoResume bool
Env []string
CredentialContextIDs []string
DefaultModel string
}

var (
Expand Down Expand Up @@ -385,7 +360,7 @@ func (i *Invoker) createRun(ctx context.Context, c kclient.WithWatch, thread *v1
Tool: string(toolData),
Env: opts.Env,
CredentialContextIDs: opts.CredentialContextIDs,
DefaultModel: opts.DefaultModel,
DefaultModel: string(types.DefaultModelAliasTypeLLM),
},
}

Expand Down

0 comments on commit 6be36e4

Please sign in to comment.