Token导航 LogoToken导航TokenDH.com
研究检索敏感数据github未标认证来源可访问clear审计通过

upstash-vector-db-skillsUpstash 矢量数据库技能

Agent Skill

用于搭建或维护带检索增强的 RAG 工作流,适合让 Agent 处理知识库问答、向量检索、来源引用和事实核查。它可以辅助整理数据接入、Embedding、向量库、召回参数和回答生成流程。使用时需要确认数据来源、更新频率、召回阈值和引用展示方式,避免把未命中的资料或过期内容包装成确定事实。

总安装

4,633

周安装

197

GitHub Stars

19

下载量

1,623
CodexClaudeCursorGemini CLI

安装说明

本站只整理中文说明和来源信息,不托管安装包,也不代用户安装。

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

复制提示词发给支持本地命令或 Skills 的 AI 助手,先确认命令和权限,再让它执行。

请帮我安装这个 Agent Skill:upstash-vector-db-skills(Upstash 矢量数据库技能)
来源仓库:https://github.com/gocallum/nextjs16-agent-skills
仓库路径:skills/upstash-vector-db-skills
安装命令:
npx skills add https://github.com/gocallum/nextjs16-agent-skills --skill upstash-vector-db-skills
安装前请先检查当前环境是否支持对应 CLI,并向我确认将要执行的命令、安装目录、联网范围和文件读写权限;确认后再执行。

命令行安装

复制命令到本机终端执行。不同来源提供的安装方式可能略有差异;本站展示可直接复制的安装命令,安装前请核对来源页面。

skills.shnpx skills
npx skills add https://github.com/gocallum/nextjs16-agent-skills --skill upstash-vector-db-skills

简介

upstash-vector-db-skills 用于搭建或维护带检索增强的 RAG 工作流,适合处理知识库问答、向量检索和事实核查。

  • 适用于数据接入、Embedding、向量库管理和回答生成流程优化的场景。
  • 通过 npx skills add 命令从 GitHub 仓库安装,需结合原始 README 确认具体用法。
  • 使用时需确认数据来源、更新频率和召回阈值,避免将未命中资料包装成确定事实。
  • 安装前请核实权限范围、维护状态,以及是否涉及联网、命令执行或文件读写操作。

SKILL.md

Links

Quick Setup

1. Create Vector Index (Upstash Console)

  • Go to Upstash Console
  • Create Vector Index: name, region (closest to app), type (Dense for semantic search)
  • Select embedding model: MixBread AI recommended (or use Upstash built-in models)
  • Copy UPSTASH_VECTOR_REST_URL and UPSTASH_VECTOR_REST_TOKEN to .env

2. Install SDK

pnpm add @upstash/vector

3. Environment

UPSTASH_VECTOR_REST_URL=your_url
UPSTASH_VECTOR_REST_TOKEN=your_token

Code Examples

Initialize Client (Node.js / TypeScript)

import { Index } from "@upstash/vector";

const index = new Index({
  url: process.env.UPSTASH_VECTOR_REST_URL,
  token: process.env.UPSTASH_VECTOR_REST_TOKEN,
});

Upsert Documents (Auto-Embed)

When using an embedding model in the index, text is embedded automatically:

// Single document
await index.upsert({
  id: "doc-1",
  data: "Upstash provides serverless vector database solutions.",
  metadata: { source: "docs", category: "intro" },
});

// Batch
await index.upsert([
  { id: "doc-2", data: "Vector search powers semantic similarity.", metadata: { source: "docs" } },
  { id: "doc-3", data: "MixBread AI provides high-quality embeddings.", metadata: { source: "blog" } },
]);

Query / Semantic Search

// Semantic search with auto-embedding
const results = await index.query({
  data: "What is semantic search?",
  topK: 5,
  includeMetadata: true,
});

results.forEach((result) => {
  console.log(`ID: ${result.id}, Score: ${result.score}, Metadata:`, result.metadata);
});

Using Namespaces (Data Isolation)

Namespaces partition a single index into isolated subsets. Useful for multi-tenant or multi-domain apps.

// Upsert in namespace "blog"
await index.namespace("blog").upsert({
  id: "post-1",
  data: "Next.js tutorial for Vercel deployment",
  metadata: { author: "user-123" },
});

// Query only "blog" namespace
const blogResults = await index.namespace("blog").query({
  data: "Vercel deployment",
  topK: 3,
  includeMetadata: true,
});

// List all namespaces
const namespaces = await index.listNamespaces();
console.log(namespaces);

// Delete namespace
await index.deleteNamespace("blog");

Full Semantic Search Example (Vercel Function)

// api/search.ts (Vercel Edge Function or Serverless Function)
import { Index } from "@upstash/vector";

export const config = {
  runtime: "nodejs", // or "edge"
};

const index = new Index({
  url: process.env.UPSTASH_VECTOR_REST_URL,
  token: process.env.UPSTASH_VECTOR_REST_TOKEN,
});

export default async function handler(req, res) {
  if (req.method !== "POST") {
    return res.status(405).json({ error: "Method not allowed" });
  }

  const { query, namespace = "", topK = 5 } = req.body;

  try {
    const searchIndex = namespace ? index.namespace(namespace) : index;
    const results = await searchIndex.query({
      data: query,
      topK,
      includeMetadata: true,
    });

    return res.status(200).json({ results });
  } catch (error) {
    console.error("Search error:", error);
    return res.status(500).json({ error: "Search failed" });
  }
}

Index Operations

// Reset (clear all vectors in index or namespace)
await index.reset();

// Or reset a specific namespace
await index.namespace("old-data").reset();

// Delete a single vector
await index.delete("doc-1");

// Delete multiple vectors
await index.delete(["doc-1", "doc-2", "doc-3"]);

Embedding Models

Available in Upstash

  • BAAI/bge-large-en-v1.5 (1024 dim, best performance, ~64.23 MTEB score)
  • BAAI/bge-base-en-v1.5 (768 dim, good balance)
  • BAAI/bge-small-en-v1.5 (384 dim, lightweight)
  • BAAI/bge-m3 (1024 dim, sparse + dense hybrid)

Recommended: MixBread AI

If using MixBread as your embedding provider:

  1. Create a MixBread API key at https://www.mixbread.ai/
  2. When creating your Upstash index, select MixBread as the embedding model.
  3. MixBread handles tokenization and semantic quality automatically.
  4. No extra setup needed in your code; use index.upsert() / index.query() with text directly.

Best Practices

For Vercel Deployment

  • Store credentials in Vercel Environment Variables (project settings or .env.local).
  • Use Edge Functions or Serverless Functions for low-latency access.
  • Implement request rate limiting to stay within Upstash quotas.

Namespace Strategy

  • Use namespaces to isolate data by tenant, domain, or use case.
  • Example: namespace("user-123") for per-user search.
  • Clean up old namespaces to avoid storage bloat.

Query Performance

  • Keep topK reasonable (5–10 typically sufficient).
  • Use metadata filtering to pre-filter results if possible.
  • Upstash is eventually consistent; expect slight delays after upserts.

Error Handling

try {
  const results = await index.query({
    data: userQuery,
    topK: 5,
    includeMetadata: true,
  });
} catch (error) {
  if (error.status === 401) {
    console.error("Invalid credentials");
  } else if (error.status === 429) {
    console.error("Rate limited");
  } else {
    console.error("Query error:", error);
  }
}

Common Patterns

RAG (Retrieval Augmented Generation)

  1. Upsert documents / knowledge base into Upstash.
  2. On user query, retrieve top-k similar docs via semantic search.
  3. Pass retrieved docs + user query to LLM for better context.
const docs = await index.query({ data: userQuestion, topK: 3 });
const context = docs.map((d) => d.metadata?.text).join("\n");
// Pass context to LLM

Multi-Tenant Search

Use namespaces to isolate each tenant's vectors:

const userNamespace = `tenant-${userId}`;
await index.namespace(userNamespace).upsert({ id, data, metadata });
// Queries only see that tenant's data

Batch Indexing

For bulk imports, upsert in batches:

const batchSize = 100;
for (let i = 0; i < documents.length; i += batchSize) {
  const batch = documents.slice(i, i + batchSize);
  await index.upsert(batch);
  console.log(`Indexed batch ${i / batchSize + 1}`);
}

Troubleshooting

  • No results returned: Ensure documents are indexed and embedding model is active.
  • Slow queries: Check quota limits; consider upgrading plan or reducing dataset size.
  • Stale data: Upstash is eventually consistent; wait 1–2 seconds before querying new inserts.
  • Namespace not working: Ensure namespace exists (created on first upsert) or use the default "".

适合场景

01

研究助手

02

事实核查

03

知识库问答

04

带来源的搜索总结

能力概览

能力 1

组合搜索和大模型调用

能力 2

支持多来源检索和总结

能力 3

强调引用来源和事实核查

能力 4

适合研究型 Agent 流程

安装后应在对应宿主中按原始 README 的触发条件使用;具体调用方式请以来源页面和 README 为准。

平台分布

Claude Code

30.9%
按下载量换算502

OpenCode

20.22%
按下载量换算328

Gemini CLI

18.05%
按下载量换算293

Antigravity

12.39%
按下载量换算201

Codex

7.07%
按下载量换算115

github-copilot

3.3%
按下载量换算54

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

通过

权限和风险

敏感数据

该 Skill 可能接触密钥、Token、环境变量或敏感配置,应进入高风险复核队列,默认不自动发布。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。

来源信息

继续浏览同类 Skills