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

Class Assistant

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

Source from the content-addressed store, hash-verified

14
15
16class Assistant(ModelEntity):
17 object: str = "Assistant"
18 assistant_id: str = id_field("assistant", length_range=(1, 50))
19
20 model_id: str = id_field("model", length=8)
21 name: str = name_field()
22 description: str = description_field()
23
24 system_prompt_template: List[str] = Field([])
25 memory: AssistantMemory = Field(...)
26
27 tools: List[ToolRef] = Field([])
28 # todo: tool_configs: Dict
29 retrievals: List[RetrievalRef] = Field([])
30 retrieval_configs: RetrievalConfig = Field(...)
31
32 metadata: Dict = metadata_field()
33 num_chats: int = Field(0, ge=0, description="The number of chats using this assistant", exclude=True)
34
35 created_timestamp: int = created_timestamp_field()
36 updated_timestamp: int = updated_timestamp_field()
37
38 @staticmethod
39 def build(row):
40 return Assistant(
41 assistant_id=row["assistant_id"],
42 model_id=row["model_id"],
43 name=row["name"],
44 description=row["description"],
45 system_prompt_template=load_json_attr(row, "system_prompt_template", []),
46 memory=load_json_attr(row, "memory", {"type": "zero"}),
47 tools=load_json_attr(row, "tools", []),
48 retrievals=load_json_attr(row, "retrievals", []),
49 retrieval_configs=RetrievalConfig(**load_json_attr(row, "retrieval_configs", {})),
50 metadata=load_json_attr(row, "metadata", {}),
51 num_chats=row["num_chats"],
52 created_timestamp=row["created_timestamp"],
53 updated_timestamp=row["updated_timestamp"],
54 )
55
56 def to_response_dict(self) -> Dict:
57 return {
58 "object": "Assistant",
59 "assistant_id": self.assistant_id,
60 "model_id": self.model_id,
61 "name": self.name,
62 "description": self.description,
63 "system_prompt_template": self.system_prompt_template,
64 "memory": self.memory.model_dump(exclude_none=True),
65 "tools": [tool.model_dump() for tool in self.tools],
66 "retrievals": [retrieval.model_dump() for retrieval in self.retrievals],
67 "retrieval_configs": self.retrieval_configs.model_dump(exclude_none=True),
68 "metadata": self.metadata,
69 "created_timestamp": self.created_timestamp,
70 "updated_timestamp": self.updated_timestamp,
71 }
72
73 @staticmethod

Callers 1

buildMethod · 0.70

Calls 6

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

Tested by

no test coverage detected