SuperCoder/internal/llm/agent/task.go

47 lines
1.1 KiB
Go
Raw Normal View History

2025-03-27 22:35:48 +01:00
package agent
import (
2025-04-10 13:29:44 +02:00
"context"
2025-03-27 22:35:48 +01:00
"errors"
"github.com/kujtimiihoxha/termai/internal/config"
"github.com/kujtimiihoxha/termai/internal/llm/models"
"github.com/kujtimiihoxha/termai/internal/llm/tools"
2025-04-13 14:37:05 +02:00
"github.com/kujtimiihoxha/termai/internal/lsp"
2025-03-27 22:35:48 +01:00
)
type taskAgent struct {
*agent
}
2025-04-10 13:29:44 +02:00
func (c *taskAgent) Generate(ctx context.Context, sessionID string, content string) error {
return c.generate(ctx, sessionID, content)
2025-03-27 22:35:48 +01:00
}
2025-04-13 14:37:05 +02:00
func NewTaskAgent(lspClients map[string]*lsp.Client) (Service, error) {
2025-03-27 22:35:48 +01:00
model, ok := models.SupportedModels[config.Get().Model.Coder]
if !ok {
return nil, errors.New("model not supported")
}
2025-04-13 13:17:17 +02:00
ctx := context.Background()
agentProvider, titleGenerator, err := getAgentProviders(ctx, model)
2025-03-27 22:35:48 +01:00
if err != nil {
return nil, err
}
return &taskAgent{
agent: &agent{
tools: []tools.BaseTool{
tools.NewGlobTool(),
tools.NewGrepTool(),
tools.NewLsTool(),
tools.NewSourcegraphTool(),
2025-04-13 14:37:05 +02:00
tools.NewViewTool(lspClients),
2025-03-27 22:35:48 +01:00
},
model: model,
agent: agentProvider,
titleGenerator: titleGenerator,
},
}, nil
}