# Jupyter AI Labs 사용하기

<figure><img src="/files/ieZp0ne7Ck0tmSRLnj9g" alt=""><figcaption></figcaption></figure>

{% hint style="info" %} <mark style="color:red;">**Jupyter AI란?**</mark>

Jupyter AI는 Jupyter notebook에서 생성 AI를 편하게 사용할 수 있는 환경을 제공하는 \
확장 프로그램입니다.
{% endhint %}

**Jupyter AI를 사용하면?**

✔️Jupyter notebook 커널에서 생성형 인공지능 모델을 통한 코드 생성

✔️Jupyter Lab 내 채팅 UI를 통해 생성형 인공지능과 대화

✔️OpenAI를 비롯하여 Hugging Face, Gemini 등 다양한 생성 모델 사용

**runyourAI가 제공하는&#x20;**<mark style="background-color:yellow;">**템플릿 기능**</mark>**을 통해 Jupyter AI 을 지금 바로 이용해보세요!**

***

## Step 1. 머신 대여 및 템플릿 선택

<figure><img src="/files/Imcmoz76Qxi4RNBAsIgk" alt=""><figcaption></figcaption></figure>

* GPU Cloud 목록에서 원하는 머신 선택하면 템플릿 선택 단계로 이동합니다. \
  jupyter-AI-Labs 템플릿을 선택하고 상단의 대여 버튼을 클릭합니다.
* 대여한 머신은  <mark style="background-color:yellow;">마이페이지>대시보드</mark>에서 확인할 수 있습니다.

***

## Step 2. Jupyter Lab WebUI 접속

<figure><img src="/files/gpv9U76FMkMR4bRJFP9X" alt=""><figcaption></figcaption></figure>

* 대여한 머신을 클릭하면, SSH / Web UI 접속 기능과 PEM 키 다운로드 기능을 확인할 수 있습니다.

<figure><img src="/files/ywrbcLsOblVBhHWANZP8" alt=""><figcaption></figcaption></figure>

* 두 가지의 버튼 중 SSH / WEB 버튼을 클릭합니다.

<figure><img src="/files/1rB8PPVKa1eYDFRq51Hc" alt=""><figcaption></figcaption></figure>

두 가지의 접속 방법 중, 'HTTP' > 'Jupyter Lab' 버튼을 클릭해 Web UI에 직접 접속합니다.

*(SSH 접속은*[ *'SSH 활용하여 원격접속하기'*](/userguide/tutorial/ssh.md)*를 참고해주세요.)*

## Step 3. Jupyter AI를 통해 OpenAI API 활용하기

### 1. 사용할 Jupyter Notebook 생성&#x20;

화면에 <mark style="color:red;">**Notebook > Python 3**</mark> 버튼을 클릭하여 새로운 노트북 파일을 생성합니다.

<figure><img src="/files/pXvZ4AaT5MwIz1z01GUn" alt=""><figcaption></figcaption></figure>

### 2. 노트북 파일에 아래 코드를 입력합니다.

```python
%reload_ext jupyter_ai
```

### 3. OpenAI에서 발급받은 Key를 입력합니다.

```python
import os
os.environ['OPENAI_API_KEY']='발급받은 키 값 작성'
```

### 4.아래 코드를 활용하여 Chat GPT를 사용할 수 있습니다.

{% hint style="warning" %}
생성 결과는 ChatGPT의 답변에 따라 다를 수 있습니다.
{% endhint %}

1. Line Graph 생성 예시

```
%%ai chatgpt --format code
Demonstrate how to plot a line graph based on a pandas dataset, including sample data
```

* **실행 결과** <br>

  <figure><img src="/files/axaIr8h5EPrJtiSFM26W" alt=""><figcaption></figcaption></figure>

2. Scatter Graph 생성 예시

```
%%ai chatgpt --format code
Demonstrate how to plot a scatter graph based on a pandas dataset, including sample data
```

* **실행 결과**&#x20;

<figure><img src="/files/yLi1fSAaxbey0csKIJcO" alt=""><figcaption></figcaption></figure>

* **실행 결과**&#x20;

  <figure><img src="/files/axaIr8h5EPrJtiSFM26W" alt=""><figcaption></figcaption></figure>


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://runyourai.gitbook.io/userguide/tutorial/jupyterai.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
