AI站点搜索工具

RagRabbit是一个自托管的AI站点搜索和LLM.txt生成工具,支持网站爬取、内容索引和嵌入式聊天小部件。

  • by madarco
  • TypeScript
  • 本地部署
  • 136 星标
  • 更新于
在 GitHub 查看 madarco/ragrabbit

使用说明

 RagRabbit 

自托管网站AI搜索、LLMs.txt、抓取您内容的MCP服务器。1-单击Vercel上的部署。

运作原理

RagRabbit 是一个 Next.js Turborepo 使用的应用程序 电话指数 随着 pg矢量.

特性

  • 💬 聊天小部件:嵌入式AI聊天代理和即时搜索
  • 🕸️ 网站爬虫:使用pgVector和PostgreSQL抓取和索引页面
  • 📄 LLMs.txt生成:通过ToC重新排序完全可定制
  • 🔌 MCP服务器: npx @ragrabbit/mcp 从Claude Desktop和Cursor IDE访问您的文档
  • 🛠️ 灵活:身份验证、开源、API密钥访问
  • 🚀 易于部署:在Vercel上一键设置

集成:

演示

视图 RagRabbit演示页面

安装

要在Vercel上安装:

要求:

  • Node.js 20.x
  • PostgreSQL w/pgVector
  • OpenAI API密钥
  • (可选)Trigger.dev API密钥

配置

设置以下环境变量:

  • OPENAI_API密钥

用户名/密码登录:

  • 管理员用户
  • 管理员密码

电子邮件登录:

  • RESEND_AUTH=真
  • 要限制对这些电子邮件的访问:RESEND_ALLOWED_emails=“test@test.com,foo@bar.com"
  • 不发送电子邮件,而是记录登录链接(在Vercel日志中):SIMULATE_EMAIILS=true

看 .env.示例 查看完整列表。

如何使用

使用“索引”部分添加新的网址/网站进行索引,可以是单个网址或递归抓取的网站:

然后启动作业运行器(保持选项卡打开,直到完成)

在LLM.txt部分,您可以预览生成的LLM.txt文件:

然后,您可以使用以下代码片段将小部件嵌入到您的网站中:

聊天按钮

在页面底部嵌入一个按钮:

<script src="https://<your deployed app>/widget.js"></script>

聊天小部件

在页面的某个位置插入搜索输入:

<script src="https://ragrabbit.com/widget.js?type=search"></script>
<ragrabbit-search></ragrabbit-search>

与React.js一起使用

"use client";

import Script from "next/script";

export function RagRabbitSearch() {
  return (
    <>
      <Script src="/widget.js?type=search" strategy="lazyOnload" />
      <style>{`
        ragrabbit-search .ragrabbit-search-input {
            padding: 6px 12px;
        }
      `}</style>
      <div className="ml-auto min-w-[300px] flex-1 sm:flex-initial">
        {/* @ts-ignore - Custom element will be mounted by external script */}
        <ragrabbit-search></ragrabbit-search>
      </div>
    </>
  );
}

MPC服务器

MCP服务器允许任何受支持的AI客户端使用语义搜索从您的文档中检索页面。

克劳德桌面

添加一个带有产品名称的自定义mcp服务器,以便Claude AI在查找有关它的信息时可以使用它。

在……里面 claude_desktop_config.json (克劳德->设置->开发人员->编辑配置)

{
  "mcpServers": {
    "<name_of_your_documentation_no_spaces>": {
      "command": "npx",
      "args": ["@ragrabbit/mcp", "http://<RagRabbit install>/", "<name of your documentation>"]
    }
  }
}

在游标IDE中

转到光标->设置->光标设置->MCP

并添加一个新的MCP类型 command 使用命令:

npx @ragrabbit/mcp", "http://<RagRabbit install>/", "<name of your documentation>"

论据:

  • ragrabbit-url:(必填)RagRabbit实例的基本URL,例如https://my-ragrabbit.vercel.com/
  • name:(必填)文档搜索服务的自定义名称(默认为“RagRabbit”),以便AI在查找信息时知道如何使用它

配置选项

聊天按钮

您可以通过在widget.js脚本标签中添加以下参数来配置聊天按钮:

按钮文本

<script src="https://ragrabbit.com/widget.js?buttonText=Ask%20AI"></script>

搜索小部件

您可以通过添加以下参数并使用mountSearch调用来配置搜索小部件:

search占位符

<div id="search-container"></div>
<script>
  window.mountSearch("search-container", { searchPlaceholder: "Search documentation..." });
</script>

集成

富马酸类

创建一个组件来替换“搜索”对话框:

pnpm add @ragrabbit/search-react
"use client";
import type { SharedProps } from "fumadocs-ui/components/dialog/search";
import { RagRabbitModal } from "@ragrabbit/search-react";

export default function SearchDialog({ open, onOpenChange }: SharedProps) {
  return <RagRabbitModal
    domain="http://localhost:3000/"
    open={open}
    onOpenChange={onOpenChange}
    />;
}

然后将其设置在 layout.tsx:

<RootProvider
  search={{
    SearchDialog,
  }}
>
  ...
</RootProvider>

可选择添加浮动聊天按钮:

"use client";
import { RagRabbitChatButton } from "@ragrabbit/search-react";

export default function ChatButton() {
  return <RagRabbitChatButton domain="http://localhost:3000/" />;
}

并将其添加到 layout.tsx:

<body className="flex flex-col min-h-screen">
  <ChatButton />
  ...

发展

# Start the db (Docker needed)
pnpm dev:utils # Starts postgresql with pgvector, Storybook and Drizzle ORM Studio

# Start the app
cd apps/saas
pnpm dev

目录结构:

RagRabbit是一个包含Turborepo、Next.js应用程序和具有单独包的模块化设计的monorepo。

apps/
├── docs -> the documentation site
├── saas -> the main application
└── web -> the web site
packages/
├── db -> the database with Drizzle ORM
├── auth -> the authentication with Auth.js
├── core -> shared utils
├── design -> the design system
├── rag -> the LLM and RAG package with LlamaIndexTS
├── jobs -> job runner with Trigger.dev
└── storybook -> a Next.js Storybook app
.cursorrules -> Fine tuned Cursor rules with all the locations to work with the monorepo

作者

马可·达利亚 - @马达加斯加 - 领英

许可证

麻省理工学院