跳到主要内容
本笔记本演示了如何使用 RSpace 文档加载器将 RSpace 电子实验笔记本中的研究笔记和文档导入 LangChain 管道。 首先,您需要一个 RSpace 帐户和一个 API 密钥。 您可以在 https://community.researchspace.com 免费注册帐户,或使用您的机构 RSpace。 您可以从您的帐户资料页面获取 RSpace API 令牌。
pip install -qU  rspace_client
最好将您的 RSpace API 密钥存储为环境变量。 RSPACE_API_KEY=<YOUR_KEY> 您还需要设置您的 RSpace 安装的 URL,例如 RSPACE_URL=https://community.researchspace.com 如果您使用这些精确的环境变量名称,它们将自动被检测到。
from langchain_community.document_loaders.rspace import RSpaceLoader
您可以从 RSpace 导入各种项目
  • 单个 RSpace 结构化或基本文档。这将 1 对 1 映射到 LangChain 文档。
  • 一个文件夹或笔记本。笔记本或文件夹中的所有文档都作为 LangChain 文档导入。
  • 如果您在 RSpace Gallery 中有 PDF 文件,这些文件也可以单独导入。在底层,将使用 LangChain 的 PDF 加载器,它为每个 PDF 页面创建一个 LangChain 文档。
## 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"
)

以编程方式连接这些文档到 Claude、VSCode 等,通过 MCP 获取实时答案。
© . This site is unofficial and not affiliated with LangChain, Inc.