AgentSkillsCN

exa-rag

借助Exa.ai构建RAG管道,实现实时网络检索。适用于构建检索增强生成模型、将Exa与LangChain、LlamaIndex、Vercel AI SDK集成,或开发具备网络搜索能力的AI智能体。可触发的场景包括:RAG管道、检索增强生成、Exa LangChain、Exa LlamaIndex、ExaSearchRetriever、ExaSearchResults、Exa MCP、Exa工具调用、Claude工具使用、AI智能体网络搜索、有据生成、引用生成、事实核查、幻觉检测、OpenAI兼容性、聊天补全等。

SKILL.md
--- frontmatter
name: exa-rag
description: "Build RAG pipelines with Exa.ai for real-time web retrieval. Use when building retrieval-augmented generation, integrating Exa with LangChain, LlamaIndex, Vercel AI SDK, or implementing AI agents with web search capabilities. Triggers on: RAG pipeline, retrieval augmented generation, Exa LangChain, Exa LlamaIndex, ExaSearchRetriever, ExaSearchResults, Exa MCP, Exa tool calling, Claude tool use, AI agent web search, grounded generation, citation generation, fact checking, hallucination detection, OpenAI compatibility, chat completions."
license: MIT
metadata:
  author: ejirocodes
  version: '1.0.0'

Exa RAG Integration

Quick Reference

TopicWhen to UseReference
LangChainBuilding RAG chains with LangChainlangchain.md
LlamaIndexUsing Exa as a LlamaIndex data sourcellamaindex.md
Vercel AI SDKAdding web search to Next.js AI appsvercel-ai.md
MCP & ToolsClaude MCP server, OpenAI tools, function callingmcp-tools.md

Essential Patterns

LangChain Retriever

python
from langchain_exa import ExaSearchRetriever

retriever = ExaSearchRetriever(
    exa_api_key="your-key",
    k=5,
    highlights=True
)

docs = retriever.invoke("latest AI research papers")

LlamaIndex Reader

python
from llama_index.readers.web import ExaReader

reader = ExaReader(api_key="your-key")
documents = reader.load_data(
    query="machine learning best practices",
    num_results=10
)

Vercel AI SDK Tool

typescript
import { exa } from "@agentic/exa";
import { createOpenAI } from "@ai-sdk/openai";
import { generateText } from "ai";

const result = await generateText({
  model: openai("gpt-4"),
  tools: { search: exa.searchAndContents },
  prompt: "Search for the latest TypeScript features",
});

OpenAI-Compatible Endpoint

python
from openai import OpenAI

client = OpenAI(
    base_url="https://api.exa.ai/v1",
    api_key="your-exa-key"
)

response = client.chat.completions.create(
    model="exa",
    messages=[{"role": "user", "content": "What are the latest AI trends?"}]
)

Integration Selection

FrameworkBest ForKey Feature
LangChainComplex chains, agentsExaSearchRetriever, tool integration
LlamaIndexDocument indexing, Q&AExaReader, query engines
Vercel AI SDKNext.js apps, streamingTool definitions, edge-ready
OpenAI CompatDrop-in replacementMinimal code changes
Claude MCPClaude Desktop, Claude CodeNative tool calling

Common Mistakes

  1. Not using highlights for RAG - Full text wastes context; use highlights=True for relevant snippets
  2. Missing source attribution - Always include result.url in citations for grounded responses
  3. Ignoring summaries - summary=True provides concise context without full page overhead
  4. Over-fetching results - Start with 3-5 results; more isn't always better for RAG quality
  5. Not filtering domains - Use include_domains to limit to authoritative sources
  6. Skipping date filters - For current events, always add start_published_date to avoid stale info
  7. Forgetting async patterns - Use async retrievers in production for better throughput