in src/frontends/streamlit/frontend/utils/local_chat_history.py [0:0]
def get_all_conversations(self) -> dict[str, dict]:
"""Retrieves all conversations for the current user."""
conversations = {}
for filename in os.listdir(self.user_dir):
if filename.endswith(".yaml"):
file_path = os.path.join(self.user_dir, filename)
with open(file_path) as f:
conversation = yaml.safe_load(f)
if not isinstance(conversation, list) or len(conversation) > 1:
raise ValueError(
f"""Invalid format in {file_path}.
YAML file can only contain one conversation with the following
structure.
- messages:
- content: [message text]
- type: (human or ai)"""
)
conversation = conversation[0]
if "title" not in conversation:
conversation["title"] = filename
conversations[filename[:-5]] = conversation
return dict(
sorted(conversations.items(), key=lambda x: x[1].get("update_time", ""))
)