@@ -118,6 +118,25 @@ func (c *Container) GetCommitService(ctx context.Context) (ports.CommitService,
118118 return c .commitService , nil
119119}
120120
121+ // GetPRSummarizer retorna el servicio de IA para resumir PRs (lazy initialization)
122+ func (c * Container ) GetPRSummarizer (ctx context.Context ) (ports.PRSummarizer , error ) {
123+ if c .config .AIConfig .ActiveAI == "" {
124+ return nil , fmt .Errorf ("no hay IA activa configurada" )
125+ }
126+
127+ aiFactory , err := c .aiRegistry .Get (string (c .config .AIConfig .ActiveAI ))
128+ if err != nil {
129+ return nil , fmt .Errorf ("proveedor de IA '%s' no encontrado: %w" , c .config .AIConfig .ActiveAI , err )
130+ }
131+
132+ aiSummarizer , err := aiFactory .CreatePRSummarizer (ctx , c .config , c .translations )
133+ if err != nil {
134+ return nil , fmt .Errorf ("error al crear el servicio de IA para PRs: %w" , err )
135+ }
136+
137+ return aiSummarizer , nil
138+ }
139+
121140// GetPRService retorna el servicio de PRs (lazy initialization)
122141func (c * Container ) GetPRService (ctx context.Context ) (ports.PRService , error ) {
123142 if c .prService != nil {
@@ -129,15 +148,9 @@ func (c *Container) GetPRService(ctx context.Context) (ports.PRService, error) {
129148 }
130149
131150 var aiSummarizer ports.PRSummarizer
132- if c .config .AIConfig .ActiveAI != "" {
133- aiFactory , err := c .aiRegistry .Get (string (c .config .AIConfig .ActiveAI ))
134- if err == nil {
135- aiSummarizer , err = aiFactory .CreatePRSummarizer (ctx , c .config , c .translations )
136- if err != nil {
137- // Log warning pero continuar sin AI
138- aiSummarizer = nil
139- }
140- }
151+ aiSummarizer , err := c .GetPRSummarizer (ctx )
152+ if err != nil {
153+ aiSummarizer = nil
141154 }
142155
143156 vcsClient , err := c .vcsRegistry .CreateClientFromConfig (ctx , c .gitService , c .config , c .translations )
0 commit comments