ai-rag-pipeline

Compare original and translation side by side

🇺🇸

Original

English
🇨🇳

Translation

Chinese

AI RAG Pipeline

AI RAG 管道

Build RAG (Retrieval Augmented Generation) pipelines via inference.sh CLI.
AI RAG Pipeline
通过inference.sh CLI构建RAG(检索增强生成)管道。
AI RAG Pipeline

Quick Start

快速开始

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

Simple 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" }"
undefined
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" }"
undefined

What is RAG?

什么是RAG?

RAG combines:
  1. Retrieval: Fetch relevant information from external sources
  2. Augmentation: Add retrieved context to the prompt
  3. Generation: LLM generates response using the context
This produces more accurate, up-to-date, and verifiable AI responses.
RAG由三部分组成:
  1. 检索:从外部来源获取相关信息
  2. 增强:将检索到的上下文添加到提示词中
  3. 生成: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

搜索工具

ToolApp IDBest For
Tavily Search
tavily/search-assistant
AI-powered search with answers
Exa Search
exa/search
Neural search, semantic matching
Exa Answer
exa/answer
Direct factual answers
工具应用ID最佳适用场景
Tavily Search
tavily/search-assistant
基于AI的搜索与回答
Exa Search
exa/search
神经搜索、语义匹配
Exa Answer
exa/answer
直接事实性回答

Extraction Tools

提取工具

ToolApp IDBest For
Tavily Extract
tavily/extract
Clean content from URLs
Exa Extract
exa/extract
Analyze web content
工具应用ID最佳适用场景
Tavily Extract
tavily/extract
从URL提取干净内容
Exa Extract
exa/extract
网页内容分析

LLM Tools

LLM工具

ModelApp IDBest For
Claude Sonnet 4.5
openrouter/claude-sonnet-45
Complex analysis
Claude Haiku 4.5
openrouter/claude-haiku-45
Fast processing
GPT-4o
openrouter/gpt-4o
General purpose
Gemini 2.5 Pro
openrouter/gemini-25-pro
Long context
模型应用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
长上下文处理

Pipeline Examples

管道示例

Basic RAG Pipeline

基础RAG管道

bash
undefined
bash
undefined

1. 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." }"
undefined
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." }"
undefined

Multi-Source Research

多来源调研

bash
undefined
bash
undefined

Search 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." }"
undefined
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." }"
undefined

URL Content Analysis

URL内容分析

bash
undefined
bash
undefined

1. 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:
  1. Key findings
  2. Data points
  3. Recommendations" }"
undefined
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" }"
undefined

Fact-Checking Pipeline

事实核查管道

bash
undefined
bash
undefined

Claim 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:
  1. Verdict (True/False/Partially True/Unverified)
  2. Supporting evidence
  3. Contradicting evidence
  4. Sources" }"
undefined
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" }"
undefined

Research 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" }"
undefined
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" }"
undefined

Quick Answer with Sources

带来源的快速回答

bash
undefined
bash
undefined

Use Exa Answer for direct factual questions

对事实性问题使用Exa Answer

infsh app run exa/answer --input '{ "question": "What is the current market cap of NVIDIA?" }'
undefined
infsh app run exa/answer --input '{ "question": "What is the current market cap of NVIDIA?" }'
undefined

Best Practices

最佳实践

1. Query Optimization

1. 查询优化

bash
undefined
bash
undefined

Bad: 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"
undefined

2. Context Management

2. 上下文管理

bash
undefined
bash
undefined

Summarize 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" }"
undefined
infsh app run openrouter/claude-sonnet-45 --input "{ "prompt": "Based on this research summary, provide insights: $SUMMARY" }"
undefined

3. 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
undefined
bash
undefined

First 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"}')
undefined
DEEP=$(infsh app run tavily/search-assistant --input '{"query": "specific aspect from initial search"}')
undefined

Pipeline Templates

管道模板

Agent Research Tool

Agent调研工具

bash
#!/bin/bash
bash
#!/bin/bash

research.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"
undefined
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"
undefined

Related Skills

相关技能

bash
undefined
bash
undefined

Web 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

文档