MCPcopy Create free account
hub / github.com/TaskingAI/TaskingAI / Chat

Class Chat

backend/app/models/assistant/chat.py:16–115  ·  view source on GitHub ↗

Source from the content-addressed store, hash-verified

14
15
16class Chat(ModelEntity):
17 object: str = "Chat"
18 assistant_id: str = id_field("assistant", length=24)
19 chat_id: str = id_field("chat", length=24)
20
21 metadata: Dict = metadata_field()
22 memory: ChatMemory = Field(...)
23 name: str = name_field("chat")
24
25 created_timestamp: int = created_timestamp_field()
26 updated_timestamp: int = updated_timestamp_field()
27
28 @staticmethod
29 def build(row):
30 return Chat(
31 # ids
32 chat_id=row["chat_id"],
33 assistant_id=row["assistant_id"],
34 # data
35 memory=load_json_attr(row, "memory", {}),
36 metadata=load_json_attr(row, "metadata", {}),
37 name=row.get("name") or "",
38 # timestamps
39 created_timestamp=row["created_timestamp"],
40 updated_timestamp=row["updated_timestamp"],
41 )
42
43 def to_response_dict(self) -> Dict:
44 return {
45 "object": "Chat",
46 "assistant_id": self.assistant_id,
47 "chat_id": self.chat_id,
48 "metadata": self.metadata,
49 "memory": self.memory,
50 "name": self.name,
51 "created_timestamp": self.created_timestamp,
52 "updated_timestamp": self.updated_timestamp,
53 }
54
55 @staticmethod
56 def object_name() -> str:
57 return "chat"
58
59 @staticmethod
60 def object_plural_name() -> str:
61 return "chats"
62
63 @staticmethod
64 def table_name() -> str:
65 return "chat"
66
67 @staticmethod
68 def id_field_name() -> str:
69 return "chat_id"
70
71 @staticmethod
72 def primary_key_fields() -> List[str]:
73 return ["assistant_id", "chat_id"]

Callers 1

buildMethod · 0.85

Calls 5

id_fieldFunction · 0.85
metadata_fieldFunction · 0.85
name_fieldFunction · 0.85
created_timestamp_fieldFunction · 0.85
updated_timestamp_fieldFunction · 0.85

Tested by

no test coverage detected