feat: initial draft of generating a schema from one image
fix: error formatting
This commit is contained in:
@@ -41,15 +41,13 @@ func (agent DescriptionAgent) Describe(log *log.Logger, imageId uuid.UUID, image
|
||||
log.Debug("Sending description request")
|
||||
resp, err := agent.client.Request(&request)
|
||||
if err != nil {
|
||||
return fmt.Errorf("Could not request", err)
|
||||
return fmt.Errorf("Could not request. %s", err)
|
||||
}
|
||||
|
||||
ctx := context.Background()
|
||||
|
||||
markdown := resp.Choices[0].Message.Content
|
||||
|
||||
log.Debugf("Response %s", markdown)
|
||||
|
||||
err = agent.imageModel.AddDescription(ctx, imageId, markdown)
|
||||
if err != nil {
|
||||
return err
|
||||
|
||||
@@ -27,13 +27,17 @@ An example of lists are:
|
||||
Another one of your tasks is to create a schema for this list. This should contain information that this, and following
|
||||
pictures contain. Be specific but also generic. You should use the parameters in "createList" to create this schema.
|
||||
|
||||
This schema should not be super specific. You must be able to understand the image, and if the content of the image doesnt seem relevant, try
|
||||
and extract some meaning about what the image is.
|
||||
|
||||
You must call "listLists" to see which available lists are already available.
|
||||
Use "createList" only once, don't create multiple lists for one image.
|
||||
|
||||
**Tools:**
|
||||
* think: Internal reasoning/planning step.
|
||||
* listLists: Get existing lists
|
||||
* createList: Creates a new list with a name and description.
|
||||
* addToList: Add to an existing list.
|
||||
* createList: Creates a new list with a name and description. Only use this once.
|
||||
* addToList: Add to an existing list. This will also mean extracting information from this image, and inserting it, fitting the schema.
|
||||
* stopAgent: Signal task completion.
|
||||
`
|
||||
|
||||
@@ -89,19 +93,23 @@ const listTools = `
|
||||
"items": {
|
||||
"type": "object",
|
||||
"properties": {
|
||||
"key": {
|
||||
"Item": {
|
||||
"type": "string",
|
||||
"description": "The name of the key for this specific field. Similar to a column in a database"
|
||||
},
|
||||
"value": {
|
||||
"Value": {
|
||||
"type": "string",
|
||||
"enum": ["string", "number", "boolean"]
|
||||
},
|
||||
"Description": {
|
||||
"type": "string",
|
||||
"description": "The description for this item"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["name", "description"]
|
||||
"required": ["name", "description", "schema"]
|
||||
}
|
||||
}
|
||||
},
|
||||
@@ -116,9 +124,26 @@ const listTools = `
|
||||
"listId": {
|
||||
"type": "string",
|
||||
"description": "The UUID of the existing list"
|
||||
}
|
||||
},
|
||||
"schema": {
|
||||
"type": "array",
|
||||
"items": {
|
||||
"type": "object",
|
||||
"description": "A key-value of ID - value from this image to fit the schema. any of the values can be null",
|
||||
"properties": {
|
||||
"id": {
|
||||
"type": "string",
|
||||
"description": "The UUID of the schema item."
|
||||
},
|
||||
"value": {
|
||||
"type": "string",
|
||||
"description": "the concrete value for this field"
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
},
|
||||
"required": ["listId"]
|
||||
"required": ["listId", "schema"]
|
||||
}
|
||||
|
||||
}
|
||||
@@ -141,13 +166,11 @@ type listListsArguments struct{}
|
||||
type createListArguments struct {
|
||||
Name string `json:"name"`
|
||||
Desription string `json:"description"`
|
||||
Schema []struct {
|
||||
Key string `json:"key"`
|
||||
Value string `json:"value"`
|
||||
}
|
||||
Schema []model.SchemaItems
|
||||
}
|
||||
type addToListArguments struct {
|
||||
ListID string `json:"listId"`
|
||||
Schema []models.IDValue
|
||||
}
|
||||
|
||||
func NewListAgent(log *log.Logger, listModel models.ListModel) client.AgentClient {
|
||||
@@ -173,15 +196,16 @@ func NewListAgent(log *log.Logger, listModel models.ListModel) client.AgentClien
|
||||
return model.Events{}, err
|
||||
}
|
||||
|
||||
log.Debug("Create list", "schema", args.Schema)
|
||||
|
||||
ctx := context.Background()
|
||||
savedList, err := listModel.Save(ctx, info.UserId, args.Name, args.Desription)
|
||||
savedList, err := listModel.Save(ctx, info.UserId, args.Name, args.Desription, args.Schema)
|
||||
|
||||
if err != nil {
|
||||
return model.Lists{}, err
|
||||
log.Error(err)
|
||||
return "", err
|
||||
}
|
||||
|
||||
log.Debug(savedList)
|
||||
|
||||
return savedList, nil
|
||||
})
|
||||
|
||||
@@ -199,7 +223,7 @@ func NewListAgent(log *log.Logger, listModel models.ListModel) client.AgentClien
|
||||
return "", err
|
||||
}
|
||||
|
||||
if err := listModel.SaveInto(ctx, listUuid, info.ImageId); err != nil {
|
||||
if err := listModel.SaveInto(ctx, listUuid, info.ImageId, args.Schema); err != nil {
|
||||
return "", err
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user