@crvouga/mockingbird-service-llamacloud

中文文档
3.11.0发布于 2026/11/11MITTypeScriptES Module构建来源已验证近 30 天下载 1.6万

Stateful emulator of the LlamaCloud platform API: project and pipeline lookup, pipeline documents, and deterministic (scripted or term-overlap) retrieval, verified against the official llama_cloud_services SDK.

原始使用文档
文档目录9 节
  1. Install
  2. Usage
  3. Routes
  4. Retrieval
  5. Python chat SDK: verified call sequence
  6. Admin (beyond the standard contract)
  7. Namespaces
  8. Deliberately not modelled
  9. API

@crvouga/mockingbird-service-llamacloud

Local emulators. Real API contracts. Part of Mockingbird.

Stateful emulator of the LlamaCloud platform API (LlamaIndex's managed indexes) for test suites: project and pipeline lookup, pipeline documents (list, get, insert, upsert, delete), and retrieval. Retrieval is deterministic: a scripted answer when a test sets one, otherwise a term-overlap ranking over the documents in the pipeline. The chat knowledge tools (search_health_knowledge, search_faq) and the EMR chatbot-admin knowledge CRUD run against it with no vendor account, no embeddings and no nondeterminism.

  • Operation coverage: SUPPORT.md
  • The contract (openapi.yaml) is hand-authored from the official Python client's wire models (llama-cloud 0.1.45) and our backend adapter.

Install

npm install -D @crvouga/mockingbird-service-llamacloud

ESM only. Node >= 22 or Bun >= 1.2. No native dependencies. Serve it with npx mockingbird-llamacloud serve, createServer from ./server (Node), or createRuntime with any Fetch server.

Usage

npx mockingbird-llamacloud serve --port 8805 --index acme-member-kb-v1 --project Default

Point the app at it:

ConsumerSetting
Backend LlamaCloudKnowledgeAdapterLLAMACLOUD_BASE_URL=http://127.0.0.1:8805/api/v1 (seam G-L1: the adapter hardcodes https://api.cloud.llamaindex.ai/api/v1 today), plus LLAMACLOUD_API_KEY (any value) and LLAMACLOUD_INDEX_NAME / LLAMACLOUD_PROJECT_NAME matching a seeded pipeline
Python chat service (llama_cloud_services)LLAMA_CLOUD_BASE_URL=http://127.0.0.1:8805 (no /api/v1; verified below, no code change needed)
import LlamaCloud from "@llamaindex/llama-cloud"
import { createRuntime } from "@crvouga/mockingbird-service-llamacloud"

// Test setup: a pipeline, and what retrieval answers for queries mentioning "apob".
// Anything else is ranked by term overlap over the documents the app upserted.
const emulator = createRuntime({ pipelines: [{ name: "acme-member-kb-v1", projectName: "Default" }] })
await emulator.fetch(
  new Request("http://llamacloud.test/__admin/retrieval", {
    method: "PUT",
    headers: { "content-type": "application/json" },
    body: JSON.stringify({
      match: { contains: "apob" },
      nodes: [{ text: "ApoB counts atherogenic particles.", score: 0.92, metadata: { file_name: "apob.md" } }],
    }),
  }),
)

// The LlamaCloud SDK your application already uses. Only its fetch changes: requests reach
// the emulator in this process instead of api.cloud.llamaindex.ai.
const llama = new LlamaCloud({
  apiKey: "llx-mockingbird",
  fetch: (url: RequestInfo | URL, init?: RequestInit) => emulator.fetch(new Request(url, init)),
})
const [pipeline] = await llama.pipelines.list({ project_name: "Default", pipeline_name: "acme-member-kb-v1" })
const { retrieval_nodes } = await llama.pipelines.retrieve(pipeline?.id ?? "", { query: "What does ApoB measure?" })
console.log(retrieval_nodes[0]?.node.text, retrieval_nodes[0]?.score) // ApoB counts atherogenic particles. 0.92

Routes

All under Authorization: Bearer <key> (any non-empty key unless apiKeys is set). Errors are FastAPI-shaped: {"detail": "…"}, and 422 {"detail": [{loc, msg, type}]}.

RouteBehaviour
GET /api/v1/projects?project_name=Projects with that exact name ([] when none).
GET /api/v1/projects/{id}One project, or 404.
GET /api/v1/pipelines?project_name=&project_id=&pipeline_name=&pipeline_type=Pipelines matching every filter given: [{id, name, project_id, pipeline_type: "MANAGED", embedding_config, status: "CREATED", …}]. The backend filters by project_name and picks name == LLAMACLOUD_INDEX_NAME.
GET /api/v1/pipelines/{id}One pipeline, or 404.
POST /api/v1/pipelines/{id}/retrieve{query, dense_similarity_top_k?, …} → {pipeline_id, retrieval_nodes: [{node: {id_, text, metadata, extra_info, …}, score}], …}. Top-k defaults to 5.
GET /api/v1/pipelines/{id}/documents?skip=&limit=[{id, text, metadata, …}], oldest first.
PUT /api/v1/pipelines/{id}/documentsUpsert [{id?, text, metadata}] by id (the backend uses the slug); a missing id gets a UUID. Answers the stored documents.
POST /api/v1/pipelines/{id}/documentsSame as PUT (the SDK's insert).
GET /api/v1/pipelines/{id}/documents/{docId}One document, or 404.
DELETE /api/v1/pipelines/{id}/documents/{docId}204, or 404 for an unknown document.

Retrieval

  1. Scripted. PUT /__admin/retrieval {match: {contains?, pipeline?}, nodes: [{text, score?, metadata?}]} adds a rule. The most recently added rule whose contains appears in the query (case-insensitive) and whose pipeline (id or name) matches answers its nodes verbatim, truncated to top-k. A node without a score gets 1, 0.9, 0.8, … Node ids are scripted_<n>.
  2. Default: term overlap. Terms are lower-cased alphanumeric words of 2+ characters minus common stopwords. A document's score is the share of the query's distinct terms found in its text or metadata.title, rounded to 4 places. Non-matching documents are dropped and ties keep insertion order. Each document is one node (id_: "<docId>_0"), and its metadata gains document_id and pipeline_id, the fields the backend reads.

Node metadata is sent under both metadata (read by our backend) and extra_info (the official client model's field name). Without live credentials, which of the two the real API sends is unverified.

Python chat SDK: verified call sequence

The catalog listed this as unverified. It has now been checked against the installed SDK: llama-cloud-services 0.6.88, llama-cloud 0.1.45 and llama-index-core 0.14.10, the versions the consumer app's Python chat service pins. The wheels were read, and llamacloud.sdk.test.ts runs that service's real LlamaCloudClient file on the real SDK against the served emulator. LlamaCloudIndex(name, project_name=…, api_key=…) followed by .as_retriever(similarity_top_k=5).aretrieve(q) makes these calls:

  1. GET /api/v1/projects?project_name=<name>: resolve_project. No match raises No project found with name …, and more than one match raises too.
  2. GET /api/v1/pipelines?project_id=<id>&pipeline_name=<index>&pipeline_type=MANAGED: resolve_pipeline. No match raises Unknown index name ….
  3. GET /api/v1/pipelines/{id}, then GET /api/v1/projects/{project_id}: as_retriever() builds a LlamaCloudRetriever(project_id=…, pipeline_id=…), which resolves both again by id.
  4. POST /api/v1/pipelines/{id}/retrieve {query, dense_similarity_top_k: 5}.

The base URL comes from base_url or LLAMA_CLOUD_BASE_URL, falling back to https://api.cloud.llamaindex.ai (llama_index.core.ingestion.api_utils.get_client). The client passes no base_url, so setting the environment variable is enough. The SDK's pydantic models are strict: Pipeline.status must be CREATED or DELETING, and embedding_config is required. The emulator satisfies both, and the SDK test fails if a shape drifts.

Discrepancy: the Python client's llamacloud_project_name defaults to "default" (lowercase). The backend's default is "Default". Project lookup is exact, so it needs LLAMACLOUD_PROJECT_NAME=Default, or a seeded default project. Otherwise the client degrades to empty results, which the acceptance tests cover.

To run the SDK test:

uv venv /tmp/llama && VIRTUAL_ENV=/tmp/llama uv pip install \
  llama-cloud-services==0.6.88 llama-cloud==0.1.45 llama-index-core==0.14.10
MOCKINGBIRD_LLAMACLOUD_PYTHON=/tmp/llama/bin/python \
  MOCKINGBIRD_LLAMACLOUD_PY_CLIENT=/path/to/llamacloud_client.py bun test llamacloud.sdk

Admin (beyond the standard contract)

RouteEffect
GET /__admin/pipelinesThe namespace's projects and pipelines.
PUT /__admin/pipelines{name, projectName?} creates a managed pipeline, and its project if needed. The ids are stable UUIDs derived from the namespace and names.
GET /__admin/pipelines/:pipeline/documentsA pipeline's documents, by id or name.
GET /__admin/retrievalThe scripted rules, newest first.
PUT /__admin/retrievalAdd one rule, or replace them all with {rules: [...]} (the first listed wins).
DELETE /__admin/retrievalClear the rules.
GET/PUT /__admin/settings{apiKeys?: string[], defaultTopK?: number} for the calling namespace.

Fault presets (POST /__admin/faults {"preset": "<name>", "count"?: n}; GET /__admin/faults/presets):

PresetEffect
index_missingPipeline search answers [].
retrieval_emptyRetrieval answers no nodes.
documents_unexpected_shapeThe document list answers an object instead of an array.
unauthorizedEvery call answers 401.
rate_limitedEvery call answers 429.
server_errorEvery call answers 500.
slow_retrievalRetrieval is delayed by 3 s, or by latencyMs when given.

Namespaces

Neither consumer can add headers, so a namespace can be chosen three ways:

  • the x-mockingbird-namespace header;
  • a /__admin/ns/<name> prefix on the base URL;
  • the API key: PUT /__admin/credentials {"credentials": {"<LLAMACLOUD_API_KEY>": "<namespace>"}}.

Each namespace starts with the seeded pipelines, by default acme-member-kb-v1 in project Default. The request journal records operation ids, statuses and pipeline and document ids. It never records queries, document text or titles.

Deliberately not modelled

  • Real retrieval quality: no embeddings, chunking, hybrid search, reranking, metadata filters, image or page-figure nodes, or retrieval_mode routing. A document is always one node.
  • Pipeline ingestion status and sync jobs. Upserted documents can be retrieved immediately.
  • File uploads (/api/v1/files, pipeline_files), data sources, parsing (LlamaParse) and extraction.
  • Creating projects or pipelines through the API. Use the seed or PUT /__admin/pipelines.
  • Organizations beyond one per namespace.

API

ExportKindDescription
LlamaCloudAPIclassThe in-process emulator: fetch(request), reset(), documents(pipeline), addRule(rule), rules(), clearRules(), state. Options: sqlite, now, namespace, pipelines, settings.
createRuntimefunctionThe emulator with the full service contract (health, admin, namespaces, credentials, presets). Options: pipelines, settings, clock, seed, adminKey, onLog, sqlite.
LLAMACLOUD_PRESETSobjectEvery named fault preset.
LLAMACLOUD_NAMESPACEstringThe service name, "llamacloud".
DEFAULT_PIPELINES, DEFAULT_PIPELINE_NAME, DEFAULT_PROJECT_NAME, DEFAULT_SETTINGSvaluesThe seed: acme-member-kb-v1 in Default, top-k 5, any key.
rank, termsfunctionsThe default term-overlap ranking and its tokenizer.
uuidFromfunctionThe stable UUID derivation used for project, pipeline and document ids.
document, operationIds, supportedOperationIdsvaluesThe vendored OpenAPI contract and its operation ids.
createServer, serveTarget, DEFAULT_PORT (./server)NodeServe over node:http; the serve CLI target (--index, --project, --api-key); port 8805.

Part of mockingbird.

版本与发布记录

@crvouga/mockingbird-service-llamacloud 共发布 42 个版本,首次发布于 2026/09/23;过去 12 个月发布了 42 个版本。最新版本附带 npm provenance 构建来源证明,可追溯到公开的 CI 构建记录。

版本发布日期距今
3.11.0latest2026/11/11今天
3.10.92026/11/038 天前
3.10.82026/11/038 天前
3.10.72026/11/038 天前
3.10.62026/11/038 天前
3.10.52026/11/038 天前

关于 @crvouga/mockingbird-service-llamacloud 的常见问题

@crvouga/mockingbird-service-llamacloud 是什么?

Stateful emulator of the LlamaCloud platform API: project and pipeline lookup, pipeline documents, and deterministic (scripted or term-overlap) retrieval, verified against the official llama_cloud_services SDK.

如何安装 @crvouga/mockingbird-service-llamacloud?

在项目目录运行 npm install @crvouga/mockingbird-service-llamacloud,或使用 pnpm add / yarn add / bun add。它还提供命令行工具 mockingbird-llamacloud,可以用 npx mockingbird-llamacloud 直接运行。

@crvouga/mockingbird-service-llamacloud 支持 TypeScript 吗?

支持。包内自带 TypeScript 类型声明(package.json 声明了 types 入口),安装后即可获得类型提示,无需再安装 @types 包。

@crvouga/mockingbird-service-llamacloud 支持 ESM 还是 CommonJS?

以 ES Module 形式发布,推荐使用 import 引入。在 CommonJS 项目中,Node.js 20.19+ / 22.12+ 可以直接 require() 不含顶层 await 的 ES Module,更早的版本需要改用动态 import()。

@crvouga/mockingbird-service-llamacloud 可以商用吗?

@crvouga/mockingbird-service-llamacloud 使用 MIT 许可。宽松许可:允许商业使用、修改和再分发,通常只需在分发时保留原版权与许可声明。以上为概括,不构成法律意见,请以许可原文为准。

@crvouga/mockingbird-service-llamacloud 的下载量有多少?

根据 npm 官方下载统计,@crvouga/mockingbird-service-llamacloud 在 2026/10/11 – 2026/11/09 这 30 天内被下载 16,221 次,日均约 541 次。下载量会把 CI 构建、镜像同步和作为其他包依赖的安装一并计入,适合横向比较热度,不能直接等同于使用人数。

@crvouga/mockingbird-service-llamacloud 还在维护吗?

最新版本 3.11.0 发布于 2026/11/11(今天);至今共发布 42 个版本,其中过去 12 个月发布了 42 个;首次发布于 2026/09/23。发布频率只是参考信号:功能稳定的工具可能很少需要更新,建议结合源码仓库的 issue 和提交记录判断。