|
|
@@ -8,39 +8,40 @@ import (
|
|
|
"github.com/kujtimiihoxha/termai/internal/llm/models"
|
|
|
"github.com/kujtimiihoxha/termai/internal/llm/tools"
|
|
|
"github.com/kujtimiihoxha/termai/internal/lsp"
|
|
|
+ "github.com/kujtimiihoxha/termai/internal/message"
|
|
|
+ "github.com/kujtimiihoxha/termai/internal/session"
|
|
|
)
|
|
|
|
|
|
type taskAgent struct {
|
|
|
- *agent
|
|
|
+ Service
|
|
|
}
|
|
|
|
|
|
-func (c *taskAgent) Generate(ctx context.Context, sessionID string, content string) error {
|
|
|
- return c.generate(ctx, sessionID, content)
|
|
|
-}
|
|
|
-
|
|
|
-func NewTaskAgent(lspClients map[string]*lsp.Client) (Service, error) {
|
|
|
+func NewTaskAgent(messages message.Service, sessions session.Service, lspClients map[string]*lsp.Client) (Service, error) {
|
|
|
model, ok := models.SupportedModels[config.Get().Model.Coder]
|
|
|
if !ok {
|
|
|
return nil, errors.New("model not supported")
|
|
|
}
|
|
|
|
|
|
ctx := context.Background()
|
|
|
- agentProvider, titleGenerator, err := getAgentProviders(ctx, model)
|
|
|
+
|
|
|
+ agent, err := NewAgent(
|
|
|
+ ctx,
|
|
|
+ sessions,
|
|
|
+ messages,
|
|
|
+ model,
|
|
|
+ []tools.BaseTool{
|
|
|
+ tools.NewGlobTool(),
|
|
|
+ tools.NewGrepTool(),
|
|
|
+ tools.NewLsTool(),
|
|
|
+ tools.NewSourcegraphTool(),
|
|
|
+ tools.NewViewTool(lspClients),
|
|
|
+ },
|
|
|
+ )
|
|
|
if err != nil {
|
|
|
return nil, err
|
|
|
}
|
|
|
+
|
|
|
return &taskAgent{
|
|
|
- agent: &agent{
|
|
|
- tools: []tools.BaseTool{
|
|
|
- tools.NewGlobTool(),
|
|
|
- tools.NewGrepTool(),
|
|
|
- tools.NewLsTool(),
|
|
|
- tools.NewSourcegraphTool(),
|
|
|
- tools.NewViewTool(lspClients),
|
|
|
- },
|
|
|
- model: model,
|
|
|
- agent: agentProvider,
|
|
|
- titleGenerator: titleGenerator,
|
|
|
- },
|
|
|
+ agent,
|
|
|
}, nil
|
|
|
}
|