Jupyter-ai and dockerspawner

I try to use jupyter-ai on our jupyterhub.
short config

  • dockerspawner
  • self-made docker images and standard docker images
    issues
  • config is not persistant, will be away if notebook is stopped
  • no way found to include config of jupyter-ai in docker image
    I tried:
  • with c.Spawner.cmd=["jupyter lab --config ‘/data/readonly/config’ "]
  • c.AiExtension.default_language_model=‘deepseek/deepseek-r1-distill-llama-70b:free’

how can I bring a config inside the docker image?
content of my Dockerfile:

FROM quay.io/jupyter/scipy-notebook:2025-01-20
RUN pip install 'jupyter-ai[all]'

any help is appreciated.

You should be able to put your config file in one of the directories shown by jupyter --paths
https://jupyter-ai.readthedocs.io/en/latest/users/index.html#configuring-as-a-config-file

Thanks a lot. It did not help.
I put jupyter_jupyter_ai_config.json into /home/jovyan/.jupyter
this worked (sort of) that the file is here but no change.
Or do I have to overwrite the jupyter_server_config.py ?

Can you share your full JupyterHub configuration? Does it work if you run your image on its own, without JupyterHub?

I think you should put in /home/jovyan/.jupyter/jupyter_server_config.d folder so that JupyterLab will pick it up. In the top level /home/jovyan/.jupyter it only reads jupyter_server_config.py and jupyter_server_config.json files

1 Like

the image has the same problem when run on its own. So some configuration issue with my docker image.

my Dockerfile:

FROM quay.io/jupyter/scipy-notebook:2025-01-20

RUN pip install 'jupyter-ai[all]'

RUN mkdir -p /home/jovyan/.jupyter

RUN mkdir -p /home/jovyan/.jupyter/jupyter-ai

RUN mkdir -p /home/jovyan/.jupyter/jupyter-ai/settings

ADD jupyter_jupyter_ai_config.json /home/jovyan/.jupyter

RUN echo c.AiExtension.default_language_model=deepseek/deepseek-r1-distill-llama-70b:free >>/home/jovyan/.jupyter/jupyter-ai/settings/jupyter_server_config.py

RUN echo c.AiExtension.default_api_keys={'OPENROUTER_API_KEY' : 'sk-or-v1-secret-ff'} >>/home/jovyan/.jupyter/jupyter-ai/settings/jupyter_server_config.py