Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added command to view and change the current model #139

Closed
wants to merge 6 commits into from

Conversation

viktor02
Copy link

Hi. I added a new command to switch between openai models: /model

Usage:

/model - get information about the current model and available models.

/model gpt-4 - change model to gpt-4

изображение

If something is wrong, tell me, I'll fix it.

@AlexHTW
Copy link
Contributor

AlexHTW commented Mar 29, 2023

Hey,
great feature and should definitely be included. However as I understand the current implementation, any user can change the model for all users, which could lead to confusion.
I think one of the following two options would be better.

  1. Only change the model for that specific user. The model setting would need to be detached from the bot config somehow.
    OR
  2. Add the command only for admins. You would need to check with is_admin instead of is_allowed and find a way to only show this BotCommand to admins.

I would be very interested in solutions for either option because there are many other things that would be great to be able to set specifically for each user but also the ability to add admin commands that are hidden from regular users.

Edit: the second option would be probably better for now since there is no way yet to set different costs for all the models and the API key might not support gpt4.

@viktor02
Copy link
Author

I implemented the second option, but

find a way to only show this BotCommand to admins.

It seems impossible to me, Telegram only allows to set general commands. So, I removed the /model command from bot help menu and added a sending message for non-admin users when they will try to use it.
Also added a fix in case the administrator tries to use a model that is not on the GPT_ALL_MODELS list

In theory, the first method would be preferable and more flexible, but then you would have to store user settings somewhere.

@viktor02
Copy link
Author

Well, apparently I was wrong - its possible to show a different commands to different users using scopes

@n3d1117
Copy link
Owner

n3d1117 commented Mar 29, 2023

Very nice @viktor02, thanks. I agree this feature should be for admins only.

I was wondering if there's a nicer way to let the user select a model from the list? Maybe using inline buttons? (Never used them so I'm not sure how they work)

@AlexHTW
Copy link
Contributor

AlexHTW commented Mar 29, 2023

In theory, the first method would be preferable and more flexible, but then you would have to store user settings somewhere.

I agree, for now I think it's good enough to have it admin only.

Well, apparently I was wrong - its possible to show a different commands to different users using scopes

Awesome, nice find! That would be really neat and make it straightforward to add new admin commands to control other environment settings without cluttering the menu for the users.

If I may add another suggestion - I think any config changes should also be written to the .env file (set_key) so that they persist after a restart. @n3d1117 Do you agree? Is it okay to just load_dotenv() in the telegram_bot.py again?

@n3d1117
Copy link
Owner

n3d1117 commented Mar 29, 2023

I think any config changes should also be written to the .env file (set_key) so that they persist after a restart. @n3d1117 Do you agree? Is it okay to just load_dotenv() in the telegram_bot.py again?

Yeah I agree!

@viktor02
Copy link
Author

Well, something like this?
I'm not quite sure if this relative path is the right one to use

@dkvdm
Copy link

dkvdm commented Mar 30, 2023

For this project, do we consider env vars mutable or immutable? because if this bot is deployed via Docker with a env_file param that defines OPENAI_MODEL that's different from what is defined in the chat, the config change set via chat will be overwritten on the next deployment. No firm opinion from my side, but just a heads up in terms of a potential footgun.

@AlexHTW
Copy link
Contributor

AlexHTW commented Mar 30, 2023

For this project, do we consider env vars mutable or immutable? because if this bot is deployed via Docker with a env_file param that defines OPENAI_MODEL that's different from what is defined in the chat, the config change set via chat will be overwritten on the next deployment. No firm opinion from my side, but just a heads up in terms of a potential footgun.

Great note. Is there any best practice solution to this? is there a good way that docker users can only run it with env_file param on their first deployment (or when they want to overwrite settings) and otherwise the container "remembers" the settings?

@n3d1117
Copy link
Owner

n3d1117 commented Apr 6, 2023

@viktor02 Should I close this in favor of #183?

@viktor02 viktor02 closed this Apr 6, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

4 participants