Self-evolving Context Database for AI Agents. Unify Agent Memory, Knowledge RAG and Skills.
Python agent-contextagent-memoryagent-pluginsagentic-ragcontext-databasedsh-pluginknowledge-basememorymemory-managementself-evolvingvector-database
docs: align bilingual guides and add consistency checks (#5188)
Zayn Jarvis0b3ecd9a6a5b
diff --git a/.github/workflows/_docs.yml b/.github/workflows/_docs.ymlindex 1fbabb2bc..dc22e5241 100644--- a/.github/workflows/_docs.yml+++ b/.github/workflows/_docs.yml@@ -28,6 +28,10 @@ jobs:run: npm run test:themeworking-directory: docs+ - name: Check bilingual docs and examples+ run: npm run check:docs+ working-directory: docs+- name: Check API referencerun: npm run check:apiworking-directory: docsdiff --git a/docs/.vitepress/config.ts b/docs/.vitepress/config.tsindex e25ab1ccf..7d5d485fb 100644--- a/docs/.vitepress/config.ts+++ b/docs/.vitepress/config.ts@@ -431,7 +431,8 @@ const guidesSidebar = {items: [['05-observability.md', 'Observability & Diagnostics'],['07-operation-telemetry.md', 'Operation Telemetry'],- ['11-grafana-prometheus.md', 'Prometheus / Grafana']+ ['11-grafana-prometheus.md', 'Prometheus / Grafana'],+ ['12-vikingbot-metrics-validation.md', 'VikingBot Metrics Validation']]},{diff --git a/docs/en/agent-integrations/15-agent-plugins.md b/docs/en/agent-integrations/15-agent-plugins.mdindex 92917dadf..3b57ea51a 100644--- a/docs/en/agent-integrations/15-agent-plugins.md+++ b/docs/en/agent-integrations/15-agent-plugins.md@@ -46,8 +46,9 @@ Highest to lowest priority — the same chain as the `ov` CLI and the other Open`OPENVIKING_CREDENTIAL_SOURCE` (or `OPENVIKING_CREDENTIALS_SOURCE`) pins the chain to one end: `env` for the environment, `cli` (also `ovcli` / `file` / `config`) for ovcli.conf. The default `auto` pins it to ovcli.conf when that file carries credentials and none of the variables above is set, and runs the whole chain otherwise. While the chain is pinned to ovcli.conf, the environment's credentials and `OPENVIKING_MCP_URL` are skipped. A key still falls through the `plugin` keys, the `agent_plugins` section and finally `server.root_api_key`, so an install that names only a `url` there keeps the key it has always used; the account and user stop at the `plugin` keys. `env` reads neither file.+`~/.openviking/ovcli.conf`:+```json-// ~/.openviking/ovcli.conf{"url": "https://openviking.example.com","api_key": "your-api-key"diff --git a/docs/en/api/99-api-doc-writing-guide.md b/docs/en/api/99-api-doc-writing-guide.mdindex 79d8dce46..c6ebe0728 100644--- a/docs/en/api/99-api-doc-writing-guide.md+++ b/docs/en/api/99-api-doc-writing-guide.md@@ -2,6 +2,15 @@This document defines the unified structure and writing conventions for API module documentation in the `docs/en/api/` directory.+## Keep documentation current++- Update the English and Chinese pages in the same PR, including navigation and examples. Keep one canonical explanation and link to it from related pages.+- Lead with the reader's task, prerequisites, a working example, and its expected result. Move implementation details below the usage instructions.+- Verify defaults and supported options against the current implementation. Distinguish released behavior from work on `main` and future plans; link to the relevant release or PR when it matters.+- Use valid JSON for copyable configuration. Label fragments or pseudocode explicitly; do not mix comments into a `json` block.+- Link to official documentation for external tools and services. Describe only the setup needed here instead of duplicating their manuals.+- Before submitting, run `npm run check:docs`, `npm run check:api`, and `npm run docs:build` from `docs/`. Automated checks cover structure and examples, not factual correctness or translation quality.+## Directory StructureAPI documentation is organized by module, with one file per module, using a two-digit numerical prefix.diff --git a/docs/en/guides/01-configuration.md b/docs/en/guides/01-configuration.mdindex 0e0f5d3c6..af4d803f7 100644--- a/docs/en/guides/01-configuration.md+++ b/docs/en/guides/01-configuration.md@@ -1497,6 +1497,7 @@ Supports cloud-deployed VikingDB on Volcengine"ak": "your-access-key","sk": "your-secret-key"}+ }}}```diff --git a/docs/en/guides/12-vikingbot-metrics-validation.md b/docs/en/guides/12-vikingbot-metrics-validation.mdnew file mode 100644index 000000000..4403e0038--- /dev/null+++ b/docs/en/guides/12-vikingbot-metrics-validation.md@@ -0,0 +1,200 @@+# Validate Vikingbot metrics with real conversations++Use this guide after [setting up Prometheus and Grafana](11-grafana-prometheus.md) to check the complete path:++```text+Chat → persisted bot session → feedback / follow-up → /metrics → Prometheus → Grafana+```++## Prerequisites++- Start OpenViking with `server.observability.metrics.enabled=true` and `openviking-server --with-bot --port 30300`.+- Confirm `/bot/v1/health` returns HTTP 200 and `/metrics` returns Prometheus exposition text.+- Confirm Prometheus scrapes OpenViking and Grafana uses that Prometheus data source.++The localhost setup in the previous guide uses OpenViking at `http://127.0.0.1:30300`, Prometheus at `http://127.0.0.1:30909`, and Grafana at `http://127.0.0.1:13000`. If authentication is enabled, include the credentials required by your deployment in each request; see [Authentication](04-authentication.md).++## How to interpret the metrics++Feedback metrics are **snapshot gauges**, including names ending in `_total`. `FeedbackCollector` aggregates persisted `metadata.feedback_events` and `metadata.response_outcomes` from `<bot_data_path>/sessions/*.jsonl`. Its default refresh TTL is 30 seconds, so repeated scrapes can reuse a snapshot. Allow a collector refresh and a subsequent Prometheus scrape before comparing values.++Use current values or a short time window, rather than counter-style `rate()`. Select `valid="1"`; `valid="0"` is a fallback snapshot after collection failure and is unsuitable for acceptance checks. See the [Prometheus metric types](https://prometheus.io/docs/concepts/metric_types/) for the gauge/counter distinction.++Use a fresh session ID for each scenario. Totals cover all persisted sessions, so other traffic can affect the result. Proportions may barely move when historical sample counts are large. Outcome totals can decrease when an existing response is reclassified.++## Record a baseline++Run these queries in Prometheus or Grafana Explore's table view:++```promql+openviking_service_readiness{valid="1"}+openviking_component_health{valid="1"}+openviking_queue_pending+openviking_vikingdb_collection_vectors{valid="1"}+openviking_model_usage_available{valid="1"}+```++Run each expression separately. Readiness should be `1`; healthy components normally report `1`. Queue depth should be small or zero. Collection vector counts and model-usage availability depend on the configured services and need not change during a bot conversation.++Record the feedback snapshot too:++```promql+{__name__=~"openviking_feedback.*",valid="1"}+```++## 1. Chat and confirm persistence++```bash+curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \+ -H "Content-Type: application/json" \+ -d '{+ "session_id": "realcase-01-chat",+ "user_id": "metrics-validation-user",+ "message": "Describe OpenViking in one sentence."+ }'+```++Expect HTTP 200 with `session_id`, `response_id`, and a nonempty `message`. Save the response ID for feedback.++After refresh, `openviking_feedback_responses_total{valid="1"}` should normally increase by one. A new session file also increases `openviking_feedback_sessions_scanned_total{valid="1"}`. Ordinary chat alone does not create an explicit feedback event.++## 2. Submit positive feedback++Send another chat using `session_id: "realcase-02-thumb-up"`, then replace `<response_id>` below with that chat's response ID:++```bash+curl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \+ -H "Content-Type: application/json" \+ -d '{+ "session_id": "realcase-02-thumb-up",+ "response_id": "<response_id>",+ "feedback_type": "thumb_up",+ "feedback_text": "helpful"+ }'+```++Expect `accepted: true`. For a response with no previous feedback, these gauges normally increase by one:++```promql+openviking_feedback_events_total{valid="1"}+openviking_feedback_thumb_up_total{valid="1"}+openviking_feedback_responses_with_feedback_total{valid="1"}+openviking_feedback_positive_outcomes_total{valid="1"}+```++`coverage`, `thumbs_up_rate`, and `one_turn_resolution_rate` can also change. The implementation includes both `resolved` and `positive_feedback` in one-turn resolution. Check totals first; aggregate proportions depend on all previous responses and outcomes.++## 3. Submit negative feedback++Chat with a fresh session, `realcase-03-thumb-down`, then send the same feedback request with that session's response ID, `feedback_type: "thumb_down"`, and `feedback_text: "not helpful"`.++Expect the following totals to increase by one after refresh:++```promql+openviking_feedback_events_total{valid="1"}+openviking_feedback_thumb_down_total{valid="1"}+openviking_feedback_negative_outcomes_total{valid="1"}+```++`openviking_feedback_thumbs_down_rate` and `openviking_feedback_negative_feedback_rate` may change too. Positive-feedback and reask totals should not increase from this action alone.++## 4. Follow up within ten minutes++Chat using `realcase-04-reask`. Without submitting feedback, send a second message to the same session within ten minutes of the assistant response:++```bash+curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \+ -H "Content-Type: application/json" \+ -d '{+ "session_id": "realcase-04-reask",+ "user_id": "metrics-validation-user",+ "message": "Please explain that more concretely."+ }'+```++The **previous** assistant response is classified as `reasked`; this classification uses timing, not the semantic similarity of the questions.++```promql+openviking_feedback_reasked_outcomes_total{valid="1"}+openviking_feedback_reask_rate{valid="1"}+```++The reasked total normally increases by one. The second assistant response also increases `responses_total`. Explicit feedback totals should stay unchanged.++## 5. Follow up after ten minutes++Chat using `realcase-05-followup-no-feedback`, submit no feedback, and wait **more than ten minutes** after the assistant response. Send another message to the same session.++```promql+openviking_feedback_follow_up_without_feedback_outcomes_total{valid="1"}+```++The previous response should now be classified as `follow_up_without_feedback`, increasing this total by one. A follow-up at or before the ten-minute boundary instead qualifies as `reasked`. Explicit feedback totals stay unchanged.++## 6. Understand the `resolved` outcome++A response with no subsequent user message is classified as `resolved` **when the outcome evaluator runs**. The metrics collector only reads stored outcomes; it does not run an inactivity timer or create a resolved outcome after ten minutes.++```promql+openviking_feedback_resolved_outcomes_total{valid="1"}+```++A new chat followed by silence is therefore not a deterministic acceptance test for this metric. Inspect persisted `metadata.response_outcomes` if a resolved sample is expected. Use the positive, negative, and follow-up scenarios above as the repeatable acceptance path.++## 7. Check channel-level metrics++This scenario requires an enabled `bot_api` channel whose ID is `demo`. Chat through `/bot/v1/chat/channel`:++```bash+curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat/channel" \+ -H "Content-Type: application/json" \+ -d '{+ "session_id": "realcase-07-channel-demo",+ "user_id": "metrics-validation-user",+ "channel_id": "demo",+ "message": "Describe OpenViking briefly."+ }'+```++Submit feedback with the returned response ID and the same `channel_id`:++```bash+curl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \+ -H "Content-Type: application/json" \+ -d '{+ "session_id": "realcase-07-channel-demo",+ "response_id": "<response_id>",+ "channel_id": "demo",+ "feedback_type": "thumb_down",+ "feedback_text": "not helpful"+ }'+```++Check the target channel:++```promql+openviking_feedback_channel_events_total{channel="bot_api__demo",valid="1"}+openviking_feedback_channel_negative_outcomes_total{channel="bot_api__demo",valid="1"}+openviking_feedback_channel_thumbs_down_rate{channel="bot_api__demo",valid="1"}+```++The channel's event and negative-outcome totals should increase. Other channels should not change because of this request. A missing configured channel returns `404`; plain `/bot/v1/chat` does not exercise this channel route.++## Acceptance and troubleshooting++For a minimal check, require readiness `1`, a persisted chat response, increased positive and negative feedback totals, and an increased reasked total after a prompt follow-up. Validate channel totals separately if your deployment uses channels.++| Symptom | Check |+| --- | --- |+| Chat succeeds but feedback totals stay unchanged | Submit explicit feedback; ordinary chat does not create feedback events. |+| A recent event is missing | Allow the 30-second collector TTL, background refresh, and the next Prometheus scrape; then inspect session persistence. |+| Totals change but proportions barely move | Historical samples dilute a single event. Compare current totals in table view. |+| Only `valid="0"` is present | Inspect collector errors and access to the bot session directory. |+| `bot_api__demo` is missing | Check the enabled channel ID, `/chat/channel` endpoint, and matching feedback `channel_id`. |++## Related documentation++- [Observability and troubleshooting](05-observability.md)+- [Prometheus and Grafana setup](11-grafana-prometheus.md)+- [Metrics concepts](../concepts/12-metrics.md)+- [Metrics API](../api/09-metrics.md)diff --git a/docs/en/guides/16-cuvs.md b/docs/en/guides/16-cuvs.mdindex baffec25c..1e024ebeb 100644--- a/docs/en/guides/16-cuvs.md+++ b/docs/en/guides/16-cuvs.md@@ -2,6 +2,10 @@The `cuvs` backend keeps OpenViking's embedded record store, scalar indexes, sparse retrieval, and recovery logic, while executing dense vector search with NVIDIA cuVS. cuVS 26.06 Python wheels require Python 3.11 or newer.+## Requirements and installation++Use Linux x86_64 or aarch64 with a supported NVIDIA GPU and a compatible CUDA driver. Check the [cuVS installation requirements](https://docs.nvidia.com/cuvs/installation) and [Python package guide](https://docs.nvidia.com/cuvs/installation/python) for the selected release. Current cuVS source builds require CUDA Toolkit 12.2 or newer and Ampere or newer GPUs; package requirements depend on the chosen release.+Install the package matching the host CUDA major version:```bash@@ -14,6 +18,8 @@ pip install -e .pip install cuvs-cu13 'cupy-cuda13x[ctk]' --extra-index-url=https://pypi.nvidia.com```+## Configuration+Start with exact brute-force search:```json@@ -38,6 +44,28 @@ Start with exact brute-force search:Set `algorithm` to `cagra` for approximate graph search. `build_params` and `search_params` are passed to cuVS `cagra.IndexParams` and `cagra.SearchParams` respectively.+```json+{+ "storage": {+ "vectordb": {+ "backend": "cuvs",+ "cuvs": {+ "algorithm": "cagra",+ "build_params": {+ "graph_degree": 64,+ "intermediate_graph_degree": 128,+ "build_algo": "nn_descent"+ },+ "search_params": {+ "itopk_size": 64,+ "search_width": 1+ }+ }+ }+ }+}+```+### Memory-aware auto modeKeep `backend` set to `local` and enable `cuvs.auto_enable` to use otherwise@@ -134,6 +162,8 @@ This is why auto mode initializes the runtime first, reads the remaining freememory, and then applies a conservative safety factor and independent reserverather than admitting from the vector payload alone.+Cosine search L2-normalizes vectors before computing inner products. L2 scores use `1 - squared_l2`, so larger scores remain better matches.+## Data type and native-index behaviorEnabling cuVS does not change OpenViking's default backend or rewrite the@@ -256,8 +286,63 @@ store and repopulate cuVS after restart.The `[ctk]` CuPy extra installs the CUDA toolkit headers required by the cuVSPython interop path, even when the host provides a CUDA driver but no toolkit.+## Minimal validation+After installation, run `python examples/cuvs_smoke.py` for an exactGPU-backed write and filtered-search check, or`python examples/cuvs_smoke.py --algorithm cagra` to exercise the graph index.Add `--dtype float16` to either command to validate the lower-precision path.Neither command requires an embedding or VLM service.++The core API calls are:++```python+from openviking.storage.vectordb.collection.local_collection import (+ get_or_create_local_collection,+)++collection = get_or_create_local_collection(+ meta_data={+ "CollectionName": "cuvs_smoke",+ "Fields": [+ {"FieldName": "id", "FieldType": "string", "IsPrimaryKey": True},+ {"FieldName": "vector", "FieldType": "vector", "Dim": 4},+ {"FieldName": "account_id", "FieldType": "string"},+ {"FieldName": "uri", "FieldType": "path"},+ ],+ },+ config={+ "dense_search": {+ "backend": "cuvs",+ "algorithm": "brute_force",+ "fallback_to_native": True,+ }+ },+)+collection.create_index(+ "default",+ {+ "IndexName": "default",+ "VectorIndex": {"IndexType": "flat", "Distance": "cosine"},+ "ScalarIndex": ["account_id", "uri"],+ },+)+collection.upsert_data(+ [+ {"id": "a", "vector": [1, 0, 0, 0], "account_id": "demo", "uri": "/docs/a"},+ {"id": "b", "vector": [0, 1, 0, 0], "account_id": "demo", "uri": "/docs/b"},+ ]+)+result = collection.search_by_vector(+ "default",+ dense_vector=[1, 0, 0, 0],+ limit=2,+ filters={"op": "must", "field": "account_id", "conds": ["demo"]},+)+assert [item.id for item in result.data] == ["a", "b"]+collection.close()+```++## Current limits++The native prefilter preserves scalar DSL, `date_time`, `geo_point`, and path-depth semantics. cuVS only handles pure dense queries; sparse/hybrid fallback and snapshot maintenance follow the behavior described above. Treat brute-force as the functional baseline. Tune CAGRA graph and search parameters against recall, throughput, latency, and GPU memory for your workload.diff --git a/docs/package.json b/docs/package.jsonindex 3ca1b3e32..1d0430ab7 100644--- a/docs/package.json+++ b/docs/package.json@@ -9,7 +9,8 @@"docs:preview": "vitepress preview . --host 0.0.0.0","check:api": "node scripts/check-api-reference.mjs","test:theme": "node --experimental-strip-types --test .vitepress/theme/*.test.ts",- "test:search": "node --experimental-strip-types --test .vitepress/theme/openviking-search-*.test.ts"+ "test:search": "node --experimental-strip-types --test .vitepress/theme/openviking-search-*.test.ts",+ "check:docs": "node scripts/check-docs-consistency.mjs"},"devDependencies": {"vitepress": "1.6.4"diff --git a/docs/scripts/check-docs-consistency.mjs b/docs/scripts/check-docs-consistency.mjsnew file mode 100644index 000000000..e2a3b856e--- /dev/null+++ b/docs/scripts/check-docs-consistency.mjs@@ -0,0 +1,77 @@+import fs from 'node:fs'+import path from 'node:path'+import { fileURLToPath } from 'node:url'++// Deliberately checks files, not translated heading anchors or external URLs.+// Run from any directory: node docs/scripts/check-docs-consistency.mjs+const root = path.resolve(path.dirname(fileURLToPath(import.meta.url)), '..')+function pages(directory) {+ return fs.readdirSync(directory, { withFileTypes: true }).flatMap((entry) => {+ const filename = path.join(directory, entry.name)+ return entry.isDirectory() ? pages(filename) : filename.endsWith('.md') ? [filename] : []+ })+}+const localized = ['en', 'zh'].map((locale) => pages(path.join(root, locale)))+const errors = []+const skipped = []+let jsonCount = 0+let linkCount = 0+for (const [index, files] of localized.entries()) {+ const locale = ['en', 'zh'][index]+ const other = ['zh', 'en'][index]+ for (const file of files) {+ const relative = path.relative(path.join(root, locale), file)+ if (!fs.existsSync(path.join(root, other, relative))) errors.push(`${locale}/${relative}: missing ${other} page`)+ const source = fs.readFileSync(file, 'utf8')+ const label = path.relative(root, file)+ const lineAt = (offset) => source.slice(0, offset).split('\n').length+ // Mask fences before checking links; example payloads are not page links.+ const prose = source.replace(/^([ \t]*)(`{3,}|~{3,})([^\n]*)\n([\s\S]*?)^\1\2[ \t]*$/gm,+ (block, indent, fence, info, body, offset) => {+ const language = info.trim().split(/\s/)[0]+ if (language === 'json' || language === 'jsonc') {+ try {+ JSON.parse(body)+ jsonCount+++ } catch (error) {+ // Legacy JSON-labelled examples sometimes deliberately contain comments+ // or unquoted ellipses. Report these as illustrative, never valid JSON.+ const unquoted = body.replace(/"(?:\\.|[^"\\])*"/g, '""')+ const reason = language === 'jsonc' ? 'explicit JSONC'+ : /\/\/|\/\*/.test(unquoted) ? 'comments in a json fence'+ : /\.\.\.|…|<[^>]+>/.test(unquoted) ? 'illustrative placeholders' : null+ if (reason) skipped.push({ location: `${label}:${lineAt(offset)}`, reason })+ else errors.push(`${label}:${lineAt(offset)}: invalid JSON: ${error.message}`)+ }+ }+ return block.replace(/[^\n]/g, ' ')+ })+ const links = [...prose.matchAll(/!?\[[^\]\n]*\]\(\s*(<[^>]+>|[^\s)]+)(?:\s+["'][^\n]*?["'])?\s*\)/g)]+ const definitions = [...prose.matchAll(/^ {0,3}\[[^\]\n]+\]:\s*(<[^>]+>|\S+)/gm)]+ for (const match of [...links, ...definitions]) {+ const href = match[1].replace(/^<|>$/g, '')+ if (/^(?:[a-z][a-z\d+.-]*:|\/\/|#)/i.test(href)) continue+ const pathname = href.split(/[?#]/)[0]+ if (!pathname || /[{}]/.test(pathname)) continue+ let decoded+ try { decoded = decodeURIComponent(pathname) } catch { errors.push(`${label}:${lineAt(match.index)}: invalid URL ${href}`); continue }+ const target = decoded.startsWith('/') ? path.join(root, decoded) : path.resolve(path.dirname(file), decoded)+ const candidates = [target, `${target}.md`, path.join(target, 'index.md')]+ if (target.endsWith('.html')) candidates.push(target.slice(0, -5) + '.md')+ // VitePress serves public assets from the site root.+ if (decoded.startsWith('/')) candidates.push(path.join(root, 'public', decoded))+ linkCount+++ if (!candidates.some((candidate) => fs.existsSync(candidate))) errors.push(`${label}:${lineAt(match.index)}: missing link target ${href}`)+ }+ }+}+console.log(`Checked ${localized[0].length} English and ${localized[1].length} Chinese pages, ${jsonCount} strict JSON blocks, ${linkCount} local links.`)+console.log(`Skipped strict JSON parsing for ${skipped.length} JSONC / illustrative blocks (use --verbose to list).`)+for (const reason of [...new Set(skipped.map((item) => item.reason))]) {+ console.log(` ${reason}: ${skipped.filter((item) => item.reason === reason).length} (not validated as JSON)`)+}+if (process.argv.includes('--verbose')) console.log(skipped.map((item) => `${item.location}: ${item.reason}`).join('\n'))+if (errors.length) {+ console.error(errors.join('\n'))+ process.exitCode = 1+} else console.log('Documentation consistency checks passed.')diff --git a/docs/zh/agent-integrations/15-agent-plugins.md b/docs/zh/agent-integrations/15-agent-plugins.mdindex ffe70f71b..30d178781 100644--- a/docs/zh/agent-integrations/15-agent-plugins.md+++ b/docs/zh/agent-integrations/15-agent-plugins.md@@ -46,8 +46,9 @@ OpenViking 服务端本身在 `/mcp` 上就是 streamable HTTP,但 `mcp.json``OPENVIKING_CREDENTIAL_SOURCE`(或 `OPENVIKING_CREDENTIALS_SOURCE`)把整条链钉在某一端:`env` 只认环境变量,`cli`(同义写法还有 `ovcli` / `file` / `config`)只认 ovcli.conf。默认的 `auto` 在 ovcli.conf 带凭据、且上面这些环境变量一个都没设时钉向 ovcli.conf,否则按整条链解析。钉在 ovcli.conf 时,环境变量里的凭据和 `OPENVIKING_MCP_URL` 会被跳过。key 仍依次回落到 `plugin` 键、`agent_plugins` 段,最后是 `server.root_api_key`,所以只写了 `url` 的旧安装仍能用原来的 key;account 和 user 只回落到 `plugin` 键。`env` 模式两个文件都不读。+`~/.openviking/ovcli.conf`:+```json-// ~/.openviking/ovcli.conf{"url": "https://openviking.example.com","api_key": "your-api-key"diff --git a/docs/zh/api/99-api-doc-writing-guide.md b/docs/zh/api/99-api-doc-writing-guide.mdindex 740291abc..b47179b63 100644--- a/docs/zh/api/99-api-doc-writing-guide.md+++ b/docs/zh/api/99-api-doc-writing-guide.md@@ -2,6 +2,15 @@本文档定义 `docs/zh/api/` 目录下各 API 模块文档的统一结构和编写规范。+## 保持文档可用与及时++- 在同一 PR 中更新中英文页面、导航和示例。相同内容保留一个主要说明入口,相关页面通过链接引用。+- 先写读者任务、前置条件、可运行示例和预期结果,实现细节放在使用说明之后。+- 根据当前实现核验默认值和支持的选项。区分已发布行为、`main` 上的实现和后续计划,必要时链接到对应 release 或 PR。+- 可复制配置使用合法 JSON;片段或伪代码需明确标注,不在 `json` 代码块中混入注释。+- 外部工具和服务引用官方文档,只介绍当前任务需要的配置,不复制整套手册。+- 提交前在 `docs/` 运行 `npm run check:docs`、`npm run check:api` 和 `npm run docs:build`。自动检查覆盖结构与示例,不能替代事实核验和翻译 review。+## 目录结构API 文档按模块组织,每个模块一个文件,使用两位数字序号前缀。diff --git a/docs/zh/guides/01-configuration.md b/docs/zh/guides/01-configuration.mdindex 03d1836d0..da847caf2 100644--- a/docs/zh/guides/01-configuration.md+++ b/docs/zh/guides/01-configuration.md@@ -1472,6 +1472,7 @@ RAGFS 默认使用 Rust binding 模式,通过 Rust 实现直接访问文件系"ak": "your-access-key","sk": "your-secret-key"}+ }}}```diff --git a/docs/zh/guides/12-vikingbot-metrics-validation.md b/docs/zh/guides/12-vikingbot-metrics-validation.mdindex dbc5e03f0..456f01b5c 100644--- a/docs/zh/guides/12-vikingbot-metrics-validation.md+++ b/docs/zh/guides/12-vikingbot-metrics-validation.md@@ -1,94 +1,48 @@# 使用真实问答验证 Vikingbot 指标-这份文档用于验证一条完整链路是否已经打通:+完成 [Prometheus 和 Grafana 配置](11-grafana-prometheus.md) 后,用本文验证完整链路:```text-用户提问 -> /bot/v1/chat -> Vikingbot 会话持久化 -> /bot/v1/feedback 或 follow-up -> /metrics -> Prometheus -> Grafana+问答 → bot 会话持久化 → feedback / follow-up → /metrics → Prometheus → Grafana```-它和 [使用 Prometheus 和 Grafana 查看 OpenViking 指标](11-grafana-prometheus.md) 的区别是:--- `11-grafana-prometheus.md` 解决的是“怎么把链路搭起来”-- 本文解决的是“链路搭起来以后,怎么用真实问答场景确认指标真的在变”--本文只使用当前仓库里已经确认存在、而且比较容易观察到的指标,尤其是:--- `openviking_service_readiness`-- `openviking_component_health`-- `openviking_queue_pending`-- `openviking_vikingdb_collection_vectors`-- `openviking_model_usage_available`-- `openviking_feedback_*`-- `openviking_feedback_channel_*`-## 前提条件-开始前请先确认:+- 启用 `server.observability.metrics.enabled=true`,通过 `openviking-server --with-bot --port 30300` 启动服务。+- 确认 `/bot/v1/health` 返回 HTTP 200,`/metrics` 返回 Prometheus exposition 文本。+- 确认 Prometheus 能抓取 OpenViking,Grafana 使用该 Prometheus 数据源。-- OpenViking Server 已启动,并且启用了 `server.observability.metrics.enabled=true`-- Vikingbot 已通过 `openviking-server --with-bot` 启动-- `curl http://127.0.0.1:30300/bot/v1/health` 返回 `200`-- `curl http://127.0.0.1:30300/metrics` 能返回 Prometheus exposition 文本-- Prometheus 已经能抓到 OpenViking-- Grafana 已经连上 Prometheus+上一篇的 localhost 方案使用 OpenViking `http://127.0.0.1:30300`、Prometheus `http://127.0.0.1:30909` 和 Grafana `http://127.0.0.1:13000`。如果启用了认证,请为每个请求添加部署要求的凭据,参见 [认证](04-authentication.md)。-如果你使用的是本文前面已经补好的 Linux localhost 方案,默认地址是:+## 指标口径-- Prometheus: `http://127.0.0.1:30909`-- Grafana: `http://127.0.0.1:13000`-- OpenViking: `http://127.0.0.1:30300`+反馈指标是 **snapshot gauge**,包括以 `_total` 结尾的指标。`FeedbackCollector` 从 `<bot_data_path>/sessions/*.jsonl` 的 `metadata.feedback_events` 和 `metadata.response_outcomes` 聚合快照。默认刷新 TTL 为 30 秒,多次 scrape 可能复用同一份快照。对比结果前,需要等待 collector 刷新和下一次 Prometheus 抓取。-## 先理解这批反馈指标的口径+优先查看当前值或短时间内的变化,不要按 counter 使用 `rate()`。查询过滤 `valid="1"`;`valid="0"` 是采集失败后的 fallback 快照,不适合作为验收依据。gauge 与 counter 的区别见 [Prometheus 指标类型](https://prometheus.io/docs/concepts/metric_types/)。-这一步很重要,否则很容易把现象看错。+每个场景使用新的 session ID。指标覆盖全部持久化会话,其他流量也会影响结果;历史样本多时,单次操作带来的比例变化可能很小。已有 response 的 outcome 被重新分类时,相应 outcome total 可以下降。-当前仓库里,Vikingbot 反馈相关指标不是在线单调累加 counter,而是 `scrape-time snapshot gauge`:Prometheus 每次抓取 `/metrics` 时,`FeedbackCollector` 会去扫描 `bot/sessions/*.jsonl`,从持久化 session 的 `metadata.feedback_events` 和 `metadata.response_outcomes` 里重新聚合一份最新快照。+## 记录基线-这意味着:--- 更适合看“当前总量/占比/按 channel 分布”-- 更适合直接看当前值或短时间内的阶梯变化-- 不建议把它当成普通 counter 去优先看 `rate()`-- 查询时建议优先过滤 `valid="1"`--可以先在 Prometheus 或 Grafana Explore 里执行:+在 Prometheus 或 Grafana Explore 的表格视图中逐条执行:```promql-{__name__=~"openviking_feedback.*"}+openviking_service_readiness{valid="1"}+openviking_component_health{valid="1"}+openviking_queue_pending+openviking_vikingdb_collection_vectors{valid="1"}+openviking_model_usage_available{valid="1"}```-如果你看到的是 `valid="0"`,说明当前样本是 fallback/stale 快照,不建议把它当成主验证结果。--## 按真实问答场景执行的验收用例--如果你不想按“指标类别”理解文档,而是更希望像真实用户一样逐轮发问、观察 Vikingbot 回复、再去 Prometheus / Grafana 里核对指标变化,可以直接按下面这 7 个场景顺序执行。--建议使用一组全新的 `session_id`,这样更容易看出单次操作带来的阶梯变化。下面示例统一使用:--- `realcase-01-chat`-- `realcase-02-thumb-up`-- `realcase-03-thumb-down`-- `realcase-04-reask`-- `realcase-05-followup-no-feedback`-- `realcase-06-resolved`-- `realcase-07-channel-demo`--### 场景 1:真实用户先发一条正常问题,验证会话落盘与响应计数+readiness 应为 `1`,健康组件通常为 `1`,队列积压应为零或较小值。向量数和模型统计可用性取决于服务配置,不要求在问答过程中变化。-用户提问:+同时记录反馈快照:-```text-请用一句话介绍 OpenViking,控制在 20 个字以内。+```promql+{__name__=~"openviking_feedback.*",valid="1"}```-预期 Vikingbot 回复特征:--- 返回 200-- 返回体包含 `session_id`-- 返回体包含 `response_id`-- `message` 非空--执行命令:+## 1. 发起问答,确认持久化```bashcurl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \@@ -96,69 +50,17 @@ curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \-d '{"session_id": "realcase-01-chat","user_id": "metrics-validation-user",- "message": "请用一句话介绍 OpenViking,控制在 20 个字以内。"+ "message": "请用一句话介绍 OpenViking。"}'```-重点观察:--- `openviking_feedback_responses_total{valid="1"}`-- `openviking_feedback_sessions_scanned_total{valid="1"}`--PromQL:--```promql-openviking_feedback_responses_total{valid="1"}-```--```promql-openviking_feedback_sessions_scanned_total{valid="1"}-```--预期变化:--- 会变:`responses_total` 通常增加 `1`;如果这是全新的 session 文件,`sessions_scanned_total` 也可能增加 `1`。-- 不该变:`events_total`、`thumb_up_total`、`thumb_down_total`、`responses_with_feedback_total` 以及各类 outcome total 在这一步通常不应直接增加,因为这里只发生了一次普通问答,没有显式 feedback,也没有 follow-up。-- 可能不明显:rate 类指标通常不会因为这一轮普通问答出现明显波动;这个场景优先看 total 是否跳变,不要把 rate 没变化当成异常。--### 场景 2:用户认为回答有帮助,点一个赞,验证正向反馈链路--用户提问:--```text-帮我总结一下 OpenViking 的主要作用。-```--预期 Vikingbot 回复特征:--- 会给出一段简短介绍-- 返回体里能拿到 `response_id`--随后用户行为:--```text-这次回答有帮助,我给一个赞。-```--执行步骤:+预期 HTTP 200,返回 `session_id`、`response_id` 和非空 `message`。保存 response ID,后续反馈需要使用。-1. 先调用 `/bot/v1/chat` 发送问题。-2. 记录返回里的 `response_id`。-3. 再调用 `/bot/v1/feedback` 提交 `thumb_up`。+刷新后,`openviking_feedback_responses_total{valid="1"}` 通常增加 `1`。新 session 文件也会使 `openviking_feedback_sessions_scanned_total{valid="1"}` 增加。普通问答本身不会产生显式反馈事件。-聊天命令:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "realcase-02-thumb-up",- "user_id": "metrics-validation-user",- "message": "帮我总结一下 OpenViking 的主要作用。"- }'-```+## 2. 提交正向反馈-反馈命令:+使用 `session_id: "realcase-02-thumb-up"` 再发起一次问答,将下面的 `<response_id>` 替换为该轮返回的 ID:```bashcurl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \@@ -171,155 +73,34 @@ curl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \}'```-重点观察:--- `openviking_feedback_events_total{valid="1"}`-- `openviking_feedback_thumb_up_total{valid="1"}`-- `openviking_feedback_responses_with_feedback_total{valid="1"}`-- `openviking_feedback_positive_outcomes_total{valid="1"}`-- `openviking_feedback_coverage{valid="1"}`-- `openviking_feedback_thumbs_up_rate{valid="1"}`-- `openviking_feedback_one_turn_resolution_rate{valid="1"}`--PromQL:+预期返回 `accepted: true`。对于此前没有反馈的 response,以下 gauge 通常各增加 `1`:```promqlopenviking_feedback_events_total{valid="1"}-```--```promqlopenviking_feedback_thumb_up_total{valid="1"}-```--```promql+openviking_feedback_responses_with_feedback_total{valid="1"}openviking_feedback_positive_outcomes_total{valid="1"}```-```promql-openviking_feedback_one_turn_resolution_rate{valid="1"}-```--预期变化:--- 会变:`feedback_events_total`、`thumb_up_total`、`responses_with_feedback_total`、`positive_outcomes_total` 通常各增加 `1`。-- 不该变:`thumb_down_total`、`negative_outcomes_total`、`reasked_outcomes_total`、`follow_up_without_feedback_outcomes_total` 在这个场景通常不应直接增加,因为当前动作是对同一条 response 提交显式正向反馈,而不是差评或追问。-- 可能不明显:`coverage`、`thumbs_up_rate`、`one_turn_resolution_rate` 通常会上升或保持不变,但如果历史 response 和历史 feedback 已经很多,显示上也可能接近不变;其中 `one_turn_resolution_rate` 会受当前实现把 `positive_feedback` 也计入 one-turn resolution 的影响。--### 场景 3:用户认为回答没帮助,点一个踩,验证负向反馈链路--用户提问:--```text-请告诉我 OpenViking 的部署步骤,越短越好。-```--预期 Vikingbot 回复特征:--- 会给出一个简短部署说明-- 返回体里能拿到 `response_id`--随后用户行为:--```text-这次回答不够有帮助,我给一个踩。-```--执行步骤:--1. 先调用 `/bot/v1/chat`。-2. 记录 `response_id`。-3. 调用 `/bot/v1/feedback`,提交 `thumb_down`。--聊天命令:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "realcase-03-thumb-down",- "user_id": "metrics-validation-user",- "message": "请告诉我 OpenViking 的部署步骤,越短越好。"- }'-```--反馈命令:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \- -H "Content-Type: application/json" \- -d '{- "session_id": "realcase-03-thumb-down",- "response_id": "<response_id>",- "feedback_type": "thumb_down",- "feedback_text": "not helpful"- }'-```+`coverage`、`thumbs_up_rate` 和 `one_turn_resolution_rate` 也可能变化。当前实现将 `resolved` 和 `positive_feedback` 都计入一轮解决率。优先核对 total,比例取决于全部历史 response 和 outcome。-重点观察:+## 3. 提交负向反馈-- `openviking_feedback_events_total{valid="1"}`-- `openviking_feedback_thumb_down_total{valid="1"}`-- `openviking_feedback_negative_outcomes_total{valid="1"}`-- `openviking_feedback_thumbs_down_rate{valid="1"}`-- `openviking_feedback_negative_feedback_rate{valid="1"}`+用新 session `realcase-03-thumb-down` 发起问答,再按上面的方式提交反馈,使用该轮 response ID,并设置 `feedback_type: "thumb_down"`、`feedback_text: "not helpful"`。-PromQL:+刷新后,以下 total 通常各增加 `1`:```promql+openviking_feedback_events_total{valid="1"}openviking_feedback_thumb_down_total{valid="1"}-```--```promqlopenviking_feedback_negative_outcomes_total{valid="1"}```-```promql-openviking_feedback_negative_feedback_rate{valid="1"}-```--预期变化:--- 会变:`thumb_down_total`、`negative_outcomes_total` 通常各增加 `1`,`events_total` 也应随这次显式 feedback 增加 `1`。-- 不该变:`thumb_up_total`、`positive_outcomes_total`、`reasked_outcomes_total`、`resolved_outcomes_total`、`follow_up_without_feedback_outcomes_total` 在这个场景通常不应直接增加,因为这里只提交了显式负向反馈,没有发生追问或静默结束。-- 可能不明显:`thumbs_down_rate`、`negative_feedback_rate` 通常会上升或保持不变,但如果历史样本很多,比例变化可能很小,因此仍然优先看 total 是否按预期跳变。--### 场景 4:用户没有显式反馈,但马上追问,验证 `reasked`--用户第一问:--```text-请解释 OpenViking 的 metrics 是做什么的。-```--Vikingbot 第一轮回复特征:--- 会给出解释,但用户主观上仍觉得不够具体--用户第二问:--```text-我还是没明白,请再具体一点。-```--执行步骤:--1. 用同一个 `session_id` 先发第一问。-2. 不要调用 `/bot/v1/feedback`。-3. 在 10 分钟内用同一个 `session_id` 发第二问。+`openviking_feedback_thumbs_down_rate` 和 `openviking_feedback_negative_feedback_rate` 也可能变化。仅这次操作不应增加正向反馈或 reask total。-第一轮命令:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "realcase-04-reask",- "user_id": "metrics-validation-user",- "message": "请解释 OpenViking 的 metrics 是做什么的。"- }'-```+## 4. 十分钟内追问-第二轮命令:+用 `realcase-04-reask` 发起问答,不提交反馈,在 assistant 回复后的十分钟内向同一 session 发送第二条消息:```bashcurl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \@@ -327,179 +108,42 @@ curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \-d '{"session_id": "realcase-04-reask","user_id": "metrics-validation-user",- "message": "我还是没明白,请再具体一点。"+ "message": "请解释得更具体一些。"}'```-重点观察:--- `openviking_feedback_reasked_outcomes_total{valid="1"}`-- `openviking_feedback_reask_rate{valid="1"}`--PromQL:+**上一条** assistant response 会被分类为 `reasked`。该判断依据时间,不会检查两次问题的语义相似度。```promqlopenviking_feedback_reasked_outcomes_total{valid="1"}-```--```promqlopenviking_feedback_reask_rate{valid="1"}```-预期变化:--- `reasked_outcomes_total` 通常增加 `1`-- `reask_rate` 通常会上升,或在历史样本很多时保持不变-- 核心不是第二条回复内容本身,而是第一条 assistant response 的 outcome 被评估成了 `reasked`-- `responses_total` 通常还会因为第二次 `/bot/v1/chat` 再增加 `1`,但这不影响“上一条 response 被改判为 `reasked`”这个核心判断-- `events_total`、`thumb_up_total`、`thumb_down_total`、`responses_with_feedback_total` 通常不变,因为这个场景没有显式 feedback-- `positive_outcomes_total`、`negative_outcomes_total`、`resolved_outcomes_total` 通常不应因为这一步直接增加--补充说明:--1. `reask_rate` 不是严格单调变化的在线 counter 比率,而是基于当前持久化 session 快照重新聚合出来的占比,所以更适合看“是否不下降、是否出现阶梯变化”。-2. 如果第二次 follow-up 已经超过 10 分钟窗口,且仍然没有显式 feedback,那么它更可能落入 `follow_up_without_feedback`,而不是 `reasked`。-3. 如果你在这个场景里看到了 `follow_up_without_feedback_outcomes_total` 增加,优先检查是不是第二次提问时间已经超过 10 分钟,或者混入了别的 session 样本。--### 场景 5:用户不点赞也不点踩,隔一段时间再追问,验证 `follow_up_without_feedback`--用户第一问:--```text-OpenViking 和普通向量数据库有什么关系?-```--Vikingbot 第一轮回复特征:--- 会给出概念性回答--用户稍后继续问:--```text-那你能再举一个更具体的例子吗?-```--执行步骤:--1. 用新的 `session_id` 发第一问。-2. 不调用 `/bot/v1/feedback`。-3. 至少等待 10 分钟以后,再用同一个 `session_id` 继续发 follow-up。--说明:当前实现里,10 分钟内的 follow-up 会优先被归类为 `reasked`;只有超过这个窗口、且没有显式反馈时,才会落入 `follow_up_without_feedback`。--第一轮命令:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "realcase-05-followup-no-feedback",- "user_id": "metrics-validation-user",- "message": "OpenViking 和普通向量数据库有什么关系?"- }'-```--第二轮命令:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "realcase-05-followup-no-feedback",- "user_id": "metrics-validation-user",- "message": "那你能再举一个更具体的例子吗?"- }'-```--重点观察:+reasked total 通常增加 `1`。第二次 assistant 回复也会增加 `responses_total`,显式反馈 total 应保持不变。-- `openviking_feedback_follow_up_without_feedback_outcomes_total{valid="1"}`+## 5. 超过十分钟再追问-PromQL:+用 `realcase-05-followup-no-feedback` 发起问答,不提交反馈,在 assistant 回复后等待 **超过十分钟**,再向同一 session 发送消息。```promqlopenviking_feedback_follow_up_without_feedback_outcomes_total{valid="1"}```-预期变化:--- 会变:`follow_up_without_feedback_outcomes_total` 通常增加 `1`;同时第二次 `/bot/v1/chat` 也会让 `responses_total` 再增加 `1`,但真正被补判为 `follow_up_without_feedback` 的仍然是第一轮 assistant response。-- 不该变:`events_total`、`thumb_up_total`、`thumb_down_total`、`responses_with_feedback_total` 通常不变,因为整个场景没有显式调用 `/bot/v1/feedback`;`positive_outcomes_total`、`negative_outcomes_total`、`reasked_outcomes_total` 也通常不应在这一步直接增长。-- 可能不明显:如果你看到增长落在 `reasked_outcomes_total`,优先检查第二次提问是不是仍在 10 分钟窗口内;rate 类指标同样可能因为历史样本较多而变化不明显,所以这个场景优先看 total 跳变。--### 场景 6:用户问完就结束,不再追问,验证 `resolved`--用户提问:--```text-请用一句话解释什么是 OpenViking 的 readiness 指标。-```--预期 Vikingbot 回复特征:--- 会给出短回答-- 用户不继续追问,也不提交反馈--执行步骤:--1. 新开一个 `session_id` 发一轮问答。-2. 不调用 `/bot/v1/feedback`。-3. 不继续发 follow-up。-4. 等待系统完成持久化与后续 outcome 评估,再观察指标。--命令:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "realcase-06-resolved",- "user_id": "metrics-validation-user",- "message": "请用一句话解释什么是 OpenViking 的 readiness 指标。"- }'-```--重点观察:+上一条 response 应被分类为 `follow_up_without_feedback`,对应 total 增加 `1`。恰好十分钟或更早的 follow-up 仍属于 `reasked`;显式反馈 total 保持不变。-- `openviking_feedback_resolved_outcomes_total{valid="1"}`+## 6. 理解 `resolved`-PromQL:+没有后续 user 消息的 response 会在 **outcome evaluator 执行时** 被分类为 `resolved`。metrics collector 只读取已保存的 outcome,不会运行静默计时器,也不会在十分钟后自动生成 resolved outcome。```promqlopenviking_feedback_resolved_outcomes_total{valid="1"}```-预期变化:--- 会变:`resolved_outcomes_total` 有机会增加 `1`,`one_turn_resolution_rate` 也可能上升或保持不变。-- 不该变:`events_total`、`thumb_up_total`、`thumb_down_total`、`responses_with_feedback_total` 在这个场景通常不变,因为既没有显式 feedback,也没有后续追问;`negative_outcomes_total`、`reasked_outcomes_total`、`follow_up_without_feedback_outcomes_total` 也通常不应直接增加。-- 可能不明显:`resolved` 相比 `thumb_up`、`thumb_down`、`reasked` 更适合作为补充验证项,因为它依赖后续 outcome 评估时机,出现时间和幅度都不如显式反馈稳定;因此看到短时间内没有立刻跳变,不一定表示链路异常。--### 场景 7:真实多 channel 用户,从指定 channel 访问,验证 `openviking_feedback_channel_*`--前提:--- 你的 bot 配置中已经启用了 `channel_id="demo"` 对应的 `bot_api` channel--用户提问:--```text-请简单介绍一下 OpenViking。-```--预期 Vikingbot 回复特征:--- 请求需要走 `POST /bot/v1/chat/channel`-- 返回样本最终应落到 `channel="bot_api__demo"`+因此,发起问答后保持静默不能作为该指标的确定性验收用例。如果预期存在 resolved 样本,请检查持久化的 `metadata.response_outcomes`。可重复验收应使用上面的正向、负向和追问场景。-执行步骤:+## 7. 验证 channel 维度-1. 用 `POST /bot/v1/chat/channel` 发起聊天。-2. 记录返回中的 `response_id`。-3. 调用 `/bot/v1/feedback`,带上同一个 `channel_id`。-4. 对照 channel 维度指标。--聊天命令:+此场景要求已启用 ID 为 `demo` 的 `bot_api` channel。通过 `/bot/v1/chat/channel` 发起问答:```bashcurl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat/channel" \@@ -508,11 +152,11 @@ curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat/channel" \"session_id": "realcase-07-channel-demo","user_id": "metrics-validation-user","channel_id": "demo",- "message": "请简单介绍一下 OpenViking。"+ "message": "请简要介绍 OpenViking。"}'```-反馈命令:+使用返回的 response ID 提交反馈,并带上相同的 `channel_id`:```bashcurl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \@@ -526,703 +170,31 @@ curl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \}'```-重点观察:--- `openviking_feedback_channel_events_total{channel="bot_api__demo",valid="1"}`-- `openviking_feedback_channel_thumbs_down_rate{channel="bot_api__demo",valid="1"}`-- `openviking_feedback_channel_negative_outcomes_total{channel="bot_api__demo",valid="1"}`--PromQL:+查询目标 channel:```promqlopenviking_feedback_channel_events_total{channel="bot_api__demo",valid="1"}-```--```promql-openviking_feedback_channel_thumbs_down_rate{channel="bot_api__demo",valid="1"}-```--```promqlopenviking_feedback_channel_negative_outcomes_total{channel="bot_api__demo",valid="1"}+openviking_feedback_channel_thumbs_down_rate{channel="bot_api__demo",valid="1"}```-```promql-openviking_feedback_channel_events_total{valid="1"}-```--预期变化:--- 会变:能看到 `channel="bot_api__demo"` 这一组样本,并且该 channel 下的 `events_total`、`negative_outcomes_total` 等 total 会随这次问答和负向反馈跳变。-- 不该变:其他无关 channel 的样本通常不应因为这次请求跳变;如果你误用的是 `POST /bot/v1/chat` 而不是 `POST /bot/v1/chat/channel`,通常也不会得到目标 `bot_api__demo` 的聚合样本。-- 可能不明显:`channel_thumbs_down_rate`、`channel_one_turn_resolution_rate` 这类比例在历史 channel 样本较多时可能变化不明显,所以 channel 验收优先看该 channel 的 total 是否跳变,再看 rate 方向是否合理。--如果你不确定当前环境里有哪些可用 `channel_id`,可以先检查 bot 配置里启用的 `bot_api` channel;若配置不存在,对应请求会返回 `404 Channel '<channel_id>' not found`。--### 一次性人工验收的推荐顺序--如果你只想跑一遍最实用的人工验收,建议按下面顺序执行:--1. 跑“场景 1”,确认 `/bot/v1/chat`、会话持久化和 `responses_total` 正常。-2. 跑“场景 2”,确认 `thumb_up`、`positive_outcomes_total`、`coverage` 正常。-3. 跑“场景 3”,确认 `thumb_down`、`negative_outcomes_total` 正常。-4. 跑“场景 4”,确认 `reasked_outcomes_total` 正常。-5. 跑“场景 5”,确认 `follow_up_without_feedback_outcomes_total` 正常。-6. 跑“场景 6”,把 `resolved` 作为补充验证。-7. 如果你的环境启用了 `bot_api` channel,再跑“场景 7”验证 channel 维度指标。--## 第 0 步:先看基线指标--在真正发问答之前,先确认基础链路指标是活的。--推荐依次执行下面这些查询。--服务 readiness:--```promql-openviking_service_readiness{valid="1"}-```--预期:返回 `1`。--组件健康:--```promql-openviking_component_health{valid="1"}-```--预期:--- 至少能看到 `queue`、`vikingdb` 等 component-- 正常情况下大多数值为 `1`--队列积压:--```promql-openviking_queue_pending-```--预期:--- 通常为 `0` 或较小值-- 如果此时已经长期大于 `0`,后面做问答验证时要注意区分“新流量触发”还是“原本就有积压”--VikingDB collection 当前向量数:--```promql-openviking_vikingdb_collection_vectors{valid="1"}-```--预期:--- 至少存在一部分 collection 样本-- 数值不一定在本次验证中变化,但它能证明这类状态指标已经被 Prometheus 抓到--模型使用统计可用性:--```promql-openviking_model_usage_available{valid="1"}-```--预期:--- 可能看到 `model_type="vlm"`、`embedding`、`rerank`-- 值为 `1` 表示对应统计当前可用--反馈快照总览:--```promql-openviking_feedback_sessions_scanned_total{valid="1"}-```--```promql-openviking_feedback_responses_total{valid="1"}-```--```promql-openviking_feedback_events_total{valid="1"}-```--预期:--- 如果你的环境已有历史 bot session,数值通常大于 `0`-- 如果是全新环境,也可能是 `0`--建议把下面这些值先记下来,后面每个场景都拿它们做对比:--- `openviking_feedback_responses_total{valid="1"}`-- `openviking_feedback_responses_with_feedback_total{valid="1"}`-- `openviking_feedback_events_total{valid="1"}`-- `openviking_feedback_thumb_up_total{valid="1"}`-- `openviking_feedback_thumb_down_total{valid="1"}`-- `openviking_feedback_positive_outcomes_total{valid="1"}`-- `openviking_feedback_negative_outcomes_total{valid="1"}`-- `openviking_feedback_reasked_outcomes_total{valid="1"}`-- `openviking_feedback_resolved_outcomes_total{valid="1"}`-- `openviking_feedback_follow_up_without_feedback_outcomes_total{valid="1"}`--## 第 1 步:先做一轮最小聊天,确认 bot 会话能落盘--这个场景不是为了验证反馈指标,而是为了确认 `/bot/v1/chat` 这条链路本身正常。--用户输入示例:--```text-请用一句话介绍 OpenViking,控制在 20 个字以内。-```--期望的 Vikingbot 回复特征:--- 返回 200-- 返回体里包含 `session_id`-- 返回体里包含 `response_id`-- `message` 非空--执行命令:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-session-a",- "user_id": "metrics-validation-user",- "message": "请用一句话介绍 OpenViking,控制在 20 个字以内。"- }'-```--返回体示例形态:--```json-{- "session_id": "metrics-validation-session-a",- "response_id": "<response_id>",- "message": "..."-}-```--这一轮之后,最值得观察的不是点赞/踩指标,而是:--```promql-openviking_feedback_responses_total{valid="1"}-```--预期:--- 相比第 0 步基线,通常增加 `1`-- 如果 scrape 还没刷新,等 15-30 秒再看一次--可选观察:--```promql-openviking_queue_pending-```--预期:--- 可能短暂波动,但不保证一定变化-- 它更适合用来确认系统没有因为 bot 请求出现异常积压--## 第 2 步:显式 thumb up,验证正向反馈指标--这是最推荐先做的主路径,因为现象最稳定、最好理解。--用户问答场景:--1. 用户提问:--```text-帮我总结一下 OpenViking 的作用。-```--2. Vikingbot 给出一段简短回答。--3. 用户主观判断“这次回答有帮助”,提交 `thumb_up`。--先发起聊天:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-positive",- "user_id": "metrics-validation-user",- "message": "帮我总结一下 OpenViking 的作用。"- }'-```--记下返回里的 `response_id`,然后提交反馈:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-positive",- "response_id": "<response_id>",- "feedback_type": "thumb_up",- "feedback_text": "helpful"- }'-```--期望反馈返回:--```json-{- "accepted": true,- "response_id": "<response_id>",- "session_id": "metrics-validation-positive",- "feedback_type": "thumb_up",- "feedback_delay_sec": 1.234,- "timestamp": "..."-}-```--重点看这些查询。--反馈事件总量:--```promql-openviking_feedback_events_total{valid="1"}-```--点赞总量:--```promql-openviking_feedback_thumb_up_total{valid="1"}-```--带反馈响应数:--```promql-openviking_feedback_responses_with_feedback_total{valid="1"}-```--正向 outcome 总量:--```promql-openviking_feedback_positive_outcomes_total{valid="1"}-```--覆盖率:--```promql-openviking_feedback_coverage{valid="1"}-```--点赞率:--```promql-openviking_feedback_thumbs_up_rate{valid="1"}-```--一轮解决率:--```promql-openviking_feedback_one_turn_resolution_rate{valid="1"}-```--预期变化:--- `openviking_feedback_events_total{valid="1"}` 增加 `1`-- `openviking_feedback_thumb_up_total{valid="1"}` 增加 `1`-- `openviking_feedback_responses_with_feedback_total{valid="1"}` 通常增加 `1`-- `openviking_feedback_positive_outcomes_total{valid="1"}` 通常增加 `1`-- `openviking_feedback_coverage{valid="1"}` 可能上升,也可能不变,取决于历史总样本-- `openviking_feedback_thumbs_up_rate{valid="1"}` 可能上升,也可能不变,取决于历史反馈结构-- `openviking_feedback_one_turn_resolution_rate{valid="1"}` 可能上升,因为当前实现把 `resolved + positive_feedback` 都计入 one-turn resolution--如果你想看“这次操作是否已经刷新进 Prometheus”,最稳妥的做法是把查询改成表格视图,连续刷新 1-2 次,而不是一开始就看时间序列折线。--## 第 3 步:显式 thumb down,验证负向反馈指标--第二个主路径是 `thumb_down`,它同样稳定,而且和正向反馈形成对照。--用户问答场景:--1. 用户提问:--```text-请告诉我 OpenViking 的部署步骤,越短越好。-```--2. Vikingbot 返回一个回答。--3. 假设用户认为这次回答没有帮助,提交 `thumb_down`。--先发聊天:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-negative",- "user_id": "metrics-validation-user",- "message": "请告诉我 OpenViking 的部署步骤,越短越好。"- }'-```--再提交踩:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-negative",- "response_id": "<response_id>",- "feedback_type": "thumb_down",- "feedback_text": "not helpful"- }'-```--重点查询。--```promql-openviking_feedback_events_total{valid="1"}-```--```promql-openviking_feedback_thumb_down_total{valid="1"}-```--```promql-openviking_feedback_negative_outcomes_total{valid="1"}-```--```promql-openviking_feedback_thumbs_down_rate{valid="1"}-```--```promql-openviking_feedback_negative_feedback_rate{valid="1"}-```--预期变化:--- `openviking_feedback_events_total{valid="1"}` 再增加 `1`-- `openviking_feedback_thumb_down_total{valid="1"}` 增加 `1`-- `openviking_feedback_negative_outcomes_total{valid="1"}` 通常增加 `1`-- `openviking_feedback_thumbs_down_rate{valid="1"}` 可能上升-- `openviking_feedback_negative_feedback_rate{valid="1"}` 可能上升--这一步完成后,你已经验证了:--- `/bot/v1/feedback` 能关联到历史 `response_id`-- feedback event 已被落入 session metadata-- scrape-time feedback 聚合已经反映到 `/metrics`--## 第 4 步:follow-up 提问,验证 `reasked`--这个场景用来验证“没有显式反馈,但用户很快追问,上一条回答被判定为 `reasked`”。--用户问答场景:--1. 用户第一问:--```text-请解释 OpenViking 的 metrics 是做什么的。-```--2. Vikingbot 给出回答。--3. 用户在同一个 `session_id` 里继续追问:--```text-我还是没明白,请再具体一点。-```--第一轮聊天:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-reask",- "user_id": "metrics-validation-user",- "message": "请解释 OpenViking 的 metrics 是做什么的。"- }'-```--第二轮 follow-up,注意要在 10 分钟内发送:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-reask",- "user_id": "metrics-validation-user",- "message": "我还是没明白,请再具体一点。"- }'-```--重点查询:--```promql-openviking_feedback_reasked_outcomes_total{valid="1"}-```--```promql-openviking_feedback_reask_rate{valid="1"}-```--预期变化:--- `openviking_feedback_reasked_outcomes_total{valid="1"}` 通常增加 `1`-- `openviking_feedback_reask_rate{valid="1"}` 可能上升--这里的关键点不是第二次 `/chat` 的回复内容,而是第一条 assistant response 的 outcome 已经被落成 `reasked`。--## 第 5 步:不提交显式反馈但继续追问,验证 `follow_up_without_feedback`--这个场景和上一步类似,但要验证的是另一个 outcome 维度。--用户问答场景:--1. 用户第一问:--```text-OpenViking 和普通向量数据库有什么关系?-```--2. Vikingbot 给出回答。--3. 用户没有点赞也没有点踩,而是在 10 分钟之后继续问:--```text-那你能再举一个更具体的例子吗?-```--执行方式和第 4 步类似,但这里不要在 10 分钟内追问。应使用新的 `session_id`,不调用 `/bot/v1/feedback`,并在 assistant 回复后至少等待 10 分钟,再发送下一条 follow-up。--推荐查询:--```promql-openviking_feedback_follow_up_without_feedback_outcomes_total{valid="1"}-```--预期变化:--- 该值通常增加 `1`--说明:--- 当前实现里,`reasked` 和 `follow_up_without_feedback` 都依赖后续 user turn-- 但它们的分析口径不同,前者强调“回答后 10 分钟内被追问/重问”,后者强调“用户有 follow-up、没有显式反馈,而且 follow-up 已超出 10 分钟窗口”-- 如果你的环境里历史数据很多,单次验证造成的比例变化可能不明显,所以优先看 total 指标是否跳变--## 第 6 步:`resolved` 作为补充场景验证--`resolved` 不建议作为第一优先验证项,因为它不像 thumb up / thumb down 那样“做完一个动作就容易立刻观察”。--根据当前实现规则:--- 无显式反馈-- 没有新的 user follow-up-- 该 response 被 outcome evaluator 评估为已解决--推荐验证方法:--1. 新开一个 session 发一轮简短问答-2. 不做 `/bot/v1/feedback`-3. 不继续追问-4. 等待系统完成相关持久化与后续评估-5. 再看:--```promql-openviking_feedback_resolved_outcomes_total{valid="1"}-```--预期:--- 该值有机会增加 `1`--如果这一步没有明显变化,不应优先判定系统有问题,建议先以第 2、3、4 步的结果作为主验收依据。--## 第 7 步:按 channel 看反馈指标--当前实现支持通过 `POST /bot/v1/chat/channel` 携带 `channel_id`,把请求路由到 `bot_api__<channel_id>` 这类 channel 维度里,因此可以验证 `openviking_feedback_channel_*`。--这一步是可选项,建议在主路径都通过后再做。--聊天请求示例:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/chat/channel" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-channel-demo",- "user_id": "metrics-validation-user",- "channel_id": "demo",- "message": "请简单介绍一下 OpenViking。"- }'-```--注意:普通 `POST /bot/v1/chat` 不会根据 `channel_id` 自动切到 `bot_api` 路由;按 channel 验证时应使用 `POST /bot/v1/chat/channel`。--反馈请求示例:--```bash-curl -sS -X POST "http://127.0.0.1:30300/bot/v1/feedback" \- -H "Content-Type: application/json" \- -d '{- "session_id": "metrics-validation-channel-demo",- "response_id": "<response_id>",- "channel_id": "demo",- "feedback_type": "thumb_down",- "feedback_text": "not helpful"- }'-```--重点查询:--```promql-openviking_feedback_channel_events_total{channel="bot_api__demo",valid="1"}-```--```promql-openviking_feedback_channel_thumbs_down_rate{channel="bot_api__demo",valid="1"}-```--```promql-openviking_feedback_channel_negative_outcomes_total{channel="bot_api__demo",valid="1"}-```--如果你想同时对比默认 channel 和 `bot_api__demo`,可以查:--```promql-openviking_feedback_channel_events_total{valid="1"}-```--预期:--- 能看到 `channel="bot_api__demo"`-- 对应数值会随该 channel 下的聊天/反馈变化--注意:如果你当前 bot 配置没有启用对应的 `bot_api` channel,`POST /bot/v1/chat/channel` 会直接返回 `404 Channel 'demo' not found`,需要先确认 bot 配置中存在相应 channel。最直接的方法是查看 bot 配置文件里已启用的 `bot_api` channel 定义。--## 推荐的 Grafana Explore 查询清单--如果你只想快速做一遍人工验收,可以按这个顺序执行。--基础链路:--```promql-openviking_service_readiness{valid="1"}-```--```promql-openviking_component_health{valid="1"}-```--```promql-openviking_queue_pending-```--反馈总览:--```promql-openviking_feedback_responses_total{valid="1"}-```--```promql-openviking_feedback_events_total{valid="1"}-```--```promql-openviking_feedback_coverage{valid="1"}-```--正向反馈:--```promql-openviking_feedback_thumb_up_total{valid="1"}-```--```promql-openviking_feedback_positive_outcomes_total{valid="1"}-```--负向反馈:--```promql-openviking_feedback_thumb_down_total{valid="1"}-```--```promql-openviking_feedback_negative_outcomes_total{valid="1"}-```--追问与解决:--```promql-openviking_feedback_reasked_outcomes_total{valid="1"}-```--```promql-openviking_feedback_follow_up_without_feedback_outcomes_total{valid="1"}-```--```promql-openviking_feedback_resolved_outcomes_total{valid="1"}-```--按 channel:--```promql-openviking_feedback_channel_events_total{valid="1"}-```--```promql-openviking_feedback_channel_thumbs_up_rate{valid="1"}-```--```promql-openviking_feedback_channel_thumbs_down_rate{valid="1"}-```--## 常见误判--### 1. 为什么我刚发完 `/chat`,某些反馈指标没有变化--因为反馈类指标主要来自:--- `metadata.feedback_events`-- `metadata.response_outcomes`--只有普通聊天、还没有显式 feedback 或 follow-up 时,不是所有反馈指标都会立刻动。--### 2. 为什么 total 变了,但 rate 看起来不明显--因为它们本质上是 snapshot gauge,不是面向 `rate()` 设计的 counter。优先看当前值、表格视图或短时间范围内的阶梯变化。--### 3. 为什么我只看到 `valid="0"`--说明 collector 本次刷新失败,当前暴露的是上一次成功快照。主验证时优先使用 `valid="1"`。--### 4. 为什么 channel 维度没有出现 `bot_api__demo`--可能原因通常有三个:--- 你调用的是 `POST /bot/v1/chat`,而不是 `POST /bot/v1/chat/channel`-- 请求里没带 `channel_id`-- bot 配置里并没有启用对应 `bot_api` channel--## 验收建议--如果你只做一次最小验收,建议以这四项作为“通过”标准:+该 channel 的 event 和 negative-outcome total 应增加;其他 channel 不应因这次请求变化。未配置对应 channel 时会返回 `404`;普通 `/bot/v1/chat` 不经过此 channel 路由。-1. `openviking_service_readiness{valid="1"}` 为 `1`-2. 一次 `thumb_up` 后,`openviking_feedback_events_total{valid="1"}` 和 `openviking_feedback_thumb_up_total{valid="1"}` 增加-3. 一次 `thumb_down` 后,`openviking_feedback_thumb_down_total{valid="1"}` 和 `openviking_feedback_negative_outcomes_total{valid="1"}` 增加-4. 一次 follow-up 后,`openviking_feedback_reasked_outcomes_total{valid="1"}` 增加+## 验收与排障-只要这四项通过,基本就能说明:+最小验收要求 readiness 为 `1`、问答已持久化、正负反馈 total 增加,以及十分钟内追问后 reasked total 增加。使用 channel 的部署再单独验证 channel total。-- bot 会话已持久化-- feedback/outcome 已写入 metadata-- `/metrics` 已成功聚合反馈快照-- Prometheus / Grafana 已能正确看到这批指标+| 现象 | 检查项 |+| --- | --- |+| 问答成功,反馈 total 不变 | 是否提交了显式反馈;普通问答不会创建反馈事件。 |+| 看不到刚提交的事件 | 等待 30 秒 collector TTL、后台刷新和下一次 Prometheus 抓取,再检查会话持久化。 |+| total 变化,比例几乎不变 | 历史样本会稀释单次变化,先在表格视图比较当前 total。 |+| 只有 `valid="0"` | 检查 collector 错误和 bot session 目录的访问权限。 |+| 没有 `bot_api__demo` | 检查 channel 是否启用、是否调用 `/chat/channel`,以及反馈中的 `channel_id` 是否一致。 |## 相关文档- [可观测性与排障](05-observability.md)-- [使用 Prometheus 和 Grafana 查看 OpenViking 指标](11-grafana-prometheus.md)+- [Prometheus 和 Grafana 配置](11-grafana-prometheus.md)- [指标与 Metrics](../concepts/12-metrics.md)- [Metrics API](../api/09-metrics.md)diff --git a/docs/zh/guides/16-cuvs.md b/docs/zh/guides/16-cuvs.mdindex 213b546d4..b8a12b54f 100644--- a/docs/zh/guides/16-cuvs.md+++ b/docs/zh/guides/16-cuvs.md@@ -5,10 +5,11 @@ OpenViking 的 `cuvs` 后端保留本地后端的记录持久化、标量索引## 环境要求- Linux x86_64 或 aarch64-- 可见的 NVIDIA GPU;cuVS 26.06 预编译包要求 Ampere 或更新架构-- CUDA 12.2+;安装与本机 CUDA 大版本匹配的 Python 包+- 受支持的 NVIDIA GPU,以及兼容的 CUDA driver- Python 3.11+(cuVS 26.06 的 Python wheel 要求)+按所选版本核对 [cuVS 安装要求](https://docs.nvidia.com/cuvs/installation) 和 [Python 包安装指南](https://docs.nvidia.com/cuvs/installation/python)。当前 cuVS 源码构建要求 CUDA Toolkit 12.2+ 和 Ampere 或更新架构的 GPU;安装包要求取决于所选版本。+CUDA 12:```bash