Token导航 LogoToken导航TokenDH.com
研究检索需要联网github未标认证来源可访问clear审计提醒

cloudflare-vectorizecloudflare 矢量化

Agent Skill

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

总安装

950

周安装

40

GitHub Stars

37

下载量

333
CodexClaudeCursorGemini CLI

安装说明

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

GitHub

来源数

3

许可证

MIT

最后核验

2026-05-01

来源状态

来源可访问

安装方式

通过对话安装

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

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

命令行安装

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

skills.shnpx skills
npx skills add https://github.com/ovachiever/droid-tings --skill cloudflare-vectorize

简介

构建基于向量检索的 RAG 应用,支持语义搜索与 AI 增强问答。

  • 提供索引创建、Embedding 生成、相似度查询与结果排序全流程指导。
  • 可与 Workers AI 集成,实现低延迟向量计算与缓存优化。
  • 需配置 wrangler.jsonc 并声明 vectorize 绑定,选择合适的分片策略。
  • 数据更新频率与召回阈值应根据业务场景调整,避免过时答案误导。

SKILL.md

Cloudflare Vectorize

Complete implementation guide for Cloudflare Vectorize - a globally distributed vector database for building semantic search, RAG (Retrieval Augmented Generation), and AI-powered applications with Cloudflare Workers.

Status: Production Ready ✅ Last Updated: 2025-10-21 Dependencies: cloudflare-worker-base (for Worker setup), cloudflare-workers-ai (for embeddings) Latest Versions: wrangler@4.43.0, @cloudflare/workers-types@4.20251014.0 Token Savings: ~65% Errors Prevented: 8 Dev Time Saved: ~3 hours

What This Skill Provides

Core Capabilities

  • Index Management: Create, configure, and manage vector indexes
  • Vector Operations: Insert, upsert, query, delete, and list vectors
  • Metadata Filtering: Advanced filtering with 10 metadata indexes per index
  • Semantic Search: Find similar vectors using cosine, euclidean, or dot-product metrics
  • RAG Patterns: Complete retrieval-augmented generation workflows
  • Workers AI Integration: Native embedding generation with @cf/baai/bge-base-en-v1.5
  • OpenAI Integration: Support for text-embedding-3-small/large models
  • Document Processing: Text chunking and batch ingestion pipelines

Templates Included

  1. basic-search.ts - Simple vector search with Workers AI
  2. rag-chat.ts - Full RAG chatbot with context retrieval
  3. document-ingestion.ts - Document chunking and embedding pipeline
  4. metadata-filtering.ts - Advanced filtering patterns

⚠️ Vectorize V2 Breaking Changes (September 2024)

IMPORTANT: Vectorize V2 became GA in September 2024 with significant breaking changes.

What Changed in V2

Performance Improvements:

  • Index capacity: 200,000 → 5 million vectors per index
  • Query latency: 549ms → 31ms median (18× faster)
  • TopK limit: 20 → 100 results per query
  • Scale limits: 100 → 50,000 indexes per account
  • Namespace limits: 100 → 50,000 namespaces per index

Breaking API Changes:

  1. Async Mutations - All mutations now asynchronous: // V2: Returns mutationId const result = await env.VECTORIZE_INDEX.insert(vectors); console.log(result.mutationId); // "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx" // Vector inserts/deletes may take a few seconds to be reflected
  2. returnMetadata Parameter - Boolean → String enum: // ❌ V1 (deprecated) {returnMetadata: true} // ✅ V2 (required) {returnMetadata: 'all' | 'indexed' | 'none'}
  3. Metadata Indexes Required Before Insert:

- V2 requires metadata indexes created BEFORE vectors inserted - Vectors added before metadata index won't be indexed - Must re-upsert vectors after creating metadata index

V1 Deprecation Timeline:

  • December 2024: Can no longer create V1 indexes
  • Existing V1 indexes: Continue to work (other operations unaffected)
  • Migration: Use wrangler vectorize --deprecated-v1 flag for V1 operations

Wrangler Version Required:

  • Minimum: wrangler@3.71.0 for V2 commands
  • Recommended: wrangler@4.43.0+ (latest)

Check Mutation Status

// Get index info to check last mutation processed
const info = await env.VECTORIZE_INDEX.describe();
console.log(info.mutationId); // Last mutation ID
console.log(info.processedUpToMutation); // Last processed timestamp

Critical Setup Rules

⚠️ MUST DO BEFORE INSERTING VECTORS

# 1. Create the index with FIXED dimensions and metric
npx wrangler vectorize create my-index \
  --dimensions=768 \
  --metric=cosine

# 2. Create metadata indexes IMMEDIATELY (before inserting vectors!)
npx wrangler vectorize create-metadata-index my-index \
  --property-name=category \
  --type=string

npx wrangler vectorize create-metadata-index my-index \
  --property-name=timestamp \
  --type=number

Why: Metadata indexes MUST exist before vectors are inserted. Vectors added before a metadata index was created won't be filterable on that property.

Index Configuration (Cannot Be Changed Later)

# Dimensions MUST match your embedding model output:
# - Workers AI @cf/baai/bge-base-en-v1.5: 768 dimensions
# - OpenAI text-embedding-3-small: 1536 dimensions
# - OpenAI text-embedding-3-large: 3072 dimensions

# Metrics determine similarity calculation:
# - cosine: Best for normalized embeddings (most common)
# - euclidean: Absolute distance between vectors
# - dot-product: For non-normalized vectors

Wrangler Configuration

wrangler.jsonc:

{
  "name": "my-vectorize-worker",
  "main": "src/index.ts",
  "compatibility_date": "2025-10-21",
  "vectorize": [
    {
      "binding": "VECTORIZE_INDEX",
      "index_name": "my-index"
    }
  ],
  "ai": {
    "binding": "AI"
  }
}

TypeScript Types

export interface Env {
  VECTORIZE_INDEX: VectorizeIndex;
  AI: Ai;
}

interface VectorizeVector {
  id: string;
  values: number[] | Float32Array | Float64Array;
  namespace?: string;
  metadata?: Record<string, string | number | boolean | string[]>;
}

interface VectorizeMatches {
  matches: Array<{
    id: string;
    score: number;
    values?: number[];
    metadata?: Record<string, any>;
    namespace?: string;
  }>;
  count: number;
}

Metadata Filter Operators (V2)

Vectorize V2 supports advanced metadata filtering with range queries:

// Equality (implicit $eq)
{ category: "docs" }

// Not equals
{ status: { $ne: "archived" } }

// In/Not in arrays
{ category: { $in: ["docs", "tutorials"] } }
{ category: { $nin: ["deprecated", "draft"] } }

// Range queries (numbers) - NEW in V2
{ timestamp: { $gte: 1704067200, $lt: 1735689600 } }

// Range queries (strings) - prefix searching
{ url: { $gte: "/docs/workers", $lt: "/docs/workersz" } }

// Nested metadata with dot notation
{ "author.id": "user123" }

// Multiple conditions (implicit AND)
{ category: "docs", language: "en", "metadata.published": true }

Metadata Best Practices

1. Cardinality Considerations

Low Cardinality (Good for $eq filters):

// Few unique values - efficient filtering
metadata: {
  category: "docs",        // ~10 categories
  language: "en",          // ~5 languages
  published: true          // 2 values (boolean)
}

High Cardinality (Avoid in range queries):

// Many unique values - avoid large range scans
metadata: {
  user_id: "uuid-v4...",         // Millions of unique values
  timestamp_ms: 1704067200123    // Use seconds instead
}

2. Metadata Limits

  • Max 10 metadata indexes per Vectorize index
  • Max 10 KiB metadata per vector
  • String indexes: First 64 bytes (UTF-8)
  • Number indexes: Float64 precision
  • Filter size: Max 2048 bytes (compact JSON)

3. Key Restrictions

// ❌ INVALID metadata keys
metadata: {
  "": "value",              // Empty key
  "user.name": "John",      // Contains dot (reserved for nesting)
  "$admin": true,           // Starts with $
  "key\"with\"quotes": 1    // Contains quotes
}

// ✅ VALID metadata keys
metadata: {
  "user_name": "John",
  "isAdmin": true,
  "nested": { "allowed": true }  // Access as "nested.allowed" in filters
}

Common Errors & Solutions

Error 1: Metadata Index Created After Vectors Inserted

Problem: Filtering doesn't work on existing vectors
Solution: Delete and re-insert vectors OR create metadata indexes BEFORE inserting

Error 2: Dimension Mismatch

Problem: "Vector dimensions do not match index configuration"
Solution: Ensure embedding model output matches index dimensions:
  - Workers AI bge-base: 768
  - OpenAI small: 1536
  - OpenAI large: 3072

Error 3: Invalid Metadata Keys

Problem: "Invalid metadata key"
Solution: Keys cannot:
  - Be empty
  - Contain . (dot)
  - Contain " (quote)
  - Start with $ (dollar sign)

Error 4: Filter Too Large

Problem: "Filter exceeds 2048 bytes"
Solution: Simplify filter or split into multiple queries

Error 5: Range Query on High Cardinality

Problem: Slow queries or reduced accuracy
Solution: Use lower cardinality fields for range queries, or use seconds instead of milliseconds for timestamps

Error 6: Insert vs Upsert Confusion

Problem: Updates not reflecting in index
Solution: Use upsert() to overwrite existing vectors, not insert()

Error 7: Missing Bindings

Problem: "VECTORIZE_INDEX is not defined"
Solution: Add [[vectorize]] binding to wrangler.jsonc

Error 8: Namespace vs Metadata Confusion

Problem: Unclear when to use namespace vs metadata filtering
Solution:
  - Namespace: Partition key, applied BEFORE metadata filters
  - Metadata: Flexible key-value filtering within namespace

Error 9: V2 Async Mutation Timing (NEW in V2)

Problem: Inserted vectors not immediately queryable
Solution: V2 mutations are asynchronous - vectors may take a few seconds to be reflected
  - Use mutationId to track mutation status
  - Check env.VECTORIZE_INDEX.describe() for processedUpToMutation timestamp

Error 10: V1 returnMetadata Boolean (BREAKING in V2)

Problem: "returnMetadata must be 'all', 'indexed', or 'none'"
Solution: V2 changed returnMetadata from boolean to string enum:
  - ❌ V1: { returnMetadata: true }
  - ✅ V2: { returnMetadata: 'all' }

V2 Migration Checklist

If migrating from V1 to V2:

  1. ✅ Update wrangler to 3.71.0+ (npm install -g wrangler@latest)
  2. ✅ Create new V2 index (can't upgrade V1 → V2)
  3. ✅ Create metadata indexes BEFORE inserting vectors
  4. ✅ Update returnMetadata boolean → string enum ('all', 'indexed', 'none')
  5. ✅ Handle async mutations (expect mutationId in responses)
  6. ✅ Test with V2 limits (topK up to 100, 5M vectors per index)
  7. ✅ Update error handling for async behavior

V1 Deprecation:

  • After December 2024: Cannot create new V1 indexes
  • Existing V1 indexes: Continue to work
  • Use wrangler vectorize --deprecated-v1 for V1 operations

Official Documentation


Status: Production Ready ✅ (Vectorize V2 GA - September 2024) Last Updated: 2025-11-22 Token Savings: ~70% Errors Prevented: 10 (includes V2 breaking changes)

适合场景

01

研究助手

02

事实核查

03

知识库问答

04

带来源的搜索总结

能力概览

能力 1

组合搜索和大模型调用

能力 2

支持多来源检索和总结

能力 3

强调引用来源和事实核查

能力 4

适合研究型 Agent 流程

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

平台分布

Claude Code

29.09%
按下载量换算97

Antigravity

24.17%
按下载量换算80

Gemini CLI

18.68%
按下载量换算62

OpenCode

11.29%
按下载量换算38

github-copilot

8.17%
按下载量换算27

Codex

3.5%
按下载量换算12

安全审计

Gen Agent Trust Hub

通过

Socket

通过

Snyk

可疑

权限和风险

需要联网

该 Skill 可能需要联网访问来源站点、仓库或外部 API;具体网络访问范围需要结合源码和 README 复核。

安装前确认

本站仅展示第三方公开信息,不托管安装包,不提供自动安装或运行环境。安装前应自行审查源码、依赖和命令行为。来源安全扫描存在 warning/failed 结果,不能写成本站确认安全。

来源信息

继续浏览同类 Skills