def set_title()

in src/frontends/streamlit/frontend/utils/local_chat_history.py [0:0]


    def set_title(self, session: dict) -> None:
        """
        Set the title for the given session.

        This method generates a title for the session based on its messages.
        If the session has messages, it appends a special message to prompt
        for title creation, generates the title using a title chain, and
        updates the session with the new title.

        Args:
            session (dict): A dictionary containing session information,
                            including messages.

        Returns:
            None
        """
        if session["messages"]:
            messages = session["messages"] + [
                {
                    "type": "human",
                    "content": "End of conversation - Create one single title",
                }
            ]
            # Remove the tool calls from conversation
            messages = [
                msg
                for msg in messages
                if msg["type"] in ("ai", "human") and isinstance(msg["content"], str)
            ]

            response = chain_title.invoke(messages)
            title = (
                response.content.strip()
                if isinstance(response.content, str)
                else str(response.content)
            )
            session["title"] = title
            self.upsert_session(session)