jupyter-ai
jupyter-ai copied to clipboard
chat UI not showing on jupyterhub
Description
using: https://github.com/jupyterhub/zero-to-jupyterhub-k8s chat UI doesn't appear after installing pip install jupyter_ai
Reproduce
- setup jupyterhub environment using https://github.com/jupyterhub/zero-to-jupyterhub-k8s
- open jupyterhub > terminal > pip install jupyter_ai
- restart jupyterhub
- check left navigation list
Expected behavior
chat UI on left navigation appears
Context
Trying to understand if Jupyterhub cannot support this JupyterLab extension. Listed Jupyter Lab Extension and found: @jupyter-ai/core v0.7.3 enabled OK (python, jupyter_ai)
Are there more extensions that enables chat UI?
Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! :hugs:
If you haven't done so already, check out Jupyter's Code of Conduct. Also, please try to follow the issue template as it helps other other community members to contribute more effectively.
You can meet the other Jovyans by joining our Discourse forum. There is also an intro thread there where you can stop by and say Hi! :wave:
Welcome to the Jupyter community! :tada:
Hoping this one gets fixed in upcoming release(s). Not sure how to or if possible to connect to custom Azure OpenAI instance without this.
My k8s hub instance on reports this in the pod log:
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ChatUser
initials
none is not an allowed value (type=type_error.none.not_allowed)
2023-11-10 14:53:37,802 - ServerApp - ERROR - Uncaught exception GET /user/xxx1/api/ai/chats?token=xxx (10.240.0.62)
HTTPServerRequest(protocol='https', host='xxx, method='GET', uri='/user/xxx/api/ai/chats?token=xxx', version='HTTP/1.1', remote_ip='10.240.0.62')
Traceback (most recent call last):
File "/opt/conda/lib/python3.11/site-packages/tornado/websocket.py", line 937, in _accept_connection
open_result = handler.open(*handler.open_args, **handler.open_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/jupyter_ai/handlers.py", line 154, in open
current_user = self.get_chat_user().dict()
^^^^^^^^^^^^^^^^^^^^
File "/opt/conda/lib/python3.11/site-packages/jupyter_ai/handlers.py", line 133, in get_chat_user
return ChatUser(**chat_user_kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "pydantic/main.py", line 341, in pydantic.main.BaseModel.__init__
pydantic.error_wrappers.ValidationError: 1 validation error for ChatUser
initials
none is not an allowed value (type=type_error.none.not_allowed)
First off, a huge thanks for developing such a fantastic tool 🤗. It's been incredibly useful for our team, reducing the initial barriers at the start of projects and providing a great jumpstart.
Previously, our Chat UI in JupyterHub was working seamlessly with jupyter-ai v2.14, allowing us to use Azure OpenAI without any problems. However, following a server upgrade and the installation of the latest version, jupyter-ai v2.15, although the Chat UI reappeared, the dropdown menu for language models no longer included OpenAI or Azure OpenAI options. After applying the solution provided here, we installed langchain-openai. But, we now encounter an issue where JupyterHub fails to spawn servers for users, which is similar to the problem described here.
@triinity2221 I'm sorry to hear that you encountered a regression! Our team is not familiar with JupyterHub operation, so I will need some more information to help.
Can you share a quick list of commands to run in a new Python environment to reproduce your setup? References to upstream docs would also be helpful.
@dlqqq - we have a python-3.8.16 environment and we have installed jupyterhub through pip by pip install jupyterhub. Below is the output of pip freeze on our setup.
requirements.txt
there are no ready logs available for the jupyterhub server, we are looking into ways if we can generate one, will share it here if I get hands on it.
Thanks
I installed jupyterhub on an old linux desktop using conda and it works as expected with jupyter-ai, but this is preliminary. Just dropping off the screen shot and the console trace pending more investigation.
@dlqqq , @srdas - it must have been some setup issue at our end, after fresh installation and version management of some already existing packages, the ChatUI is back again.
But now we are facing below error when we trying to use azure openai, even though all the required credentials are set from the UI
`Sorry, an error occurred. Details below:
Traceback (most recent call last):
File "/data1/jupyterhub_new/lib/python3.8/site-packages/jupyter_ai/chat_handlers/base.py", line 125, in on_message
await self.process_message(message)
File "/data1/jupyterhub_new/lib/python3.8/site-packages/jupyter_ai/chat_handlers/default.py", line 60, in process_message
self.get_llm_chain()
File "/data1/jupyterhub_new/lib/python3.8/site-packages/jupyter_ai/chat_handlers/base.py", line 215, in get_llm_chain
self.create_llm_chain(lm_provider, lm_provider_params)
File "/data1/jupyterhub_new/lib/python3.8/site-packages/jupyter_ai/chat_handlers/default.py", line 30, in create_llm_chain
llm = provider(**unified_parameters)
File "/data1/jupyterhub_new/lib/python3.8/site-packages/jupyter_ai_magics/providers.py", line 322, in init
super().init(*args, **kwargs, **model_kwargs)
File "/data1/jupyterhub_new/lib/python3.8/site-packages/pydantic/v1/main.py", line 339, in init
values, fields_set, validation_error = validate_model(pydantic_self.class, data)
File "/data1/jupyterhub_new/lib/python3.8/site-packages/pydantic/v1/main.py", line 1100, in validate_model
values = validator(cls_, values)
File "/data1/jupyterhub_new/lib/python3.8/site-packages/langchain_openai/chat_models/azure.py", line 202, in validate_environment
values["client"] = openai.AzureOpenAI(
File "/data1/jupyterhub_new/lib/python3.8/site-packages/openai/lib/azure.py", line 169, in init
raise OpenAIError(
openai.OpenAIError: Missing credentials. Please pass one of api_key, azure_ad_token, azure_ad_token_provider, or the AZURE_OPENAI_API_KEY or AZURE_OPENAI_AD_TOKEN environment variables.
`
Seems like the AZURE_OPENAI_API_KEY set from the UI isn't getting passed on. Although I can view it in the jupyter_ai/config.json
@triinity2221 This issue is due to an upstream change to the Azure OpenAI provider in LangChain. There is some discussion about this issue in this PR: https://github.com/jupyterlab/jupyter-ai/pull/722
I will take some time to investigate this now for you and see if I can include a patch in the minor release planned for today.