trieve
安装方式
先用 Prompt 核对来源与依赖。也可下载安装包。
用 AI 助手安装
复制提示词,让助手先核对固定版本和依赖。
查看 Prompt收起 Prompt
先检查当前 Agent 是否已安装 SkillPI Skill Finder。如果尚未安装,请按官方仓库的说明安装并启用:https://github.com/Findskills/skillpi。然后使用 Skill Finder 打开此 SkillPI 详情页并定位 "trieve":https://skillpi.com/zh/skills/deepskill-6dc456ce9663f8949b627bfb9d6f7e454f8f27dd5bce1317631bca0201bd09c3。安装前核对上游来源和版本:https://github.com/TerminalSkills/skills。来源不一致时停止并说明差异。核对通过后,用 Skill Finder 安装目标 Skill,并报告安装路径和来源版本。
来源与配置
github.com
配置方式待核实
请查看原始来源中的适用工具、依赖和权限要求。
安装实测待补充
为 Trieve 提供专家级指导,Trieve 是集全文搜索、语义搜索和混合搜索于一体的搜索基础设施并内置 RAG 功能。用于帮助开发者实现生产级搜索功能,支持分块、重排序、推荐与分析,无需管理向量数据库或嵌入模型。
介绍来源: third_party · TerminalSkills · 1.0.0 参考来源
SkillPi 解读
- 能完成的任务
- 翻译待完成,请参阅来源文档。
- 实测状态
- 未测试
文件浏览
Frontmatter
name: trieve
description: Expert guidance for Trieve, the all-in-one search infrastructure that combines full-text, semantic, and hybrid search with built-in RAG capabilities. Helps developers implement production search with chunking, re-ranking, recommendations, and analytics without managing vector databases or embedding models.
license: Apache-2.0
compatibility: No special requirements
metadata:
author: terminal-skills
version: 1.0.0
category: data-ai
tags:
- search
- ai-search
- rag
- vector-search
- hybrid-searchTrieve — AI Search Infrastructure
Overview
Trieve, the all-in-one search infrastructure that combines full-text, semantic, and hybrid search with built-in RAG capabilities. Helps developers implement production search with chunking, re-ranking, recommendations, and analytics without managing vector databases or embedding models.
Instructions
Dataset and Chunk Management
Create a dataset and ingest content as chunks:
// src/search/ingest.ts — Ingest documents into Trieve
const TRIEVE_API_URL = "https://api.trieve.ai";
const TRIEVE_API_KEY = process.env.TRIEVE_API_KEY!;
const DATASET_ID = process.env.TRIEVE_DATASET_ID!;
async function trieveFetch(path: string, options?: RequestInit) {
const res = await fetch(`${TRIEVE_API_URL}${path}`, {
...options,
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${TRIEVE_API_KEY}`,
"TR-Dataset": DATASET_ID,
...options?.headers,
},
});
if (!res.ok) throw new Error(`Trieve error: ${await res.text()}`);
return res.json();
}
// Create a chunk (the fundamental unit of searchable content)
async function ingestChunk(params: {
content: string;
link?: string;
tag_set?: string[];
metadata?: Record<string, any>;
group_tracking_id?: string; // Group related chunks (e.g., same document)
}) {
return trieveFetch("/api/chunk", {
method: "POST",
body: JSON.stringify({
chunk_html: params.content, // HTML or plain text content
link: params.link, // Source URL
tag_set: params.tag_set, // Tags for filtering
metadata: params.metadata,
group_tracking_ids: params.group_tracking_id
? [params.group_tracking_id]
: undefined,
upsert_by_tracking_id: true, // Update if exists, insert if not
}),
});
}
// Bulk ingest for large datasets
async function bulkIngest(documents: any[]) {
const chunks = documents.flatMap((doc) => {
// Split long documents into smaller chunks
const paragraphs = doc.content.split("\n\n").filter(Boolean);
return paragraphs.map((paragraph: string, index: number) => ({
chunk_html: paragraph,
tracking_id: `${doc.id}-chunk-${index}`,
link: doc.url,
tag_set: doc.tags,
metadata: {
title: doc.title,
author: doc.author,
section_index: index,
},
group_tracking_ids: [doc.id], // All chunks from same doc in one group
}));
});
// Send in batches of 120 (API limit)
for (let i = 0; i < chunks.length; i += 120) {
const batch = chunks.slice(i, i + 120);
await trieveFetch("/api/chunks", {
method: "POST",
body: JSON.stringify(batch),
});
console.log(`Ingested ${Math.min(i + 120, chunks.length)}/${chunks.length} chunks`);
}
}
Search
Perform full-text, semantic, or hybrid search:
// src/search/query.ts — Search with different strategies
// Hybrid search — combines keyword matching with semantic similarity
async function hybridSearch(query: string, options?: {
filters?: Record<string, any>;
page?: number;
pageSize?: number;
scoreThreshold?: number;
}) {
return trieveFetch("/api/chunk/search", {
method: "POST",
body: JSON.stringify({
query,
search_type: "hybrid", // "fulltext" | "semantic" | "hybrid"
page: options?.page ?? 1,
page_size: options?.pageSize ?? 10,
score_threshold: options?.scoreThreshold ?? 0.3,
get_total_pages: true,
highlight_results: true, // Return highlighted snippets
highlight_max_length: 200,
highlight_max_num: 3,
use_weights: true, // Balance keyword vs semantic scores
filters: options?.filters ? {
must: Object.entries(options.filters).map(([field, value]) => ({
field: `metadata.${field}`,
match_any: Array.isArray(value) ? value : [value],
})),
} : undefined,
}),
});
}
// Autocomplete / typeahead search
async function autocomplete(query: string) {
return trieveFetch("/api/chunk/autocomplete", {
method: "POST",
body: JSON.stringify({
query,
search_type: "fulltext", // Keyword-based for speed
page_size: 5,
highlight_results: true,
highlight_max_length: 100,
}),
});
}
// Group search — return results grouped by document
async function groupSearch(query: string) {
return trieveFetch("/api/chunk_group/group_oriented_search", {
method: "POST",
body: JSON.stringify({
query,
search_type: "hybrid",
page: 1,
page_size: 10,
group_size: 3, // Show top 3 chunks per group
}),
});
}
RAG (Retrieval-Augmented Generation)
Use Trieve's built-in RAG to generate answers from your data:
// src/search/rag.ts — Generate answers using retrieved context
async function ragQuery(question: string) {
const response = await trieveFetch("/api/chunk/generate", {
method: "POST",
body: JSON.stringify({
prev_messages: [
{ role: "user", content: question },
],
// Search configuration for retrieval step
chunk_filter: null,
search_type: "hybrid",
page_size: 5, // Retrieve top 5 chunks as context
// LLM configuration for generation step
llm_options: {
completion_first: false, // Search first, then generate
system_prompt: "Answer the user's question based on the provided context. If the context doesn't contain the answer, say so. Cite sources.",
temperature: 0.3, // Low temperature for factual answers
max_tokens: 500,
},
highlight_results: true,
}),
});
// Response includes both the generated answer and the source chunks
return {
answer: response.message,
sources: response.chunks.map((c: any) => ({
content: c.chunk.chunk_html,
link: c.chunk.link,
score: c.score,
})),
};
}
// Streaming RAG for real-time response display
async function streamRagQuery(question: string, onChunk: (text: string) => void) {
const response = await fetch(`${TRIEVE_API_URL}/api/chunk/generate`, {
method: "POST",
headers: {
"Content-Type": "application/json",
Authorization: `Bearer ${TRIEVE_API_KEY}`,
"TR-Dataset": DATASET_ID,
},
body: JSON.stringify({
prev_messages: [{ role: "user", content: question }],
search_type: "hybrid",
page_size: 5,
stream_response: true,
}),
});
const reader = response.body!.getReader();
const decoder = new TextDecoder();
while (true) {
const { done, value } = await reader.read();
if (done) break;
const text = decoder.decode(value);
onChunk(text);
}
}
Recommendations
Get content recommendations based on chunk similarity:
// src/search/recommend.ts — Content recommendations
async function getRecommendations(chunkId: string, limit = 5) {
return trieveFetch("/api/chunk/recommend", {
method: "POST",
body: JSON.stringify({
positive_chunk_ids: [chunkId], // "More like this"
negative_chunk_ids: [], // "Less like this"
limit,
strategy: "average_vector", // Average vectors of positive examples
}),
});
}
// Recommend based on user reading history
async function personalizedRecommendations(readChunkIds: string[], limit = 10) {
return trieveFetch("/api/chunk/recommend", {
method: "POST",
body: JSON.stringify({
positive_chunk_ids: readChunkIds.slice(-5), // Last 5 read articles
negative_chunk_ids: [],
limit,
strategy: "average_vector",
filters: {
must_not: readChunkIds.map((id) => ({ // Exclude already-read content
field: "id",
match_any: [id],
})),
},
}),
});
}
Analytics
Track search performance and user behavior:
// src/search/analytics.ts — Search analytics and click tracking
// Log a search event
async function trackSearch(query: string, results: any[]) {
await trieveFetch("/api/analytics/search", {
method: "POST",
body: JSON.stringify({
query,
search_type: "hybrid",
results: results.map((r) => r.id),
}),
});
}
// Log when a user clicks a search result
async function trackClick(queryId: string, chunkId: string, position: number) {
await trieveFetch("/api/analytics/search/click", {
method: "POST",
body: JSON.stringify({
query_id: queryId,
chunk_id: chunkId,
position, // 1-indexed click position
}),
});
}
// Get search analytics — top queries, no-result queries, CTR
async function getAnalytics(params: { from: string; to: string }) {
const topQueries = await trieveFetch(
`/api/analytics/search/top_queries?from=${params.from}&to=${params.to}`
);
const noResults = await trieveFetch(
`/api/analytics/search/no_result_queries?from=${params.from}&to=${params.to}`
);
return { topQueries, noResults };
}
Installation
# JavaScript/TypeScript SDK
npm install trieve-ts-sdk
# Or use the REST API directly (no SDK needed)
# All examples above use fetch — zero dependencies
Examples
Example 1: Integrating Trieve into an existing application
User request:
Add Trieve to my Next.js app for the AI chat feature. I want streaming responses.
The agent installs the SDK, creates an API route that initializes the Trieve client, configures streaming, selects an appropriate model, and wires up the frontend to consume the stream. It handles error cases and sets up proper environment variable management for the API key.
Example 2: Optimizing search performance
User request:
My Trieve calls are slow and expensive. Help me optimize the setup.
The agent reviews the current implementation, identifies issues (wrong model selection, missing caching, inefficient prompting, no batching), and applies optimizations specific to Trieve's capabilities — adjusting model parameters, adding response caching, and implementing retry logic with exponential backoff.
Guidelines
- Chunk intelligently — Split by paragraphs or sections, not arbitrary character counts; each chunk should be self-contained
- Use groups for documents — Group chunks from the same document so you can search by document or by chunk
- Hybrid search by default — Combines keyword precision with semantic understanding; switch to fulltext only for autocomplete
- Track analytics from day one — No-result queries tell you what content is missing; low-CTR queries reveal relevance issues
- Set score thresholds — Filter out low-confidence results; 0.3 is a good starting point, tune based on your data
- Use tags for filtering — Tags enable fast categorical filters without scanning metadata
- Upsert with tracking IDs — Use
upsert_by_tracking_idto safely re-ingest content without creating duplicates - Stream RAG responses — For user-facing applications, stream the LLM response to reduce perceived latency
当前收录版本
1.0.0
安全与评测信息
质量评测
满分100 · 来自 SkillPi LAB 实验室的评测报告。
亮点
- Trieve 是一个专业的搜索基础设施,该 Skill 提供了完整的集成指南、代码示例和最佳实践
- 帮助开发者快速实现生产级搜索功能,具有极高的实用价值
- 涵盖了数据导入、搜索、RAG、推荐和 analytics 等完整功能模块
亮点
- 触发词精准完整,覆盖多种变体,边界清晰
- description 明确描述了 Skill 的用途和目标用户
- 标签设置合理,便于用户发现和使用
亮点
- 文档结构良好,包含多个代码示例和使用场景
- Phase/步骤清晰,有出口条件,含端到端示例
- frontmatter完整,单文件≤500行,符合规范要求
亮点
- 工具来源明确,参数正确,覆盖主要异常
- 代码示例完整,包含错误处理和最佳实践
- 提供了多种使用场景和优化建议,执行可靠性高
取前四项原始分值的算术平均,四舍五入取整。可通过收录报告核对各项评分与说明,运行记录需单独查证。
正文静态检测
100 / 100 · skillpi-20261123-no-r3-v1
正文未命中当前规则。
分数仅反映正文中的规则命中,供使用前参考。附件与运行行为不在此评分范围内。
权限与使用前检查
根据当前主文档自动整理,命中内容可能是示例或防护说明;不是实际权限声明,也未覆盖附件、外部依赖或运行行为。
-
安装或获取外部依赖
使用官方来源并锁定版本,在隔离环境检查安装脚本。当前文档检查不覆盖后续下载的代码。
主文档提及 · 第 326 行 -
账号、密钥或授权
使用专用、最小权限账号,不把密钥粘贴到公开内容或命令日志;核对接收数据的服务与租户。
主文档提及 · 第 344 行
文档引用的域名或地址
这些地址可能用于文档链接或示例,不是已批准的联网清单。使用前核对实际目的地及发送的数据。
- api.trieve.ai
安全评级与访问范围
safe · 静态证据核验,不代表运行安全保证。
使用前请由宿主核对并授权实际文件读写、外部服务和联网目的地;本站的核验不会授予任何运行权限。
用户讨论
还没有已核实的点评。