Feat: two agent types; WebAgentB impl
This commit is contained in:
@@ -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")
|
||||
|
||||
Reference in New Issue
Block a user