RTutor icon indicating copy to clipboard operation
RTutor copied to clipboard

RTutor only picks up OpenAI key if environment variable set BEFORE installing RTutor

Open AleSR13 opened this issue 3 years ago • 2 comments

Thanks for helping me solve my previous issue. I managed to make a Dockerfile with RTutor and it works as expected. However, I noticed something that makes it a bit counterintuitive. The launching was perfect if I added the OpenAI key using the 'settings' button on the dashboard. However, if I used an environment variable it worked a bit different to what I expected and makes it a bit more problematic to share my Dockerfile, for instance.

I first installed RTutor, then I created the OPEN_API_KEY environment variable and then launched the dashboard with RTutor::run_app(). However, all my queries failed with an error saying that probably the API key was incorrect. If I added the same API key manually, it worked. After many attempts and looking at the code for a long time, I realized that the OPEN_API_KEY environment variable could only be set up BEFORE installing the RTutor package. If I did that, it worked as expected.

It might not be considered a bug but it could be more of an enhancement. For instance, I would have liked to make a docker image that I can use with different accounts while passing the environment variable at the moment of launching the container (with docker run -e OPEN_API_KEY=<my_api_key> rtutor). However, instead, I had to add the environment variable inside my docker container so that the image itself is bound to my account. If I change accounts, I would need to change the image as well. As said, it is not per se a problem but it could be nicer that the api_key was read at the moment of launching. In any case, this behavior could at least be a bit clearer in your documentation.

Thanks again for this lovely package!

AleSR13 avatar Jan 27 '23 17:01 AleSR13

An alternative method might be to mount the current folder to the container. This way, other users can save the api key in their folder when they start the docker run. The api key file is available from inside the container. docker run -v xxx:xxx rtutor I will look into this when I have a little more time. If you find a solution, please let me know.

gexijin avatar Jan 27 '23 18:01 gexijin

I will look into this as there is another user had the same issue.

gexijin avatar Sep 14 '23 14:09 gexijin