이 노트북은 RSpace document loader를 사용하여 RSpace Electronic Lab Notebook에서 연구 노트와 문서를 LangChain pipeline으로 가져오는 방법을 보여줍니다. 시작하려면 RSpace 계정과 API key가 필요합니다. https://community.researchspace.com에서 무료 계정을 설정하거나 소속 기관의 RSpace를 사용할 수 있습니다. RSpace API token은 계정의 프로필 페이지에서 얻을 수 있습니다.
pip install -qU  rspace_client
RSpace API key를 환경 변수로 저장하는 것이 가장 좋습니다. RSPACE_API_KEY=<YOUR_KEY> 또한 RSpace 설치의 URL을 설정해야 합니다. 예: RSPACE_URL=https://community.researchspace.com 이러한 정확한 환경 변수 이름을 사용하면 자동으로 감지됩니다.
from langchain_community.document_loaders.rspace import RSpaceLoader
RSpace에서 다양한 항목을 가져올 수 있습니다:
  • 단일 RSpace structured 또는 basic document. 이는 LangChain document와 1:1로 매핑됩니다.
  • folder 또는 notebook. notebook 또는 folder 내부의 모든 document가 LangChain document로 가져와집니다.
  • RSpace Gallery에 PDF 파일이 있는 경우, 이들도 개별적으로 가져올 수 있습니다. 내부적으로 LangChain의 PDF loader가 사용되며, 이는 PDF 페이지당 하나의 LangChain document를 생성합니다.
## replace these ids with some from your own research notes.
## Make sure to use  global ids (with the 2 character prefix). This helps the loader know which API calls to make
## to RSpace API.

rspace_ids = ["NB1932027", "FL1921314", "SD1932029", "GL1932384"]
for rs_id in rspace_ids:
    loader = RSpaceLoader(global_id=rs_id)
    docs = loader.load()
    for doc in docs:
        ## the name and ID are added to the 'source' metadata property.
        print(doc.metadata)
        print(doc.page_content[:500])
위와 같이 환경 변수를 사용하지 않으려면 RSpaceLoader에 직접 전달할 수 있습니다.
loader = RSpaceLoader(
    global_id=rs_id, api_key="MY_API_KEY", url="https://my.researchspace.com"
)

Connect these docs programmatically to Claude, VSCode, and more via MCP for real-time answers.
I