{"id":1722,"date":"2026-06-12T11:21:45","date_gmt":"2026-06-12T10:21:45","guid":{"rendered":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/?p=1722"},"modified":"2026-06-12T12:43:07","modified_gmt":"2026-06-12T11:43:07","slug":"adding-ai-in-jupyter-lab","status":"publish","type":"post","link":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/?p=1722","title":{"rendered":"Adding AI in Jupyter Lab"},"content":{"rendered":"\n<p>How to have a local AI chat and agent within your Jupyter Lab? <\/p>\n\n\n\n<p>From <a href=\"https:\/\/jupyter-ai.readthedocs.io\/en\/latest\/getting-started.html\">https:\/\/jupyter-ai.readthedocs.io\/en\/latest\/getting-started.html<\/a><\/p>\n\n\n\n<p>Selected tools: <a href=\"https:\/\/jupyter-ai.readthedocs.io\/en\/latest\/getting-started.html\">jupyter-ai<\/a> + <a href=\"https:\/\/lmstudio.ai\/\">LM Studio <\/a>(as server) + <a href=\"https:\/\/docs.mistral.ai\/vibe\/code\/cli\/install-setup\">Mistral Code CLI<\/a><\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Python environment<\/h3>\n\n\n\n<p>It is mandatory to have a Python 3.12 (at least) environment:<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>conda create -y -n MyEnvAI python=3.12\nconda activate MyEnvAI \nconda install nodejs<\/code><\/pre>\n\n\n\n<p>Finalize installation with:<\/p>\n\n\n\n<p>pip install &#8211;upgrade jupyterlab jupyter-app-launcher ipywidgets jupyter-ai mistral-vibe<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Configuring vibe<\/h3>\n\n\n\n<p>It is needed to launch vibe (enter &#8220;vibe&#8221; ) in a terminal to generate the first configuration file ( ~\/.vibe\/config.toml). Select the interface you want (simply press enter) and select API key (you can enter your real API or a fake). Then just enter \/exit when <em>vibe<\/em> is working, as we first need to change the basic Mistral configuration to a local LLM.<\/p>\n\n\n\n<p>Edit the <em>config.toml<\/em> and add the following lines (adapt according to your server and model)<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>&#91;&#91;providers]]\nname = \"local\"\napi_base = \"http:\/\/XXX.XXX.XXX.XXX:1234\/v1\"\napi_key_env_var = \"your API key to your local server\"\napi_style = \"openai\"\nbackend = \"generic\"\nreasoning_field_name = \"reasoning_content\"\nproject_id = \"\"\nregion = \"\"\n\n&#91;&#91;models]]\nname = \"google\/gemma-4-31b\"\nprovider = \"local\"\nalias = \"gemma4-local\"\nthinking = \"off\"\n<\/code><\/pre>\n\n\n\n<p>Also, in the same file, change the &#8220;active_model&#8221; to your model alias. With the previous example, it will be :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>active_model = \"gemma4-local\"<\/code><\/pre>\n\n\n\n<p>Test vibe<\/p>\n\n\n\n<p>Just enter vibe, select the interface (type <em>enter<\/em>), and add your API key. Launch vibe again. You should get something like :<\/p>\n\n\n\n<figure class=\"wp-block-image size-full wp-duotone-unset-1\"><img loading=\"lazy\" decoding=\"async\" width=\"659\" height=\"244\" src=\"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image.png\" alt=\"\" class=\"wp-image-1726\" srcset=\"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image.png 659w, https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-300x111.png 300w\" sizes=\"auto, (max-width: 659px) 100vw, 659px\" \/><\/figure>\n\n\n\n<p>If you enter &#8220;test&#8221;, your local LLM should run and respond to you. Enter \/exit to exit the <em>vibe <\/em>interface.<\/p>\n\n\n\n<h3 class=\"wp-block-heading\">Test on Jupyter Lab<\/h3>\n\n\n\n<p>launch jupyter lab. And create a new chat:<\/p>\n\n\n\n<figure class=\"wp-block-image size-full wp-duotone-unset-2\"><img loading=\"lazy\" decoding=\"async\" width=\"1003\" height=\"556\" src=\"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-2.png\" alt=\"\" class=\"wp-image-1728\" srcset=\"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-2.png 1003w, https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-2-300x166.png 300w, https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-2-768x426.png 768w\" sizes=\"auto, (max-width: 1003px) 100vw, 1003px\" \/><\/figure>\n\n\n\n<p>Start your prompt invoking the agent with &#8216;@&#8217; as :<\/p>\n\n\n\n<pre class=\"wp-block-code\"><code>@Mistral-Vibe How do I integrate metricsreloaded in 01_UNET_TF2_test.ipynb to assess the segmentation quality ?\n<\/code><\/pre>\n\n\n\n<figure class=\"wp-block-image size-large wp-duotone-unset-3\"><img loading=\"lazy\" decoding=\"async\" width=\"882\" height=\"1024\" src=\"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-3-882x1024.png\" alt=\"\" class=\"wp-image-1731\" srcset=\"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-3-882x1024.png 882w, https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-3-259x300.png 259w, https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-3-768x891.png 768w, https:\/\/www.creatis.insa-lyon.fr\/~grenier\/wp-content\/uploads\/image-3.png 954w\" sizes=\"auto, (max-width: 882px) 100vw, 882px\" \/><\/figure>\n","protected":false},"excerpt":{"rendered":"<p>How to have a local AI chat and agent within your Jupyter Lab? From https:\/\/jupyter-ai.readthedocs.io\/en\/latest\/getting-started.html Selected tools: jupyter-ai + LM Studio (as server) + Mistral Code CLI Python environment It is mandatory to have a Python 3.12 (at least) environment: Finalize installation with: pip install &#8211;upgrade jupyterlab jupyter-app-launcher ipywidgets jupyter-ai mistral-vibe Configuring vibe It is [&hellip;]<\/p>\n","protected":false},"author":2,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":{"footnotes":""},"categories":[5,4,13],"tags":[],"class_list":["post-1722","post","type-post","status-publish","format-standard","hentry","category-computer-science","category-teaching","category-tips-and-tricks"],"_links":{"self":[{"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=\/wp\/v2\/posts\/1722","targetHints":{"allow":["GET"]}}],"collection":[{"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=\/wp\/v2\/users\/2"}],"replies":[{"embeddable":true,"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=%2Fwp%2Fv2%2Fcomments&post=1722"}],"version-history":[{"count":7,"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=\/wp\/v2\/posts\/1722\/revisions"}],"predecessor-version":[{"id":1735,"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=\/wp\/v2\/posts\/1722\/revisions\/1735"}],"wp:attachment":[{"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=%2Fwp%2Fv2%2Fmedia&parent=1722"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=%2Fwp%2Fv2%2Fcategories&post=1722"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/www.creatis.insa-lyon.fr\/~grenier\/index.php?rest_route=%2Fwp%2Fv2%2Ftags&post=1722"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}