clearcase/internal/setup/issue_manager.go

36 lines
1.1 KiB
Go

package setup
import (
"context"
"forge.cadoles.com/wpetit/clearcase/internal/config"
"forge.cadoles.com/wpetit/clearcase/internal/core/service"
"github.com/bornholm/genai/llm/provider"
"github.com/pkg/errors"
_ "github.com/bornholm/genai/llm/provider/openai"
_ "github.com/bornholm/genai/llm/provider/openrouter"
)
func NewIssueManagerFromConfig(ctx context.Context, conf *config.Config) (*service.IssueManager, error) {
llmCtx := provider.FromMap(ctx, "", map[string]string{
string(provider.ContextKeyAPIBaseURL): conf.LLM.Provider.BaseURL,
string(provider.ContextKeyAPIKey): conf.LLM.Provider.Key,
string(provider.ContextKeyModel): conf.LLM.Provider.Model,
})
client, err := provider.Create(llmCtx, provider.Name(conf.LLM.Provider.Name))
if err != nil {
return nil, errors.Wrapf(err, "could not create llm client '%s'", conf.LLM.Provider.Name)
}
forgeFactories, err := getForgeFactories(conf)
if err != nil {
return nil, errors.Wrap(err, "could not get forge factories")
}
issueManager := service.NewIssueManager(client, forgeFactories...)
return issueManager, nil
}