

本文為英文版的機器翻譯版本，如內容有任何歧義或不一致之處，概以英文版為準。

# Jupyter AI 安裝
<a name="sagemaker-jupyterai-installation"></a>

若要使用 Jupyter AI，您必須先安裝 Jupyter AI 套件。對於 [Amazon SageMaker AI Distribution](https://github.com/aws/sagemaker-distribution/tree/main/build_artifacts/v1) 使用者，我們建議您選取 SageMaker Distribution 映像 1.2 版或更新版本。不需要進一步安裝。Studio 中的 JupyterLab 使用者可以在建立空間時選擇其 Amazon SageMaker Distribution 的版本。

對於其他 IPython 環境的使用者，建議的 Jupyter AI 套件版本取決於他們正在使用的 JupyterLab 版本。

Jupyter AI Distribution 包含兩個套件。
+ `jupyter_ai`：此套件提供 JupyterLab 延伸模組和原生聊天使用者介面 (UI)。它使用您選擇的大型語言模型做為對話助理。
+ `jupyter_ai_magics`：此套件提供 IPython `%%ai` 和 `%ai` 魔術命令，您可以使用這些命令，從筆記本儲存格調用大型語言模型 (LLM)。

**注意**  
安裝 `jupyter_ai` 也會安裝 `jupyter_ai_magics`。不過，您可以在沒有 JupyterLab 或 `jupyter_ai` 的情況下獨立安裝 `jupyter_ai_magics`。魔術命令 `%%ai` 和 `%ai` 可在任何 IPython 核心環境中運作。如果您只安裝 `jupyter_ai_magics`，則無法使用聊天 UI。

對於 JupyterLab 3 的使用者，特別是 Studio Classic 使用者，我們建議您安裝 `jupyter-ai` [1.5.x 版](https://pypi.org/project/jupyter-ai/#history)或任何更新的 1.x 版。不過，我們強烈建議搭配 JupyterLab 4 使用 Jupyter AI。與 JupyterLab 3 相容的 `jupyter-ai` 版本可能不允許使用者設定其他模型參數，例如溫度、top-k 和 top-p 取樣、字符數上限或長度上限，或使用者接受授權合約。

對於不使用 SageMaker Distribution 的 JupyterLab 4 環境使用者，我們建議安裝 `jupyter-ai` [2.5.x 版](https://pypi.org/project/jupyter-ai/#history)或任何更新的 2.x 版。

請參閱 [Jupyter AI 文件](https://jupyter-ai.readthedocs.io/en/latest/users/index.html#installation-via-pip)的*安裝*一節中的指示。