Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions cli/azd/cmd/container.go
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ func registerCommonDependencies(container *ioc.NestedContainer) {
container.MustRegisterScoped(consent.NewConsentManager)
container.MustRegisterNamedSingleton("ollama", llm.NewOllamaModelProvider)
container.MustRegisterNamedSingleton("azure", llm.NewAzureOpenAiModelProvider)
container.MustRegisterNamedSingleton("github-copilot", llm.NewGitHubCopilotModelProvider)

// Agent security manager
container.MustRegisterSingleton(func() (*security.Manager, error) {
Expand Down
2 changes: 1 addition & 1 deletion cli/azd/cmd/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -376,7 +376,7 @@ func (i *initAction) initAppWithAgent(ctx context.Context) error {
// Warn user that this is an alpha feature
i.console.WarnForFeature(ctx, llm.FeatureLlm)

azdAgent, err := i.agentFactory.Create(
azdAgent, err := i.agentFactory.Create(ctx,
agent.WithDebug(i.flags.global.EnableDebugLogging),
)
if err != nil {
Expand Down
1 change: 1 addition & 0 deletions cli/azd/cmd/middleware/error.go
Original file line number Diff line number Diff line change
Expand Up @@ -84,6 +84,7 @@ func (e *ErrorMiddleware) Run(ctx context.Context, next NextFn) (*actions.Action

originalError := err
azdAgent, err := e.agentFactory.Create(
ctx,
agent.WithDebug(e.global.EnableDebugLogging),
agent.WithFileWatching(true),
)
Expand Down
8 changes: 5 additions & 3 deletions cli/azd/internal/agent/agent_factory.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,8 @@
package agent

import (
"context"

"github.com/azure/azure-dev/cli/azd/internal/agent/consent"
"github.com/azure/azure-dev/cli/azd/internal/agent/logging"
"github.com/azure/azure-dev/cli/azd/internal/agent/security"
Expand Down Expand Up @@ -38,7 +40,7 @@ func NewAgentFactory(
}

// CreateAgent creates a new agent instance
func (f *AgentFactory) Create(opts ...AgentCreateOption) (Agent, error) {
func (f *AgentFactory) Create(ctx context.Context, opts ...AgentCreateOption) (Agent, error) {
// Create a daily log file for all agent activity
fileLogger, loggerCleanup, err := logging.NewFileLoggerDefault()
if err != nil {
Expand All @@ -57,15 +59,15 @@ func (f *AgentFactory) Create(opts ...AgentCreateOption) (Agent, error) {
}

// Default model gets the chained handler to expose the UX experience for the agent
defaultModelContainer, err := f.llmManager.GetDefaultModel(llm.WithLogger(chainedHandler))
defaultModelContainer, err := f.llmManager.GetDefaultModel(ctx, llm.WithLogger(chainedHandler))
if err != nil {
defer cleanup()
return nil, err
}

// Sampling model only gets the file logger to output sampling actions
// We don't need UX for sampling requests right now
samplingModelContainer, err := f.llmManager.GetDefaultModel(llm.WithLogger(fileLogger))
samplingModelContainer, err := f.llmManager.GetDefaultModel(ctx, llm.WithLogger(fileLogger))
if err != nil {
defer cleanup()
return nil, err
Expand Down
3 changes: 2 additions & 1 deletion cli/azd/pkg/llm/azure_openai.go
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,7 @@
package llm

import (
"context"
"fmt"

"github.com/azure/azure-dev/cli/azd/pkg/config"
Expand Down Expand Up @@ -37,7 +38,7 @@ func NewAzureOpenAiModelProvider(userConfigManager config.UserConfigManager) Mod
// CreateModelContainer creates a model container for Azure OpenAI with configuration
// loaded from user settings. It validates required fields and applies optional parameters
// like temperature and max tokens before creating the OpenAI client.
func (p *AzureOpenAiModelProvider) CreateModelContainer(opts ...ModelOption) (*ModelContainer, error) {
func (p *AzureOpenAiModelProvider) CreateModelContainer(_ context.Context, opts ...ModelOption) (*ModelContainer, error) {
userConfig, err := p.userConfigManager.Load()
if err != nil {
return nil, err
Expand Down
Loading
Loading