(cls, kb_dir: Path, model: str, language: str)
| 120 | |
| 121 | @classmethod |
| 122 | def new(cls, kb_dir: Path, model: str, language: str) -> "ChatSession": |
| 123 | now = _utcnow_iso() |
| 124 | sid = _gen_id() |
| 125 | return cls( |
| 126 | id=sid, |
| 127 | created_at=now, |
| 128 | updated_at=now, |
| 129 | model=model, |
| 130 | language=language, |
| 131 | title="", |
| 132 | turn_count=0, |
| 133 | history=[], |
| 134 | user_turns=[], |
| 135 | assistant_texts=[], |
| 136 | path=chats_dir(kb_dir) / f"{sid}.json", |
| 137 | ) |
| 138 | |
| 139 | def to_dict(self) -> dict[str, Any]: |
| 140 | return { |