ai-rag-pipeline
Compare original and translation side by side
🇺🇸
Original
English🇨🇳
Translation
ChineseAI RAG Pipeline
AI RAG 管道
Build RAG (Retrieval Augmented Generation) pipelines via inference.sh CLI.

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

Quick Start
快速开始
bash
curl -fsSL https://cli.inference.sh | sh && infsh loginbash
curl -fsSL https://cli.inference.sh | sh && infsh loginSimple RAG: Search + LLM
Simple RAG: Search + 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"
}"
undefinedSEARCH=$(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"
}"
undefinedWhat is RAG?
什么是RAG?
RAG combines:
- Retrieval: Fetch relevant information from external sources
- Augmentation: Add retrieved context to the prompt
- Generation: LLM generates response using the context
This produces more accurate, up-to-date, and verifiable AI responses.
RAG由三部分组成:
- 检索:从外部来源获取相关信息
- 增强:将检索到的上下文添加到提示词中
- 生成:LLM结合上下文生成响应
这种方式能生成更准确、实时且可验证的AI响应。
RAG Pipeline Patterns
RAG管道模式
Pattern 1: Simple Search + Answer
模式1:简单搜索+回答
[User Query] -> [Web Search] -> [LLM with Context] -> [Answer][用户查询] -> [网页搜索] -> [带上下文的LLM] -> [回答]Pattern 2: Multi-Source Research
模式2:多来源调研
[Query] -> [Multiple Searches] -> [Aggregate] -> [LLM Analysis] -> [Report][查询] -> [多轮搜索] -> [结果聚合] -> [LLM分析] -> [报告]Pattern 3: Extract + Process
模式3:提取+处理
[URLs] -> [Content Extraction] -> [Chunking] -> [LLM Summary] -> [Output][URL列表] -> [内容提取] -> [内容分块] -> [LLM总结] -> [输出]Available Tools
可用工具
Search Tools
搜索工具
| Tool | App ID | Best For |
|---|---|---|
| Tavily Search | | AI-powered search with answers |
| Exa Search | | Neural search, semantic matching |
| Exa Answer | | Direct factual answers |
| 工具 | 应用ID | 最佳适用场景 |
|---|---|---|
| Tavily Search | | 基于AI的搜索与回答 |
| Exa Search | | 神经搜索、语义匹配 |
| Exa Answer | | 直接事实性回答 |
Extraction Tools
提取工具
| Tool | App ID | Best For |
|---|---|---|
| Tavily Extract | | Clean content from URLs |
| Exa Extract | | Analyze web content |
| 工具 | 应用ID | 最佳适用场景 |
|---|---|---|
| Tavily Extract | | 从URL提取干净内容 |
| Exa Extract | | 网页内容分析 |
LLM Tools
LLM工具
| Model | App ID | Best For |
|---|---|---|
| Claude Sonnet 4.5 | | Complex analysis |
| Claude Haiku 4.5 | | Fast processing |
| GPT-4o | | General purpose |
| Gemini 2.5 Pro | | Long context |
| 模型 | 应用ID | 最佳适用场景 |
|---|---|---|
| Claude Sonnet 4.5 | | 复杂分析 |
| Claude Haiku 4.5 | | 快速处理 |
| GPT-4o | | 通用场景 |
| Gemini 2.5 Pro | | 长上下文处理 |
Pipeline Examples
管道示例
Basic RAG Pipeline
基础RAG管道
bash
undefinedbash
undefined1. Search for information
1. 搜索信息
SEARCH_RESULT=$(infsh app run tavily/search-assistant --input '{
"query": "What are the latest breakthroughs in quantum computing 2024?"
}')
SEARCH_RESULT=$(infsh app run tavily/search-assistant --input '{
"query": "What are the latest breakthroughs in quantum computing 2024?"
}')
2. Generate grounded response
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."
}"
undefinedinfsh 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."
}"
undefinedMulti-Source Research
多来源调研
bash
undefinedbash
undefinedSearch multiple sources
搜索多个来源
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"}')
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"}')
Combine and analyze
合并结果并分析
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."
}"
undefinedinfsh 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."
}"
undefinedURL Content Analysis
URL内容分析
bash
undefinedbash
undefined1. Extract content from specific URLs
1. 从指定URL提取内容
CONTENT=$(infsh app run tavily/extract --input '{
"urls": [
"https://example.com/research-paper",
"https://example.com/industry-report"
]
}')
CONTENT=$(infsh app run tavily/extract --input '{
"urls": [
"https://example.com/research-paper",
"https://example.com/industry-report"
]
}')
2. Analyze extracted content
2. 分析提取的内容
infsh app run openrouter/claude-sonnet-45 --input "{
"prompt": "Analyze these documents and extract key insights:
$CONTENT
Provide:
- Key findings
- Data points
- Recommendations" }"
undefinedinfsh app run openrouter/claude-sonnet-45 --input "{
"prompt": "Analyze these documents and extract key insights:
$CONTENT
Provide:
- Key findings
- Data points
- Recommendations" }"
undefinedFact-Checking Pipeline
事实核查管道
bash
undefinedbash
undefinedClaim to verify
需要验证的主张
CLAIM="AI will replace 50% of jobs by 2030"
CLAIM="AI will replace 50% of jobs by 2030"
1. Search for evidence
1. 搜索证据
EVIDENCE=$(infsh app run tavily/search-assistant --input "{
"query": "$CLAIM evidence studies research"
}")
EVIDENCE=$(infsh app run tavily/search-assistant --input "{
"query": "$CLAIM evidence studies research"
}")
2. Verify claim
2. 验证主张
infsh app run openrouter/claude-sonnet-45 --input "{
"prompt": "Fact-check this claim: '$CLAIM'
Based on the following evidence:
$EVIDENCE
Provide:
- Verdict (True/False/Partially True/Unverified)
- Supporting evidence
- Contradicting evidence
- Sources" }"
undefinedinfsh app run openrouter/claude-sonnet-45 --input "{
"prompt": "Fact-check this claim: '$CLAIM'
Based on the following evidence:
$EVIDENCE
Provide:
- Verdict (True/False/Partially True/Unverified)
- Supporting evidence
- Contradicting evidence
- Sources" }"
undefinedResearch Report Generator
调研报告生成器
bash
TOPIC="Impact of generative AI on creative industries"bash
TOPIC="Impact of generative AI on creative industries"1. Initial research
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"}")
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. Generate comprehensive report
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" }"
undefinedinfsh 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" }"
undefinedQuick Answer with Sources
带来源的快速回答
bash
undefinedbash
undefinedUse Exa Answer for direct factual questions
对事实性问题使用Exa Answer
infsh app run exa/answer --input '{
"question": "What is the current market cap of NVIDIA?"
}'
undefinedinfsh app run exa/answer --input '{
"question": "What is the current market cap of NVIDIA?"
}'
undefinedBest Practices
最佳实践
1. Query Optimization
1. 查询优化
bash
undefinedbash
undefinedBad: Too vague
不佳:过于模糊
"AI news"
"AI news"
Good: Specific and contextual
优秀:具体且有上下文
"latest developments in large language models January 2024"
undefined"latest developments in large language models January 2024"
undefined2. Context Management
2. 上下文管理
bash
undefinedbash
undefinedSummarize long search results before sending to LLM
在发送给LLM之前先总结长搜索结果
SEARCH=$(infsh app run tavily/search-assistant --input '{"query": "..."}')
SEARCH=$(infsh app run tavily/search-assistant --input '{"query": "..."}')
If too long, summarize first
如果结果过长,先进行总结
SUMMARY=$(infsh app run openrouter/claude-haiku-45 --input "{
"prompt": "Summarize these search results in bullet points: $SEARCH"
}")
SUMMARY=$(infsh app run openrouter/claude-haiku-45 --input "{
"prompt": "Summarize these search results in bullet points: $SEARCH"
}")
Then use summary for analysis
再使用总结结果进行分析
infsh app run openrouter/claude-sonnet-45 --input "{
"prompt": "Based on this research summary, provide insights: $SUMMARY"
}"
undefinedinfsh app run openrouter/claude-sonnet-45 --input "{
"prompt": "Based on this research summary, provide insights: $SUMMARY"
}"
undefined3. Source Attribution
3. 来源归因
Always ask the LLM to cite sources:
bash
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": "... Always cite sources in [Source Name](URL) format."
}'始终要求LLM标注来源:
bash
infsh app run openrouter/claude-sonnet-45 --input '{
"prompt": \"... Always cite sources in [Source Name](URL) format.\"
}'4. Iterative Research
4. 迭代式调研
bash
undefinedbash
undefinedFirst pass: broad search
第一轮:宽泛搜索
INITIAL=$(infsh app run tavily/search-assistant --input '{"query": "topic overview"}')
INITIAL=$(infsh app run tavily/search-assistant --input '{"query": "topic overview"}')
Second pass: dive deeper based on findings
第二轮:基于初步发现深入研究
DEEP=$(infsh app run tavily/search-assistant --input '{"query": "specific aspect from initial search"}')
undefinedDEEP=$(infsh app run tavily/search-assistant --input '{"query": "specific aspect from initial search"}')
undefinedPipeline Templates
管道模板
Agent Research Tool
Agent调研工具
bash
#!/bin/bashbash
#!/bin/bashresearch.sh - Reusable research function
research.sh - 可复用的调研函数
research() {
local query="$1"
Search
local results=$(infsh app run tavily/search-assistant --input "{"query": "$query"}")
Analyze
infsh app run openrouter/claude-haiku-45 --input "{
"prompt": "Summarize: $results"
}"
}
research "your query here"
undefinedresearch() {
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"
undefinedRelated Skills
相关技能
bash
undefinedbash
undefinedWeb search tools
网页搜索工具
npx skills add inference-sh/skills@web-search
npx skills add inference-sh/skills@web-search
LLM models
LLM模型
npx skills add inference-sh/skills@llm-models
npx skills add inference-sh/skills@llm-models
Content pipelines
内容管道
npx skills add inference-sh/skills@ai-content-pipeline
npx skills add inference-sh/skills@ai-content-pipeline
Full platform skill
完整平台技能
npx skills add inference-sh/skills@inference-sh
Browse all apps: `infsh app list`npx skills add inference-sh/skills@inference-sh
浏览所有应用:`infsh app list`Documentation
文档
- Adding Tools to Agents - Agent tool integration
- Building a Research Agent - Full guide
- 为Agent添加工具 - Agent工具集成
- 构建调研Agent - 完整指南