Feat: two agent types; WebAgentB impl

This commit is contained in:
Grail Finder
2025-12-19 11:06:22 +03:00
parent 5f852418d8
commit 67ea1aef0d
8 changed files with 101 additions and 185 deletions

View File

@@ -1,7 +1,10 @@
package agent
import (
"bytes"
"encoding/json"
"gf-lt/config"
"gf-lt/models"
"io"
"log/slog"
"net/http"
@@ -23,9 +26,28 @@ func NewAgentClient(cfg *config.Config, log slog.Logger, gt func() string) *Agen
}
}
func (ag *AgentClient) FormMsg(sysprompt, msg string) (io.Reader, error) {
agentConvo := []models.RoleMsg{
{Role: "system", Content: sysprompt},
{Role: "user", Content: msg},
}
agentChat := &models.ChatBody{
Model: ag.cfg.CurrentModel,
Stream: true,
Messages: agentConvo,
}
b, err := json.Marshal(agentChat)
if err != nil {
ag.log.Error("failed to form agent msg", "error", err)
return nil, err
}
return bytes.NewReader(b), nil
}
func (ag *AgentClient) LLMRequest(body io.Reader) ([]byte, error) {
req, err := http.NewRequest("POST", ag.cfg.CurrentAPI, body)
if err != nil {
ag.log.Error("llamacpp api", "error", err)
return nil, err
}
req.Header.Add("Accept", "application/json")