과제 소개
LLAMA INDEX와 노션 API를 활용해서 노션 DATA를 바탕으로 RAG 시스템 구축을 해본다.
지난 "지피터스 11기의 모든것" 데이터를 바탕으로 RAG 시스템을 구축해본다.
목적
노션 API를 활용하여 노션 데이터를 로딩을 해본다.
FAQ, 사용자들이 질문할법한 데이터를 넣어서 효과가 있을지 확인
RAG 답변의 퀄리티 확인
추후 AI 스터디에서 필요한 RAG 구축에 활용하기 위함
방법론
LLAMA INDEX, NOTION API, OPENAI API를 활용
빠른 POC를 위해 COLAB에서 진행
먼저 NOTION API부터 세팅을 진행합니다.
https://hirlawldo.tistory.com/192
-> 이 사이트를 참고해서 세팅 진행함
https://www.notion.so/profile/integrations
노션 시크릿 키를 발급 받습니다!
Gifters라는 단어가 포함된 페이지의 스크린샷
개인 노션에 원하는 페이지를 만들고, 그 페이지의 번호를 확인합니다.
https://www.notion.so/AI-11-0acec37d48b34b20b5075b730203c5ed
-> 이런 사이트 주소가 있다면
0acec37d48b34b20b5075b730203c5ed -> 이게 페이지 id 번호를 뜻합니다.
노션 페이지에 가서 연결항목에 내가 만든 GPTERS API를 선택해서 넣어줍니다. -> 중요
맥 OS X
%pip install llama-index-readers-notion
import logging
import sys
logging.basicConfig(stream=sys.stdout, level=logging.INFO)
logging.getLogger().addHandler(logging.StreamHandler(stream=sys.stdout))If you're opening this Notebook on colab, you will probably need to install LlamaIndex 🦙.
!pip install llama-indexfrom llama_index.core import SummaryIndex
from llama_index.readers.notion import NotionPageReader
from IPython.display import Markdown, display
import os
integration_token = "노션 시크릿 키 넣기"
page_ids = ["페이지 id 번호 넣기"]
documents = NotionPageReader(integration_token=integration_token).load_data(
page_ids=page_ids
)
index = SummaryIndex.from_documents(documents)
print(index)
print(documents[0].text)로딩된 노션 데이터
한국어 화면의 스크린샷