python:jupyterlab:jupyter_ai

文書の過去の版を表示しています。


Jupyter AI - JupyterLab の生成 AI 拡張機能

公式: Installation - Users — Jupyter AI documentation 翻訳

$ pipx inject jupyterlab jupyter-ai

or Python モジュールをビルドなしのバイナリオンリーでインストールしたい場合🤔

$ pipx inject jupyterlab jupyter-ai --pip-args='--only-binary=:all:'

  injected package jupyter-ai into venv jupyterlab
done! ✨ 🌟 ✨

モデル プロバイダーに応じて以下の Python モジュールをインストールする🤔

$ pipx inject jupyterlab ai21 anthropic boto3 cohere qianfan langchain-google-genai gpt4all huggingface_hub ipywidgets pillow langchain_nvidia_ai_endpoints openai

ipywidgets pillow langchain_nvidia_ai_endpoints openai
  injected package ai21 into venv jupyterlab
done! ✨ 🌟 ✨
  injected package anthropic into venv jupyterlab
done! ✨ 🌟 ✨
  injected package boto3 into venv jupyterlab
done! ✨ 🌟 ✨
  injected package cohere into venv jupyterlab
done! ✨ 🌟 ✨
  injected package qianfan into venv jupyterlab
done! ✨ 🌟 ✨
  injected package langchain-google-genai into venv jupyterlab
done! ✨ 🌟 ✨
  injected package gpt4all into venv jupyterlab
done! ✨ 🌟 ✨
  injected package huggingface-hub into venv jupyterlab
done! ✨ 🌟 ✨
  injected package ipywidgets into venv jupyterlab
done! ✨ 🌟 ✨
  injected package pillow into venv jupyterlab
done! ✨ 🌟 ✨
  injected package langchain-nvidia-ai-endpoints into venv jupyterlab
done! ✨ 🌟 ✨
  injected package openai into venv jupyterlab
done! ✨ 🌟 ✨

Provider Provider ID Environment variable(s) Python package(s)
AI21 AI21 Labs ai21 AI21_API_KEY ai21
Anthropic anthropic ANTHROPIC_API_KEY anthropic
Anthropic (chat) anthropic-chat ANTHROPIC_API_KEY anthropic
Bedrock Amazon Bedrock bedrock N/A boto3
Bedrock (chat) bedrock-chat N/A boto3
Cohere cohere COHERE_API_KEY cohere
ERNIE-Bot Chatbot developed by Baidu qianfan QIANFAN_AK, QIANFAN_SK qianfan
Gemini gemini GOOGLE_API_KEY Get API key | Google AI Studio langchain-google-genai
GPT4All gpt4all N/A gpt4all
Hugging Face Hub huggingface_hub HUGGINGFACEHUB_API_TOKEN huggingface_hub, ipywidgets, pillow
NVIDIA NVIDIA AI nvidia-chat NVIDIA_API_KEY langchain_nvidia_ai_endpoints
OpenAI openai OPENAI_API_KEY API keys - OpenAI API openai
OpenAI (chat) openai-chat OPENAI_API_KEY openai
SageMaker Amazon SageMaker sagemaker-endpoint N/A boto3

Model providers - Users — Jupyter AI documentation より🤔

Project Jupyter is vendor-neutral, so Jupyter AI supports LLMs from AI21, Anthropic, AWS, Cohere, HuggingFace Hub, and OpenAI. More model providers will be added in the future. Please review a provider’s privacy policy and pricing model before you use it.
Project Jupyter はベンダー中立であるため、Jupyter AI は AI21、Anthropic、AWS、Cohere、HuggingFace Hub、OpenAI の LLM をサポートします。今後さらにモデルプロバイダーが追加される予定です。プロバイダーを使用する前に、プロバイダーのプライバシー ポリシーと価格モデルを確認してください。

Generative AI in Jupyter. Jupyter AI, a new open source project… | by Jason Weill | Jupyter Blog より

公式: Development install - Contributors — Jupyter AI documentation 翻訳

anyenvNode.js をインストールする🤔
JupyterLab をインストールする🤔

参考: jupyter-ai/scripts/install.sh at main · jupyterlab/jupyter-ai

$ git clone https://github.com/jupyterlab/jupyter-ai.git

Cloning into 'jupyter-ai'...
remote: Enumerating objects: 4239, done.
remote: Counting objects: 100% (957/957), done.
remote: Compressing objects: 100% (350/350), done.
remote: Total 4239 (delta 723), reused 732 (delta 591), pack-reused 3282
Receiving objects: 100% (4239/4239), 8.08 MiB | 1.56 MiB/s, done.
Resolving deltas: 100% (2766/2766), done.

$ cd jupyter-ai
$ cp playground/config.example.py playground/config.py
$ jlpm install

 YN0000: ┌ Resolution step
 YN0002: │ @jupyter-ai/core@workspace:packages/jupyter-ai doesn't provide @mui/zero-runtime (pd0dfc), requested by @mui/material
 YN0002: │ @jupyter-ai/core@workspace:packages/jupyter-ai doesn't provide yjs (pe3e33), requested by y-protocols
 YN0002: │ @jupyterlab/completer@npm:4.1.0 doesn't provide react (pcc968), requested by @jupyterlab/settingregistry
 YN0002: │ @jupyterlab/services@npm:7.1.0 doesn't provide react (p6ccbd), requested by @jupyterlab/settingregistry
 YN0002: │ @jupyterlab/testutils@npm:4.1.0 doesn't provide typescript (p0a820), requested by @jupyterlab/testing
 YN0002: │ @lerna/legacy-package-management@npm:6.6.2 doesn't provide nx (pa803c), requested by @nrwl/devkit
 YN0000: │ Some peer dependencies are incorrectly met; run yarn explain peer-requirements <hash> for details, where <hash> is the six-letter p-prefixed code
 YN0000: └ Completed in 0s 931ms
 YN0000: ┌ Fetch step
 YN0013: │ yargs-parser@npm:21.1.1 can't be found in the cache and will be fetched from the remote registry
 YN0013: │ yargs@npm:16.2.0 can't be found in the cache and will be fetched from the remote registry
 YN0013: │ yargs@npm:17.7.2 can't be found in the cache and will be fetched from the remote registry
 YN0013: │ yjs@npm:13.6.11 can't be found in the cache and will be fetched from the remote registry
 YN0013: │ yocto-queue@npm:0.1.0 can't be found in the cache and will be fetched from the remote registry
 YN0000: └ Completed in 2m 43s
 YN0000: ┌ Link step
 YN0007: │ @parcel/watcher@npm:2.0.4 must be built because it never has been before or the last one failed
 YN0007: │ @fortawesome/fontawesome-free@npm:5.15.4 must be built because it never has been before or the last one failed
 YN0007: │ leveldown@npm:5.6.0 must be built because it never has been before or the last one failed
 YN0007: │ nx@npm:15.9.7 [9d75b] must be built because it never has been before or the last one failed
 YN0000: └ Completed in 1m 1s
 YN0000: Done with warnings in 3m 46s

$ jlpm dev-install


公式: problem with the Chat backend · Issue #335 · jupyterlab/jupyter-ai 翻訳

There seems to be a problem with the Chat backend, please look at the JupyterLab server logs or contact your administrator to correct this problem.
Chat バックエンドに問題があるようです。JupyterLab サーバーのログを確認するか、管理者に連絡してこの問題を解決してください。

$ jupyter-lab --ip=0.0.0.0 --port=8888 --no-browser

[I 2024-03-12 06:29:13.731 ServerApp] ipyparallel | extension was successfully linked.
[I 2024-03-12 06:29:13.739 ServerApp] jupyter_ai | extension was successfully linked.
[I 2024-03-12 06:29:13.739 ServerApp] jupyter_lsp | extension was successfully linked.
[I 2024-03-12 06:29:13.747 ServerApp] jupyter_server_fileid | extension was successfully linked.
[I 2024-03-12 06:29:13.754 ServerApp] jupyter_server_mathjax | extension was successfully linked.
[I 2024-03-12 06:29:13.762 ServerApp] jupyter_server_terminals | extension was successfully linked.
[I 2024-03-12 06:29:13.770 ServerApp] jupyter_server_ydoc | extension was successfully linked.
[I 2024-03-12 06:29:13.779 ServerApp] jupyterlab | extension was successfully linked.
[I 2024-03-12 06:29:13.779 ServerApp] jupyterlab_git | extension was successfully linked.
[I 2024-03-12 06:29:13.779 ServerApp] nbdime | extension was successfully linked.
[I 2024-03-12 06:29:13.786 ServerApp] notebook_shim | extension was successfully linked.
[I 2024-03-12 06:29:13.825 ServerApp] notebook_shim | extension was successfully loaded.
[I 2024-03-12 06:29:13.827 ServerApp] Loading IPython parallel extension
[I 2024-03-12 06:29:13.828 ServerApp] ipyparallel | extension was successfully loaded.
[I 2024-03-12 06:29:13.829 AiExtension] Configured provider allowlist: None
[I 2024-03-12 06:29:13.829 AiExtension] Configured provider blocklist: None
[I 2024-03-12 06:29:13.829 AiExtension] Configured model allowlist: None
[I 2024-03-12 06:29:13.829 AiExtension] Configured model blocklist: None
[I 2024-03-12 06:29:13.829 AiExtension] Configured model parameters: {}
[I 2024-03-12 06:29:13.883 AiExtension] Registered model provider `ai21`.
[I 2024-03-12 06:29:13.884 AiExtension] Registered model provider `bedrock`.
[I 2024-03-12 06:29:13.884 AiExtension] Registered model provider `bedrock-chat`.
[I 2024-03-12 06:29:13.884 AiExtension] Registered model provider `anthropic`.
[I 2024-03-12 06:29:13.884 AiExtension] Registered model provider `anthropic-chat`.
[I 2024-03-12 06:29:13.884 AiExtension] Registered model provider `azure-chat-openai`.
[I 2024-03-12 06:29:13.884 AiExtension] Registered model provider `cohere`.
[I 2024-03-12 06:29:13.884 AiExtension] Registered model provider `gpt4all`.
[I 2024-03-12 06:29:13.884 AiExtension] Registered model provider `huggingface_hub`.
[I 2024-03-12 06:29:13.941 AiExtension] Registered model provider `nvidia-chat`.
[I 2024-03-12 06:29:13.941 AiExtension] Registered model provider `openai`.
[I 2024-03-12 06:29:13.941 AiExtension] Registered model provider `openai-chat`.
[I 2024-03-12 06:29:13.941 AiExtension] Registered model provider `qianfan`.
[I 2024-03-12 06:29:13.942 AiExtension] Registered model provider `sagemaker-endpoint`.
[I 2024-03-12 06:29:14.000 AiExtension] Registered embeddings model provider `bedrock`.
[I 2024-03-12 06:29:14.000 AiExtension] Registered embeddings model provider `cohere`.
[I 2024-03-12 06:29:14.000 AiExtension] Registered embeddings model provider `gpt4all`.
[I 2024-03-12 06:29:14.000 AiExtension] Registered embeddings model provider `huggingface_hub`.
[I 2024-03-12 06:29:14.000 AiExtension] Registered embeddings model provider `openai`.
[I 2024-03-12 06:29:14.000 AiExtension] Registered embeddings model provider `qianfan`.
[I 2024-03-12 06:29:14.012 AiExtension] Registered providers.
[I 2024-03-12 06:29:14.012 AiExtension] Registered jupyter_ai server extension
[W 2024-03-12 06:29:14.086 ServerApp] jupyter_ai | extension failed loading with message: ValueError('Failed to retrieve model')
    Traceback (most recent call last):
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_server/extension/manager.py", line 359, in load_extension
        extension.load_all_points(self.serverapp)
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_server/extension/manager.py", line 231, in load_all_points
        return [self.load_point(point_name, serverapp) for point_name in self.extension_points]
                ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_server/extension/manager.py", line 222, in load_point
        return point.load(serverapp)
               ^^^^^^^^^^^^^^^^^^^^^
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_server/extension/manager.py", line 150, in load
        return loader(serverapp)
               ^^^^^^^^^^^^^^^^^
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_server/extension/application.py", line 474, in _load_jupyter_server_extension
        extension.initialize()
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_server/extension/application.py", line 435, in initialize
        self._prepare_settings()
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_server/extension/application.py", line 315, in _prepare_settings
        self.initialize_settings()
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_ai/extension.py", line 238, in initialize_settings
        learn_chat_handler = LearnChatHandler(**chat_handler_kwargs)
                             ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_ai/chat_handlers/learn.py", line 66, in __init__
        self._load()
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_ai/chat_handlers/learn.py", line 70, in _load
        embeddings = self.get_embedding_model()
                     ^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_ai/chat_handlers/learn.py", line 295, in get_embedding_model
        return em_provider_cls(**em_provider_args)
               ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyter_ai_magics/embedding_providers.py", line 133, in __init__
        GPT4All.retrieve_model(model_name=model_name, allow_download=False)
      File "/home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/gpt4all/gpt4all.py", line 193, in retrieve_model
        raise ValueError("Failed to retrieve model")
    ValueError: Failed to retrieve model
[I 2024-03-12 06:29:14.093 ServerApp] jupyter_lsp | extension was successfully loaded.
[I 2024-03-12 06:29:14.093 FileIdExtension] Configured File ID manager: ArbitraryFileIdManager
[I 2024-03-12 06:29:14.093 FileIdExtension] ArbitraryFileIdManager : Configured root dir: /home/tomoyan
[I 2024-03-12 06:29:14.093 FileIdExtension] ArbitraryFileIdManager : Configured database path: /home/tomoyan/.local/share/jupyter/file_id_manager.db
[I 2024-03-12 06:29:14.094 FileIdExtension] ArbitraryFileIdManager : Successfully connected to database file.
[I 2024-03-12 06:29:14.094 FileIdExtension] ArbitraryFileIdManager : Creating File ID tables and indices with journal_mode = DELETE
[I 2024-03-12 06:29:14.094 FileIdExtension] Attached event listeners.
[I 2024-03-12 06:29:14.095 ServerApp] jupyter_server_fileid | extension was successfully loaded.
[I 2024-03-12 06:29:14.096 ServerApp] jupyter_server_mathjax | extension was successfully loaded.
[I 2024-03-12 06:29:14.097 ServerApp] jupyter_server_terminals | extension was successfully loaded.
[I 2024-03-12 06:29:14.098 ServerApp] jupyter_server_ydoc | extension was successfully loaded.
[I 2024-03-12 06:29:14.103 LabApp] JupyterLab extension loaded from /home/tomoyan/.local/share/pipx/venvs/jupyterlab/lib64/python3.12/site-packages/jupyterlab
[I 2024-03-12 06:29:14.103 LabApp] JupyterLab application directory is /home/tomoyan/.local/share/pipx/venvs/jupyterlab/share/jupyter/lab
[I 2024-03-12 06:29:14.104 LabApp] Extension Manager is 'pypi'.
[I 2024-03-12 06:29:14.142 ServerApp] jupyterlab | extension was successfully loaded.
[I 2024-03-12 06:29:14.153 ServerApp] jupyterlab_git | extension was successfully loaded.
[I 2024-03-12 06:29:14.245 ServerApp] nbdime | extension was successfully loaded.
[I 2024-03-12 06:29:14.246 ServerApp] ローカルディレクトリからノートブックをサーブ: /home/tomoyan
[I 2024-03-12 06:29:14.246 ServerApp] Jupyter Server 2.13.0 is running at:
[I 2024-03-12 06:29:14.246 ServerApp] http://highway-x.fireball.local:8888/lab
[I 2024-03-12 06:29:14.246 ServerApp]     http://127.0.0.1:8888/lab
[I 2024-03-12 06:29:14.246 ServerApp] サーバを停止し全てのカーネルをシャットダウンするには Control-C を使って下さい(確認をスキップするには2回)。
[I 2024-03-12 06:29:14.963 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
[W 2024-03-12 06:29:17.122 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 86.18ms referer=None
[W 2024-03-12 06:29:21.092 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.26ms referer=None
[W 2024-03-12 06:29:25.946 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.51ms referer=None
[W 2024-03-12 06:29:28.094 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.02ms referer=None
[W 2024-03-12 06:29:30.515 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.18ms referer=None
[W 2024-03-12 06:29:34.732 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.11ms referer=None
[W 2024-03-12 06:29:40.609 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 3.83ms referer=None
[W 2024-03-12 06:29:45.902 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.25ms referer=None
[W 2024-03-12 06:29:51.701 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 2.66ms referer=None
[W 2024-03-12 06:29:54.176 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.09ms referer=None
[W 2024-03-12 06:29:58.953 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 1.75ms referer=None
[W 2024-03-12 06:30:02.606 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 5.21ms referer=None
[W 2024-03-12 06:30:08.093 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.43ms referer=None
[W 2024-03-12 06:30:12.383 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 3.33ms referer=None
[W 2024-03-12 06:30:16.697 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 5.08ms referer=None
[W 2024-03-12 06:30:18.842 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.15ms referer=None
[W 2024-03-12 06:30:22.020 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.38ms referer=None
[W 2024-03-12 06:30:26.797 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.24ms referer=None
[W 2024-03-12 06:30:30.129 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 2.27ms referer=None
[W 2024-03-12 06:30:33.787 ServerApp] 404 GET /api/ai/chats (123d23ghj72149e89021f2dd23d6fc32@127.0.0.1) 4.49ms referer=None
^C[I 2024-03-12 06:30:34.769 ServerApp] 中断しました
[I 2024-03-12 06:30:34.769 ServerApp] ローカルディレクトリからノートブックをサーブ: /home/tomoyan
    0 個のアクティブなカーネル
    Jupyter Server 2.13.0 is running at:
    http://highway-x.fireball.local:8888/lab
        http://127.0.0.1:8888/lab
Shut down this Jupyter server (y/[n])? ^C[C 2024-03-12 06:30:35.048 ServerApp] シグナル 2 を受信。停止します
[I 2024-03-12 06:30:35.049 ServerApp] Shutting down 11 extensions
[I 2024-03-12 06:30:35.050 AiExtension] Closing Dask client.

Jupyter AI の 設定を削除して再設定する😊

$ ll ~/.local/share/jupyter/jupyter_ai

合計 8
-rw-r--r-- 1 tomoyan tomoyan  194  3月 12 06:29 config.json
-rw-r--r-- 1 tomoyan tomoyan 1216  3月  9 09:19 config_schema.json
drwxr-xr-x 1 tomoyan tomoyan    0  3月  9 09:19 indices

$ rm ~/.local/share/jupyter/jupyter_ai/config.json
$ jupyter-lab --ip=0.0.0.0 --port=8888 --no-browser

[E 2024-03-12 11:05:44.478 AiExtension] Could not load vector index from disk.

  • python/jupyterlab/jupyter_ai.1710453329.txt.gz
  • 最終更新: 2024/03/15 06:55
  • by ともやん