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

As of openai>=1.0.0, Azure endpoints should be specified via the azure_endpoint param not openai_api_base #734

Closed
MarcSkovMadsen opened this issue Apr 16, 2024 · 2 comments · Fixed by #722
Labels
bug Something isn't working

Comments

@MarcSkovMadsen
Copy link

MarcSkovMadsen commented Apr 16, 2024

Description

I'm trying to upgrade jupyter-ai from 2.4.0 to 2.13.0 on our JupyterHub. We are using it with Azure Open AI LLMs.

Reproduce

The below describes how I've reproduced the issue on my windows laptop. Not our JupyterHub.

  • Create and activate an new Python 3.11 environment
  • pip install jupyter-ai==2.13.0 jupyter-ai-magics==2.13.0 langchain-openai==0.1.3 jupyterlab==4.1.6
  • remove the jupyter_ai folder containing the existing config.json file: `rm -rf 'C:\Users\USER\AppData\Roaming\jupyter\jupyter_ai'
  • jupyter lab
  • Open Jupyter lab
  • Open Jupyter-AI in sidebar and configure the llm

image

  • Say 'Hi' in the chat

image

Traceback (most recent call last):
  File "C:\repos\tmp\.venv\Lib\site-packages\jupyter_ai\chat_handlers\base.py", line 125, in on_message
    await self.process_message(message)
  File "C:\repos\tmp\.venv\Lib\site-packages\jupyter_ai\chat_handlers\default.py", line 60, in process_message
    self.get_llm_chain()
  File "C:\repos\tmp\.venv\Lib\site-packages\jupyter_ai\chat_handlers\base.py", line 215, in get_llm_chain
    self.create_llm_chain(lm_provider, lm_provider_params)
  File "C:\repos\tmp\.venv\Lib\site-packages\jupyter_ai\chat_handlers\default.py", line 30, in create_llm_chain
    llm = provider(**unified_parameters)
          ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
  File "C:\repos\tmp\.venv\Lib\site-packages\jupyter_ai_magics\providers.py", line 293, in __init__
    super().__init__(*args, **kwargs, **model_kwargs)
  File "C:\repos\tmp\.venv\Lib\site-packages\langchain_core\load\serializable.py", line 120, in __init__
    super().__init__(**kwargs)
  File "C:\repos\tmp\.venv\Lib\site-packages\pydantic\v1\main.py", line 341, in __init__
    raise validation_error
pydantic.v1.error_wrappers.ValidationError: 1 validation error for AzureChatOpenAIProvider
__root__
  As of openai>=1.0.0, Azure endpoints should be specified via the `azure_endpoint` param not `openai_api_base` (or alias `base_url`). (type=value_error)

Context

  • Operating System and version: Windows 10 Enterprise Version 22H2
  • Browser and version: Edge
  • JupyterLab version: 4.1.6
Troubleshoot Output
$ jupyter troubleshoot

[notice] A new release of pip is available: 23.1.2 -> 24.0
[notice] To update, run: python.exe -m pip install --upgrade pip
$PATH:
C
C:\repos\tmp.venv\Scripts
H:\bin
C:\Program Files\Git\mingw64\bin
C:\Program Files\Git\usr\local\bin
C:\Program Files\Git\usr\bin
C:\Program Files\Git\usr\bin
C:\Program Files\Git\mingw64\bin
C:\Program Files\Git\usr\bin
H:\bin
C:\Program Files\Python311\Scripts
C:\Program Files\Python311
C:\Program Files (x86)\Common Files\Oracle\Java\javapath
C:\ProgramData\Oracle\Java\javapath
C:\Program Files (x86)\Microsoft SDKs\Azure\CLI2\wbin
C:\oracle\product\11.2.0.4\client_x64\bin
C:\WINDOWS\CCM
C:\WINDOWS\system32
C:\WINDOWS
C:\WINDOWS\System32\Wbem
C:\WINDOWS\System32\WindowsPowerShell\v1.0
C:\WINDOWS\System32\OpenSSH
C:\WINDOWS\system32\config\systemprofile\AppData\Local\Microsoft\WindowsApps
C:\Program Files\Azure Data Studio\bin
C:\Program Files\Pandoc
C:\Program Files\Microsoft SQL Server\150\Tools\Binn
C:\Program Files\Microsoft SQL Server\Client SDK\ODBC\170\Tools\Binn
C:\Program Files\dotnet
C:\Helm
C:\Program Files\Git\cmd
C:\Program Files\Microsoft VS Code\bin
C:\Program Files (x86)\Microsoft SQL Server\160\DTS\Binn
C:\Program Files\nodejs
C:\Program Files (x86)\JetBrains\PyCharm 2023.1.2\bin
C:\WINDOWS\system32\config\systemprofile\AppData\Roaming\npm
C:\Program Files (x86)\Adaptiva\AdaptivaClient\bin\x32
C:\Program Files (x86)\Adaptiva\AdaptivaClient\bin\x64
C:\Program Files\Docker\Docker\resources\bin
C:\Users\USER\AppData\Local\Microsoft\WindowsApps
C:\Users\USER\AppData\Local\Programs\Microsoft VS Code\bin
C:\Program Files\Git\usr\bin\vendor_perl
C:\Program Files\Git\usr\bin\core_perl
C:\Program Files\Python39

sys.path:
C:\repos\tmp.venv\Scripts\jupyter-troubleshoot.EXE
C:\Program Files\Python311\python311.zip
C:\Program Files\Python311\DLLs
C:\Program Files\Python311\Lib
C:\Program Files\Python311
C:\repos\tmp.venv
C:\repos\tmp.venv\Lib\site-packages
C:\repos\tmp.venv\Lib\site-packages\win32
C:\repos\tmp.venv\Lib\site-packages\win32\lib
C:\repos\tmp.venv\Lib\site-packages\Pythonwin

sys.executable:
C:\repos\tmp.venv\Scripts\python.exe

sys.version:
3.11.4 (tags/v3.11.4:d2340ef, Jun 7 2023, 05:45:37) [MSC v.1934 64 bit (AMD64)]

platform.platform():
Windows-10-10.0.19045-SP0

where jupyter:
C:\repos\tmp.venv\Scripts\jupyter.exe

pip list:
Package Version
------------------------- --------------
aiohttp 3.9.4
aiosignal 1.3.1
aiosqlite 0.20.0
annotated-types 0.6.0
anyio 4.3.0
argon2-cffi 23.1.0
argon2-cffi-bindings 21.2.0
arrow 1.3.0
asttokens 2.4.1
async-lru 2.0.4
attrs 23.2.0
Babel 2.14.0
beautifulsoup4 4.12.3
bleach 6.1.0
certifi 2024.2.2
cffi 1.16.0
charset-normalizer 3.3.2
click 8.1.7
cloudpickle 3.0.0
colorama 0.4.6
comm 0.2.2
dask 2024.4.1
dataclasses-json 0.6.4
debugpy 1.8.1
decorator 5.1.1
deepmerge 1.1.1
defusedxml 0.7.1
distributed 2024.4.1
distro 1.9.0
executing 2.0.1
faiss-cpu 1.8.0
fastjsonschema 2.19.1
fqdn 1.5.1
frozenlist 1.4.1
fsspec 2024.3.1
greenlet 3.0.3
h11 0.14.0
httpcore 1.0.5
httpx 0.27.0
idna 3.7
importlib_metadata 7.1.0
ipykernel 6.29.4
ipython 8.23.0
isoduration 20.11.0
jedi 0.19.1
Jinja2 3.1.3
json5 0.9.25
jsonpatch 1.33
jsonpath-ng 1.6.1
jsonpointer 2.4
jsonschema 4.21.1
jsonschema-specifications 2023.12.1
jupyter_ai 2.13.0
jupyter_ai_magics 2.13.0
jupyter_client 8.6.1
jupyter_core 5.7.2
jupyter-events 0.10.0
jupyter-lsp 2.2.5
jupyter_server 2.14.0
jupyter_server_terminals 0.5.3
jupyterlab 4.1.6
jupyterlab_pygments 0.3.0
jupyterlab_server 2.26.0
langchain 0.1.16
langchain-community 0.0.33
langchain-core 0.1.43
langchain-openai 0.1.3
langchain-text-splitters 0.0.1
langsmith 0.1.48
locket 1.0.0
MarkupSafe 2.1.5
marshmallow 3.21.1
matplotlib-inline 0.1.7
mistune 3.0.2
msgpack 1.0.8
multidict 6.0.5
mypy-extensions 1.0.0
nbclient 0.10.0
nbconvert 7.16.3
nbformat 5.10.4
nest-asyncio 1.6.0
notebook_shim 0.2.4
numpy 1.26.4
openai 1.20.0
orjson 3.10.1
overrides 7.7.0
packaging 23.2
pandocfilters 1.5.1
parso 0.8.4
partd 1.4.1
pip 23.1.2
platformdirs 4.2.0
ply 3.11
prometheus_client 0.20.0
prompt-toolkit 3.0.43
psutil 5.9.8
pure-eval 0.2.2
pycparser 2.22
pydantic 2.7.0
pydantic_core 2.18.1
Pygments 2.17.2
python-dateutil 2.9.0.post0
python-json-logger 2.0.7
pywin32 306
pywinpty 2.0.13
PyYAML 6.0.1
pyzmq 26.0.0
referencing 0.34.0
regex 2023.12.25
requests 2.31.0
rfc3339-validator 0.1.4
rfc3986-validator 0.1.1
rpds-py 0.18.0
Send2Trash 1.8.3
setuptools 65.5.0
six 1.16.0
sniffio 1.3.1
sortedcontainers 2.4.0
soupsieve 2.5
SQLAlchemy 2.0.29
stack-data 0.6.3
tblib 3.0.0
tenacity 8.2.3
terminado 0.18.1
tiktoken 0.6.0
tinycss2 1.2.1
toolz 0.12.1
tornado 6.4
tqdm 4.66.2
traitlets 5.14.2
types-python-dateutil 2.9.0.20240316
typing_extensions 4.11.0
typing-inspect 0.9.0
uri-template 1.3.0
urllib3 2.2.1
wcwidth 0.2.13
webcolors 1.13
webencodings 0.5.1
websocket-client 1.7.0
yarl 1.9.4
zict 3.0.0
zipp 3.18.1

Command Line Output
$ jupyter lab
[I 2024-04-16 19:48:05.488 ServerApp] jupyter_ai | extension was successfully linked.
[I 2024-04-16 19:48:05.488 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2024-04-16 19:48:05.500 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2024-04-16 19:48:05.514 ServerApp] jupyterlab | extension was successfully linked.
[I 2024-04-16 19:48:05.548 ServerApp] notebook_shim | extension was successfully linked.
[I 2024-04-16 19:48:05.816 ServerApp] notebook_shim | extension was successfully loaded.
[I 2024-04-16 19:48:05.820 AiExtension] Configured provider allowlist: None
[I 2024-04-16 19:48:05.821 AiExtension] Configured provider blocklist: None
[I 2024-04-16 19:48:05.821 AiExtension] Configured model allowlist: None
[I 2024-04-16 19:48:05.821 AiExtension] Configured model blocklist: None
[I 2024-04-16 19:48:05.822 AiExtension] Configured model parameters: {}
[I 2024-04-16 19:48:05.855 AiExtension] Registered model provider `ai21`.
[I 2024-04-16 19:48:05.856 AiExtension] Registered model provider `bedrock`.
[I 2024-04-16 19:48:05.856 AiExtension] Registered model provider `bedrock-chat`.
[W 2024-04-16 19:48:05.859 AiExtension] Unable to load model provider `anthropic`. Please install the `langchain_anthropic` package.
[W 2024-04-16 19:48:05.861 AiExtension] Unable to load model provider `anthropic-chat`. Please install the `langchain_anthropic` package.
[I 2024-04-16 19:48:06.343 AiExtension] Registered model provider `azure-chat-openai`.
[I 2024-04-16 19:48:06.344 AiExtension] Registered model provider `cohere`.
[W 2024-04-16 19:48:06.346 AiExtension] Unable to load model provider `gemini`. Please install the `langchain_google_genai` package.
[I 2024-04-16 19:48:06.346 AiExtension] Registered model provider `gpt4all`.
[I 2024-04-16 19:48:06.347 AiExtension] Registered model provider `huggingface_hub`.
[W 2024-04-16 19:48:06.349 AiExtension] Unable to load model provider `nvidia-chat`. Please install the `langchain_nvidia_ai_endpoints` package.
[I 2024-04-16 19:48:06.349 AiExtension] Registered model provider `openai`.
[I 2024-04-16 19:48:06.350 AiExtension] Registered model provider `openai-chat`.
[I 2024-04-16 19:48:06.350 AiExtension] Registered model provider `qianfan`.
[I 2024-04-16 19:48:06.350 AiExtension] Registered model provider `sagemaker-endpoint`.
[I 2024-04-16 19:48:06.350 AiExtension] Registered model provider `togetherai`.
[I 2024-04-16 19:48:06.383 AiExtension] Registered embeddings model provider `bedrock`.
[I 2024-04-16 19:48:06.384 AiExtension] Registered embeddings model provider `cohere`.
[I 2024-04-16 19:48:06.384 AiExtension] Registered embeddings model provider `gpt4all`.
[I 2024-04-16 19:48:06.384 AiExtension] Registered embeddings model provider `huggingface_hub`.
[I 2024-04-16 19:48:06.385 AiExtension] Registered embeddings model provider `openai`.
[I 2024-04-16 19:48:06.385 AiExtension] Registered embeddings model provider `qianfan`.
[I 2024-04-16 19:48:06.392 AiExtension] Registered providers.
[I 2024-04-16 19:48:06.393 AiExtension] Registered jupyter_ai server extension
[I 2024-04-16 19:48:06.442 AiExtension] Initialized Jupyter AI server extension in 622 ms.
[I 2024-04-16 19:48:06.443 ServerApp] jupyter_ai | extension was successfully loaded.
[I 2024-04-16 19:48:06.447 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2024-04-16 19:48:06.449 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2024-04-16 19:48:06.458 LabApp] JupyterLab extension loaded from C:\repos\tmp\.venv\Lib\site-packages\jupyterlab
[I 2024-04-16 19:48:06.459 LabApp] JupyterLab application directory is C:\repos\tmp\.venv\share\jupyter\lab     
[I 2024-04-16 19:48:06.461 LabApp] Extension Manager is 'pypi'.
[I 2024-04-16 19:48:06.480 ServerApp] jupyterlab | extension was successfully loaded.
[I 2024-04-16 19:48:06.482 ServerApp] Serving notebooks from local directory: C:\repos\tmp
[I 2024-04-16 19:48:06.483 ServerApp] Jupyter Server 2.14.0 is running at:
[I 2024-04-16 19:48:06.483 ServerApp] http://localhost:8888/lab?token=2efa0ef313896cb0405dd71ef65e48307f825d28f8e36ccd
[I 2024-04-16 19:48:06.483 ServerApp]     http://127.0.0.1:8888/lab?token=2efa0ef313896cb0405dd71ef65e48307f825d28f8e36ccd
[I 2024-04-16 19:48:06.484 ServerApp] Use Control-C to stop this server and shut down all kernels (twice to skip confirmation).
[C 2024-04-16 19:48:09.879 ServerApp] 
To access the server, open this file in a browser:
    file:///C:/Users/USER/AppData/Roaming/jupyter/runtime/jpserver-11784-open.html
Or copy and paste one of these URLs:
    http://localhost:8888/lab?token=2efa0ef313896cb0405dd71ef65e48307f825d28f8e36ccd
    http://127.0.0.1:8888/lab?token=2efa0ef313896cb0405dd71ef65e48307f825d28f8e36ccd

[I 2024-04-16 19:48:10.073 ServerApp] Client connected. ID: 6a0e82b224104752ad17fda7110b979b
[I 2024-04-16 19:48:10.106 ServerApp] Client connected. ID: 1d4ec6ac7e4841d2ab2d3db691bc1bea
[I 2024-04-16 19:48:10.745 ServerApp] Client connected. ID: 9d0630da69824bcca3c4a92d0389bdb2
[I 2024-04-16 19:48:11.904 ServerApp] Client connected. ID: ed0b56a04a9f4a8d8385b01e99de6007
[I 2024-04-16 19:48:15.168 ServerApp] Client connected. ID: 14c7ee7346bd4acb88aa69715fa687b0
[I 2024-04-16 19:48:15.168 ServerApp] Client disconnected. ID: 14c7ee7346bd4acb88aa69715fa687b0
Task exception was never retrieved
future: <Task finished name='Task-1136' coro=<WebSocketProtocol13.write_message..wrapper() done, defined at C:\repos\tmp.venv\Lib\site-packages\tornado\websocket.py:1086> exception=WebSocketClosedError()>
Traceback (most recent call last):
File "C:\repos\tmp.venv\Lib\site-packages\tornado\websocket.py", line 1088, in wrapper
await fut
tornado.iostream.StreamClosedError: Stream is closed

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
File "C:\repos\tmp.venv\Lib\site-packages\tornado\websocket.py", line 1090, in wrapper
raise WebSocketClosedError()
tornado.websocket.WebSocketClosedError
[I 2024-04-16 19:48:15.801 ServerApp] Client connected. ID: a5fad5c427f24cffaf497c9c53da7eb3
[I 2024-04-16 19:48:16.965 ServerApp] Skipped non-installed server(s): bash-language-server, dockerfile-language-server-nodejs, javascript-typescript-langserver, jedi-language-server, julia-language-server, pyright, python-language-server, python-lsp-server, r-languageserver, sql-language-server, texlab, typescript-language-server, unified-language-server, vscode-css-languageserver-bin, vscode-html-languageserver-bin, vscode-json-languageserver-bin, yaml-language-server
[I 2024-04-16 19:48:17.120 LabApp] Build is up to date
[I 2024-04-16 19:50:48.631 AiExtension] Switching chat language model from None to azure-chat-openai:gtp3516k.
C:\repos\tmp.venv\Lib\site-packages\langchain_core\utils\utils.py:159: UserWarning: WARNING! azure_openai_api_key is not default parameter.
azure_openai_api_key was transferred to model_kwargs.
Please confirm that azure_openai_api_key is what you intended.
warnings.warn(
[E 2024-04-16 19:50:48.637 AiExtension] 1 validation error for AzureChatOpenAIProvider
root
As of openai>=1.0.0, Azure endpoints should be specified via the azure_endpoint param not openai_api_base (or alias base_url). (type=value_error)
[I 2024-04-16 19:50:48.646 ServerApp] Default chat handler resolved in 17 ms.

@MarcSkovMadsen MarcSkovMadsen added the bug Something isn't working label Apr 16, 2024
Copy link

welcome bot commented Apr 16, 2024

Thank you for opening your first issue in this project! Engagement like this is essential for open source projects! 🤗

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.
welcome
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! 👋

Welcome to the Jupyter community! 🎉

@dlqqq
Copy link
Member

dlqqq commented Apr 22, 2024

@MarcSkovMadsen Thank you! This should be closed by #722, which will be available in the next release, tentatively scheduled for Tuesday - Thursday this week.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants