pyaiml21.session.session.Session¶
- class pyaiml21.session.session.Session(user_id: str, bc: pyaiml21.botconfig.config.BotConfig, max_history: Optional[int] = None)[source][source]¶
Represents chat session between a chatbot and an user.
This class keeps track of the chat history, chat predicates and the graphmaster for this particular user.
Methods
Add bot reply (list of sentences) to the session history.
Add user query to th session history.
Find index-th bot's reply.
Find index-th user query.
Attributes
id of the user from this session
max length of the history to keep track of
- add_bot_reply(reply: List[str])[source][source]¶
Add bot reply (list of sentences) to the session history.
- add_user_query(query: List[str]) None[source][source]¶
Add user query to th session history.
- Parameters
query – list of sentences
- get_bot_reply(index: int) List[str][source][source]¶
Find index-th bot’s reply.
Return index-th bot reply as a list of sentences, or empty list, if we don’t know the reply (don’t have enough replies or index is more than max_history_length.
- Parameters
index – index of the reply to get, 0 for newest
- Returns
the reply consisting of the sentences
- get_user_query(index: int) List[str][source][source]¶
Find index-th user query.
Return index-th user query as a list of sentences, or empty list, if we don’t know the query (don’t have enough queries or index is more than max_history_length.
- Parameters
index – index of the query to get, 0 for newest
- Returns
the query consisting of the sentences