AIRAG管道技能Skill ai-rag-pipeline

此技能用于构建基于检索增强生成(RAG)的AI管道,结合网络搜索和大语言模型(LLMs),实现知识增强的AI响应生成。适用于AI智能体开发、研究助手、事实检查、知识检索等场景。关键词:RAG、AI管道、检索增强生成、网络搜索、LLMs、AI应用、知识库、智能体、事实检查、研究助手。

RAG应用 0 次安装 0 次浏览 更新于 3/12/2026

名称: ai-rag-pipeline 描述: “使用网络搜索和LLMs构建RAG(检索增强生成)管道。工具:Tavily搜索、Exa搜索、Exa答案、Claude、GPT-4、Gemini via OpenRouter。能力:研究、事实检查、基于证据的响应、知识检索。用途:AI智能体、研究助手、事实检查器、知识库。触发器:rag、检索增强生成、基于AI的搜索和答案、研究智能体、事实检查、知识检索、AI研究、搜索+llm、网络基础、perplexity替代、带来源的AI、引用、研究管道” 允许工具: Bash(infsh *)

AI RAG 管道

通过 inference.sh CLI 构建 RAG(检索增强生成)管道。

AI RAG Pipeline

快速开始

curl -fsSL https://cli.inference.sh | sh && infsh login

# 简单RAG:搜索 + LLM
SEARCH=$(infsh app run tavily/search-assistant --input '{"query": "latest AI developments 2024"}')
infsh app run openrouter/claude-sonnet-45 --input "{
  \"prompt\": \"Based on this research, summarize the key trends: $SEARCH\"
}"

安装说明: 安装脚本 仅检测您的操作系统/架构,从 dist.inference.sh 下载匹配的二进制文件,并验证其SHA-256校验和。无需提升权限或后台进程。手动安装和验证 可用。

什么是RAG?

RAG 结合:

  1. 检索: 从外部源获取相关信息
  2. 增强: 将检索到的上下文添加到提示中
  3. 生成: LLM 使用上下文生成响应

这产生更准确、最新和可验证的AI响应。

RAG 管道模式

模式 1: 简单搜索 + 答案

[用户查询] -> [网络搜索] -> [带上下文的LLM] -> [答案]

模式 2: 多源研究

[查询] -> [多次搜索] -> [聚合] -> [LLM分析] -> [报告]

模式 3: 提取 + 处理

[URLs] -> [内容提取] -> [分块] -> [LLM总结] -> [输出]

可用工具

搜索工具

工具 应用 ID 最佳用途
Tavily 搜索 tavily/search-assistant AI驱动的搜索,带答案
Exa 搜索 exa/search 神经搜索,语义匹配
Exa 答案 exa/answer 直接事实答案

提取工具

工具 应用 ID 最佳用途
Tavily 提取 tavily/extract 从URLs提取干净内容
Exa 提取 exa/extract 分析网络内容

LLM 工具

模型 应用 ID 最佳用途
Claude Sonnet 4.5 openrouter/claude-sonnet-45 复杂分析
Claude Haiku 4.5 openrouter/claude-haiku-45 快速处理
GPT-4o openrouter/gpt-4o 通用目的
Gemini 2.5 Pro openrouter/gemini-25-pro 长上下文

管道示例

基础RAG管道

# 1. 搜索信息
SEARCH_RESULT=$(infsh app run tavily/search-assistant --input '{
  "query": "What are the latest breakthroughs in quantum computing 2024?"
}')

# 2. 生成基于证据的响应
infsh app run openrouter/claude-sonnet-45 --input "{
  \"prompt\": \"You are a research assistant. Based on the following search results, provide a comprehensive summary with citations.

Search Results:
$SEARCH_RESULT

Provide a well-structured summary with source citations.\"
}"

多源研究

# 搜索多个源
TAVILY=$(infsh app run tavily/search-assistant --input '{"query": "electric vehicle market trends 2024"}')
EXA=$(infsh app run exa/search --input '{"query": "EV market analysis latest reports"}')

# 合并和分析
infsh app run openrouter/claude-sonnet-45 --input "{
  \"prompt\": \"Analyze these research results and identify common themes and contradictions.

Source 1 (Tavily):
$TAVILY

Source 2 (Exa):
$EXA

Provide a balanced analysis with sources.\"
}"

URL内容分析

# 1. 从特定URLs提取内容
CONTENT=$(infsh app run tavily/extract --input '{
  "urls": [
    "https://example.com/research-paper",
    "https://example.com/industry-report"
  ]
}')

# 2. 分析提取的内容
infsh app run openrouter/claude-sonnet-45 --input "{
  \"prompt\": \"Analyze these documents and extract key insights:

$CONTENT

Provide:
1. Key findings
2. Data points
3. Recommendations\"
}"

事实检查管道

# 要验证的声称
CLAIM="AI will replace 50% of jobs by 2030"

# 1. 搜索证据
EVIDENCE=$(infsh app run tavily/search-assistant --input "{
  \"query\": \"$CLAIM evidence studies research\"
}")

# 2. 验证声称
infsh app run openrouter/claude-sonnet-45 --input "{
  \"prompt\": \"Fact-check this claim: '$CLAIM'

Based on the following evidence:
$EVIDENCE

Provide:
1. Verdict (True/False/Partially True/Unverified)
2. Supporting evidence
3. Contradicting evidence
4. Sources\"
}"

研究报告生成器

TOPIC="Impact of generative AI on creative industries"

# 1. 初始研究
OVERVIEW=$(infsh app run tavily/search-assistant --input "{\"query\": \"$TOPIC overview\"}")
STATISTICS=$(infsh app run exa/search --input "{\"query\": \"$TOPIC statistics data\"}")
OPINIONS=$(infsh app run tavily/search-assistant --input "{\"query\": \"$TOPIC expert opinions\"}")

# 2. 生成综合报告
infsh app run openrouter/claude-sonnet-45 --input "{
  \"prompt\": \"Generate a comprehensive research report on: $TOPIC

Research Data:
== Overview ==
$OVERVIEW

== Statistics ==
$STATISTICS

== Expert Opinions ==
$OPINIONS

Format as a professional report with:
- Executive Summary
- Key Findings
- Data Analysis
- Expert Perspectives
- Conclusion
- Sources\"
}"

快速答案带来源

# 使用Exa Answer处理直接事实问题
infsh app run exa/answer --input '{
  "question": "What is the current market cap of NVIDIA?"
}'

最佳实践

1. 查询优化

# 差: 太模糊
"AI news"

# 好: 具体和上下文相关
"latest developments in large language models January 2024"

2. 上下文管理

# 在发送到LLM之前总结长搜索结果
SEARCH=$(infsh app run tavily/search-assistant --input '{"query": "..."}')

# 如果太长,先总结
SUMMARY=$(infsh app run openrouter/claude-haiku-45 --input "{
  \"prompt\": \"Summarize these search results in bullet points: $SEARCH\"
}")

# 然后用总结进行分析
infsh app run openrouter/claude-sonnet-45 --input "{
  \"prompt\": \"Based on this research summary, provide insights: $SUMMARY\"
}"

3. 来源归属

总是要求LLM引用来源:

infsh app run openrouter/claude-sonnet-45 --input '{
  "prompt": "... Always cite sources in [Source Name](URL) format."
}'

4. 迭代研究

# 第一轮: 广泛搜索
INITIAL=$(infsh app run tavily/search-assistant --input '{"query": "topic overview"}')

# 第二轮: 基于初步发现深入
DEEP=$(infsh app run tavily/search-assistant --input '{"query": "specific aspect from initial search"}')

管道模板

智能体研究工具

#!/bin/bash
# research.sh - 可重用的研究函数

research() {
  local query="$1"

  # 搜索
  local results=$(infsh app run tavily/search-assistant --input "{\"query\": \"$query\"}")

  # 分析
  infsh app run openrouter/claude-haiku-45 --input "{
    \"prompt\": \"Summarize: $results\"
  }"
}

research "your query here"

相关技能

# 网络搜索工具
npx skills add inference-sh/skills@web-search

# LLM模型
npx skills add inference-sh/skills@llm-models

# 内容管道
npx skills add inference-sh/skills@ai-content-pipeline

# 完整平台技能
npx skills add inference-sh/skills@inference-sh

浏览所有应用: infsh app list

文档