xIPnexxIPnex

source-sdk

一句话

让平台主动到你家的飞书空间、SharePoint、Notion、SVN、自家文档系统里周期性拉数据,自动入知识库—— 不用人工上传,不用人工点同步。

安装

发邮件要包

info@nox-lumen.com 申请 ragbase-source-sdk

pip install ragbase-source-sdk

五分钟例子

ragbase-cli init source my-sharepoint
cd my-sharepoint
vi src/my_sharepoint/main.py
from ragbase.source_sdk import Source, source_action
 
class SharePointSource(Source):
    @source_action(name="list_documents")
    def list_documents(self, ctx, since=None):
        token = ctx.credentials["sp_token"]
        # 调你家 SharePoint API 列文件
        for doc in self.list_changed_since(since, token):
            yield {
                "doc_id": doc.id,
                "title": doc.title,
                "uri": doc.url,
                "mtime": doc.modified,
            }
 
    @source_action(name="fetch_document")
    def fetch_document(self, ctx, doc_id: str):
        token = ctx.credentials["sp_token"]
        return ctx.fetch_binary(self.download_url(doc_id, token))

平台运行时按你设的频率(cron)调 list_documents只拉变化过的给 parser 加工,落 ES。

跟 channels 的边界

  • source = 数据单向流入知识库(SharePoint → KB)
  • channel = 双向对话通道(飞书机器人收发消息)

混了走 channel-sdk 也能拉数据,但走 source-sdk 在生命周期、凭据隔离、增量同步上更对路。

行业例子

行业source 点子
汽车持续从 DOORS Next 拉需求;从 Polarion 拉缺陷库
制造从 MES 拉工单流水;从内部 SVN 拉工艺文档
办公接 Notion / Confluence / 自研 Wiki

相关

On this page