-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathmodels.py
More file actions
87 lines (70 loc) · 3 KB
/
models.py
File metadata and controls
87 lines (70 loc) · 3 KB
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
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
from sqlalchemy import Column, String, Text, ForeignKey, JSON, Boolean, BLOB, DateTime, TIMESTAMP
from sqlalchemy.ext.declarative import declarative_base
from datetime import datetime, timezone
Base = declarative_base()
# Define the models
class Account(Base):
__tablename__ = "accounts"
id = Column(String, primary_key=True)
createdAt = Column(DateTime, default=datetime.now(timezone.utc))
name = Column(String)
username = Column(String)
email = Column(String, nullable=False)
avatarUrl = Column(String)
details = Column(JSON, default={}, nullable=False)
class Memory(Base):
__tablename__ = "memories"
id = Column(String, primary_key=True)
type = Column(String, nullable=False)
createdAt = Column(TIMESTAMP, default=datetime.now(timezone.utc))
content = Column(Text, nullable=False)
embedding = Column(BLOB, nullable=False) # Assuming embedding is stored as a string representation of a blob
userId = Column(String, ForeignKey("accounts.id"))
roomId = Column(String)
agentId = Column(String, ForeignKey("accounts.id"))
unique = Column(Boolean, default=True, nullable=False)
class Goal(Base):
__tablename__ = "goals"
id = Column(String, primary_key=True)
createdAt = Column(DateTime, default=datetime.now(timezone.utc))
userId = Column(String, ForeignKey("accounts.id"))
name = Column(String)
status = Column(String)
description = Column(String)
roomId = Column(String)
objectives = Column(JSON, default=[], nullable=False)
class Log(Base):
__tablename__ = "logs"
id = Column(String, primary_key=True)
createdAt = Column(DateTime, default=datetime.now(timezone.utc))
userId = Column(String, nullable=False)
body = Column(Text, nullable=False)
type = Column(String, nullable=False)
roomId = Column(String, nullable=False)
class Participant(Base):
__tablename__ = "participants"
id = Column(String, primary_key=True)
createdAt = Column(DateTime, default=datetime.now(timezone.utc))
userId = Column(String, ForeignKey("accounts.id"))
roomId = Column(String)
userState = Column(String)
last_message_read = Column(String)
class Relationship(Base):
__tablename__ = "relationships"
id = Column(String, primary_key=True)
createdAt = Column(DateTime, default=datetime.now(timezone.utc))
userA = Column(String, ForeignKey("accounts.id"), nullable=False)
userB = Column(String, ForeignKey("accounts.id"), nullable=False)
status = Column(String, nullable=False)
userId = Column(String, ForeignKey("accounts.id"), nullable=False)
class Room(Base):
__tablename__ = "rooms"
id = Column(String, primary_key=True)
createdAt = Column(DateTime, default=datetime.now(timezone.utc))
class Cache(Base):
__tablename__ = "cache"
key = Column(String, primary_key=True)
agentId = Column(String, primary_key=True)
value = Column(JSON, default={}, nullable=False)
createdAt = Column(DateTime, default=datetime.now(timezone.utc))
expiresAt = Column(DateTime)