BIG MASSIVE REFACTOR OMG
Ripped out literally everything to simplify the backend as much as possible. Some of the code was so horrifically complicated it's insaneeee
This commit is contained in:
@@ -76,7 +76,7 @@ type createNewListArguments struct {
|
||||
type CreateListAgent struct {
|
||||
client client.AgentClient
|
||||
|
||||
listModel models.ListModel
|
||||
listModel models.StackModel
|
||||
}
|
||||
|
||||
func (agent *CreateListAgent) CreateList(log *log.Logger, userID uuid.UUID, userReq string) error {
|
||||
@@ -120,12 +120,20 @@ func (agent *CreateListAgent) CreateList(log *log.Logger, userID uuid.UUID, user
|
||||
})
|
||||
}
|
||||
|
||||
agent.listModel.Save(ctx, userID, createListArgs.Title, createListArgs.Description, schemaItems)
|
||||
_, err = agent.listModel.Save(ctx, userID, createListArgs.Title, createListArgs.Description)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating list agent, saving list: %w", err)
|
||||
}
|
||||
|
||||
err = agent.listModel.SaveItems(ctx, schemaItems)
|
||||
if err != nil {
|
||||
return fmt.Errorf("creating list agent, saving items: %w", err)
|
||||
}
|
||||
|
||||
return nil
|
||||
}
|
||||
|
||||
func NewCreateListAgent(log *log.Logger, listModel models.ListModel) CreateListAgent {
|
||||
func NewCreateListAgent(log *log.Logger, listModel models.StackModel) CreateListAgent {
|
||||
client := client.CreateAgentClient(client.CreateAgentClientOptions{
|
||||
SystemPrompt: createListAgentPrompt,
|
||||
Log: log,
|
||||
|
||||
@@ -3,6 +3,7 @@ package agents
|
||||
import (
|
||||
"context"
|
||||
"fmt"
|
||||
"screenmark/screenmark/.gen/haystack/haystack/model"
|
||||
"screenmark/screenmark/agents/client"
|
||||
"screenmark/screenmark/models"
|
||||
|
||||
@@ -26,7 +27,7 @@ type DescriptionAgent struct {
|
||||
imageModel models.ImageModel
|
||||
}
|
||||
|
||||
func (agent DescriptionAgent) Describe(log *log.Logger, imageId uuid.UUID, imageName string, imageData []byte) error {
|
||||
func (agent DescriptionAgent) Describe(log *log.Logger, imageID uuid.UUID, imageName string, imageData []byte) error {
|
||||
request := client.AgentRequestBody{
|
||||
Model: "policy/images",
|
||||
Temperature: 0.3,
|
||||
@@ -51,7 +52,11 @@ func (agent DescriptionAgent) Describe(log *log.Logger, imageId uuid.UUID, image
|
||||
|
||||
markdown := resp.Choices[0].Message.Content
|
||||
|
||||
err = agent.imageModel.AddDescription(ctx, imageId, markdown)
|
||||
_, err = agent.imageModel.Update(ctx, model.Image{
|
||||
ID: imageID,
|
||||
Description: markdown,
|
||||
})
|
||||
|
||||
if err != nil {
|
||||
return err
|
||||
}
|
||||
|
||||
@@ -176,7 +176,7 @@ type addToListArguments struct {
|
||||
Schema []models.IDValue
|
||||
}
|
||||
|
||||
func NewListAgent(log *log.Logger, listModel models.ListModel, limitsMethods limits.LimitsManagerMethods) client.AgentClient {
|
||||
func NewListAgent(log *log.Logger, listModel models.StackModel, limitsMethods limits.LimitsManagerMethods) client.AgentClient {
|
||||
agentClient := client.CreateAgentClient(client.CreateAgentClientOptions{
|
||||
SystemPrompt: listPrompt,
|
||||
JsonTools: listTools,
|
||||
@@ -206,10 +206,19 @@ func NewListAgent(log *log.Logger, listModel models.ListModel, limitsMethods lim
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
savedList, err := listModel.Save(ctx, info.UserId, args.Name, args.Desription, args.Schema)
|
||||
|
||||
savedList, err := listModel.Save(ctx, info.UserId, args.Name, args.Desription)
|
||||
if err != nil {
|
||||
log.Error(err)
|
||||
log.Error("saving list", "err", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
for i := range args.Schema {
|
||||
args.Schema[i].StackID = savedList.ID
|
||||
}
|
||||
|
||||
err = listModel.SaveItems(ctx, args.Schema)
|
||||
if err != nil {
|
||||
log.Error("saving items", "err", err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
@@ -229,12 +238,12 @@ func NewListAgent(log *log.Logger, listModel models.ListModel, limitsMethods lim
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
listUuid, err := uuid.Parse(args.ListID)
|
||||
listUUID, err := uuid.Parse(args.ListID)
|
||||
if err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
if err := listModel.SaveInto(ctx, listUuid, info.ImageId, args.Schema); err != nil {
|
||||
if err := listModel.SaveImage(ctx, info.ImageId, listUUID); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user