开源自托管 AI 搜索引擎,本地或云端 LLM 生成带引用答案

✓ 支持本地模型免 API Key✓ Docker 一键部署 ✕ Live Demo 仅支持云模型

方案简介

Farfalle 是一个开源的 AI 驱动搜索引擎(Perplexity Clone)。它将搜索引擎(SearXNG/Tavily/Serper/Bing)与 LLM(本地 llama3/mistral/gemma/phi3、云端 OpenAI/Groq 或通过 LiteLLM 接入的自定义模型)组合,用搜索结果回答问题。适合想自托管类 Perplexity 搜索体验、或用 Ollama 在本地跑模型且不想依赖外部 API 的开发者。

亮点与能力

  • Search with multiple search providers (Tavily, Searxng, Serper, Bing)
  • Answer questions with cloud models (OpenAI/gpt4-o, OpenAI/gpt3.5-turbo, Groq/Llama3)
  • Answer questions with local models (llama3, mistral, gemma, phi3)
  • Answer questions with any custom LLMs through LiteLLM
  • Search with an agent that plans and executes the search for better results
  • Chat History

组成与分工

  • Next.js:前端框架
  • FastAPI:后端框架
  • SearXNG / Tavily / Serper / Bing:搜索 API 提供方
  • Ollama:本地运行 llama3、mistral、gemma、phi3 等模型
  • LiteLLM:接入自定义 LLM
  • Redis:速率限制
  • Logfire:日志
  • shadcn/ui:UI 组件库

前置要求

  • Ollama(如运行本地模型),下载支持的模型之一:llama3, mistral, gemma, phi3,然后启动服务:

ollama serve

如使用云端模型需要准备相应 API Keys;使用 Ollama 时可不填。

实施步骤

1. 克隆仓库并准备环境变量

git clone https://github.com/rashadphz/farfalle.git
cd farfalle && cp .env-template .env

修改 .env 填入你的 API keys(可选,使用 Ollama 时不需要)。

2. 启动应用

docker-compose -f docker-compose.dev.yaml up -d

3. 访问

等待应用启动后访问 http://localhost:3000

自定义安装说明见 custom-setup-instructions.md。

使用与配置要点

作为默认搜索引擎使用

  1. 访问浏览器设置
  2. 进入 'Search Engines'
  3. 使用如下 URL 创建新的搜索引擎条目:http://localhost:3000/?q=%s。
  4. 添加该搜索引擎。

部署到云端

后端部署后复制服务 URL(形如 https://some-service-name.onrender.com),前端在 Vercel 部署时将后端 URL 填入 NEXT_PUBLIC_API_URL 环境变量。

注意事项与常见问题

  • Live Demo (farfalle.dev) 仅支持云模型。
  • 使用 Ollama 本地模型时无需 API keys。
  • Roadmap 中已完成 Docker 部署、预构建 Docker 镜像、SearXNG 支持、Chat History、Expert Search;「Chat with local files」尚未完成。

优缺点

  • ✓ 支持本地模型免 API Key
  • ✓ Docker 一键部署
  • ✕ Live Demo 仅支持云模型

出处

本方案挖掘自开源项目 rashadphz/farfalle,方案内容与实施命令均来自其 README 原文。

方案出处
rashadphz/farfalle:🔍 AI search engine - self-host with local or cloud LLMs
3541 star 🔍 AI search engine - self-host with local or cloud LLMs

本方案由真实开源项目挖掘整理,实施命令均来自其 README 原文,安装使用请遵循项目开源协议。