blob: ce1309a50e08bbabbf459efdd8a80bd7b84dc425 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
|
package models
import (
"encoding/json"
"time"
)
type Chat struct {
ID uint32 `db:"id" json:"id"`
Name string `db:"name" json:"name"`
Msgs string `db:"msgs" json:"msgs"` // []RoleMsg to string json
Agent string `db:"agent" json:"agent"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
func (c Chat) ToHistory() ([]RoleMsg, error) {
resp := []RoleMsg{}
if err := json.Unmarshal([]byte(c.Msgs), &resp); err != nil {
return nil, err
}
return resp, nil
}
/*
memories should have two key system
to be able to store different perspectives
agent -> topic -> data
agent is somewhat similar to a char
*/
type Memory struct {
Agent string `db:"agent" json:"agent"`
Topic string `db:"topic" json:"topic"`
Mind string `db:"mind" json:"mind"`
CreatedAt time.Time `db:"created_at" json:"created_at"`
UpdatedAt time.Time `db:"updated_at" json:"updated_at"`
}
// vector models
type VectorRow struct {
Embeddings []float32 `db:"embeddings" json:"embeddings"`
Slug string `db:"slug" json:"slug"`
RawText string `db:"raw_text" json:"raw_text"`
Distance float32 `db:"distance" json:"distance"`
}
|