Added Telethon Telegram client running alongside Python Telegram Bot client. Now bot can access full telegram client API in addition to the bot API. Telethon client is wrapped to TelethonClientWrapper class inside 'telethon_service' module. Bot can be run with or without Telethon client to make developing areas without need for telegram client easier
Updated test_mocks_v2 mocks to mock Telethon classes in addition to PTB library classes
Changed how gpt-commands message context is determined. Previously bot stored last 10 gpt command messages and their replies as context list in memory. In memory context was cleared on every restart and with '/gpt /reset' command. Now no context is stored in memory. Context is formed from Telegram message reply chains. Now bot replies to the gpt-command message, so that the "conversation context" is accumulated. This way gpt chat conversatios form a tree data structure, where each node can be replied to with a new message and as such forms a new reply chain. In addition, as replies messages are fetched from Telegram server, there is no time limit for conversation contexts. Added context message count to the response costs footer text.
added '/gpt3' or '/gpt3.5' as optional way to call GptCommand. When called with those, uses gpt-3.5-turbo model instead of V4. V4 is used by default, if command is called by '/gpt' (or '/gpt4').
now if another message is replied with just '/gpt', that message and its possible previous replies are used as the gpt command context.
now if another message is replied with just '/dalle' or '/dallemini', that messages content is used as the prompt for the image generation request. However possible replies are not included.
now gpt, dalle and dallemini commands are invoked both on message replies and on message edits
for both gpt and dalle commands, if other messages are used in context or as the prompt, those messages are preprocessed by cleaning all commands and possible parameters. In addition all cost footer texts are removed from bot's messages. This can be useful for generating a prompt with gpt-command and then using that response as input for dalle image generating command without copy-pasting it's content. Now the gpt-response message can just be replied with '/dalle'-command
added higher context limit model variants for both gpt3.5 and 4. Default 3.5 model has context limit of 4k tokens and with higher token limit model limit of 16k tokens. Default 4 model token limit is 8k and for higher limit model 32k.
added pre-tokenizing step before calling openai api so that correct model (default or higher token limit) can be chosen based on current message context token count
fixed costs information calculation for gpt command. Previously had same price for input and output tokens. Now fixed. Added price infor for higher token limit models
switched gpt and dalle commands OpenAi API-calls to be asynchronous. Now they won't block other commands
Other improvements:
extended 'dict_search' function to work with object with named attributes. Updated name to be 'object_search'
moved env-variables to new config module with logger configurations
added 'bot is writing' state updates to commands where there is a delay after the command. State is displayd on Telegram client on top banner of chat window
improved common 'send_images_response' function. Now if given image caption exceeds telegrams image caption length limit of 1024 characters, the caption is sent as a separate message. That way it has same character limit of 4096 characters as normal messages.
Removed ImageGenerationBaseTestClass and implemented dalle and dallemini command tests as concrete tests without class hierarchy
Other improvements: