mirror of
https://github.com/aljazceru/chatgpt-telegram-bot.git
synced 2025-12-20 14:14:52 +01:00
added current conversation stats to /stats
This commit is contained in:
@@ -28,6 +28,16 @@ class OpenAIHelper:
|
||||
self.conversations: dict[int: list] = {} # {chat_id: history}
|
||||
self.last_updated: dict[int: datetime] = {} # {chat_id: last_update_timestamp}
|
||||
|
||||
def get_conversation_stats(self, chat_id: int) -> tuple[int, int]:
|
||||
"""
|
||||
Gets the number of messages and tokens used in the conversation.
|
||||
:param chat_id: The chat ID
|
||||
:return: A tuple containing the number of messages and tokens used
|
||||
"""
|
||||
if chat_id not in self.conversations:
|
||||
self.reset_chat_history(chat_id)
|
||||
return (len(self.conversations[chat_id]), self.__count_tokens(self.conversations[chat_id]))
|
||||
|
||||
async def get_chat_response(self, chat_id: int, query: str) -> Union[tuple[str, str], str]:
|
||||
"""
|
||||
Gets a response from the GPT-3 model.
|
||||
|
||||
Reference in New Issue
Block a user