ai-agent-book 精选快照(<2MB 代码与文档,来自 github.com/bojieli/ai-agent-book)
Build latest book artifacts / build (push) Canceled after 0s
dependency resolution / resolve (3.11) (push) Canceled after 0s
dependency resolution / resolve (3.13) (push) Canceled after 0s
deploy-pages / build (push) Canceled after 0s
deploy-pages / deploy (push) Canceled after 0s
i18n consistency check / check (push) Canceled after 0s
provider adoption tests / test (chapter2/context-compression) (push) Canceled after 0s
provider adoption tests / test (chapter2/prompt-injection) (push) Canceled after 0s
provider adoption tests / test (chapter2/system-hint) (push) Canceled after 0s
provider adoption tests / test (chapter3/log-sanitization) (push) Canceled after 0s
web-search-agent tests / test (push) Canceled after 0s
web-search-agent tests / agentbook (push) Canceled after 0s

This commit is contained in:
2026-08-20 13:12:50 +00:00
commit b119135836
10275 changed files with 3284984 additions and 0 deletions
@@ -0,0 +1,56 @@
{
"schema_version": 1,
"experiment": "6-3",
"run_id": "exp6-3-20260729T150939685Z",
"generated_at_utc": "2026-07-29T15:09:39.685Z",
"credentials_persisted": false,
"source_media": {
"path": "microphone_input.wav",
"capture_method": "browser_microphone_over_websocket",
"original_repository_path": "backend/recordings/recording_2025-02-06T14-51-38-205Z.wav",
"sha256": "e69d77415ffa39e1a2e00b99e6dbedce675faa9b4c2b703a256585861c6d2085",
"size_bytes": 161836,
"duration_seconds": 5.056,
"sample_rate_hz": 16000,
"channels": 1,
"bits_per_sample": 16,
"provenance_note": "Existing real microphone capture saved by live-audio/backend/server.js; replayed through the production Silero class for reproducible validation."
},
"stages": {
"vad": {
"execution": "real",
"mock": false,
"probe_only": false,
"fallback_used": false,
"implementation": "Silero VAD ONNX",
"model": "models/silero_vad.onnx",
"model_sha256": "2623a2953f6ff3d2c1e61740c6cdb7168133479b267dfef114a4a3cc5bdd788f",
"threshold": 0.5,
"max_silence_ms": 500,
"endpoint_detected": true,
"forced_endpoint": false,
"observed_trailing_silence_ms": 526,
"speech_duration_ms": 692,
"latency_seconds": 5.234941667,
"segment_path": "vad_segment.wav",
"segment_sha256": "068bab529128c19aa1b9d042c947434cca71c62043c55bdf6eb235e973991bfc",
"segment_bytes": 21548
}
},
"experiment_complete": false,
"error": "Error: Real ASR failed: You exceeded your current quota, please check your plan and billing details. For more information on this error, read the docs: https://platform.openai.com/docs/guides/error-codes/api-errors.\n at runAsr (/Users/boj/book/ai-agent-book/chapter6/live-audio/backend/run_real_validation.js:120:67)\n at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n at async main (/Users/boj/book/ai-agent-book/chapter6/live-audio/backend/run_real_validation.js:244:27)",
"acceptance": {
"gates": {
"schema_and_scope": true,
"real_websocket_microphone_media": true,
"real_silero_vad_endpoint": true,
"real_asr": false,
"real_streaming_llm": false,
"real_tts_media": false,
"measured_stage_latencies": false,
"no_mock_probe_or_fallback": false
},
"passed": false,
"statement": "Passing proves one saved real microphone turn completed Silero VAD -> real ASR -> real LLM -> real TTS. It does not benchmark concurrency or production load."
}
}
@@ -0,0 +1,164 @@
{
"schema_version": 1,
"experiment": "6-3",
"run_id": "exp6-3-20260729T153334474Z",
"generated_at_utc": "2026-07-29T15:33:34.475Z",
"credentials_persisted": false,
"provenance": {
"host": {
"platform": "darwin",
"release": "25.3.0",
"architecture": "arm64",
"cpu_model": "Apple M2 Max",
"logical_cpu_count": 12,
"total_memory_bytes": 103079215104
},
"runtime": {
"node": "v25.6.0",
"onnxruntime_node": "^1.22.0-rev",
"axios": "^1.7.5",
"ffprobe": "ffprobe version 8.0.1 Copyright (c) 2007-2025 the FFmpeg developers"
},
"timing_clock": "process.hrtime.bigint monotonic clock"
},
"source_media": {
"path": "microphone_input.wav",
"capture_method": "browser_microphone_over_websocket",
"original_repository_path": "backend/recordings/recording_2025-02-06T14-51-38-205Z.wav",
"sha256": "e69d77415ffa39e1a2e00b99e6dbedce675faa9b4c2b703a256585861c6d2085",
"size_bytes": 161836,
"original_sha256": "e69d77415ffa39e1a2e00b99e6dbedce675faa9b4c2b703a256585861c6d2085",
"duration_seconds": 5.056,
"sample_rate_hz": 16000,
"channels": 1,
"bits_per_sample": 16,
"provenance_note": "Existing real microphone capture saved by live-audio/backend/server.js; replayed through the production Silero class for reproducible validation."
},
"stages": {
"vad": {
"execution": "real",
"mock": false,
"probe_only": false,
"fallback_used": false,
"implementation": "Silero VAD ONNX",
"model": "models/silero_vad.onnx",
"model_sha256": "2623a2953f6ff3d2c1e61740c6cdb7168133479b267dfef114a4a3cc5bdd788f",
"threshold": 0.5,
"max_silence_ms": 500,
"endpoint_detected": true,
"detected_endpoint_count": 2,
"selected_endpoint": "longest detected speech segment",
"forced_endpoint": false,
"observed_trailing_silence_ms": 509,
"speech_duration_ms": 1534,
"latency_seconds": 5.393088166,
"segment_path": "vad_segment.wav",
"segment_sha256": "61d43291d32fdbce3a32a1809c7368e12a5bf98f799f28a31e08848b8e7dda06",
"segment_bytes": 46124
},
"asr": {
"execution": "real",
"mock": false,
"probe_only": false,
"fallback_used": false,
"provider": "local-openai-whisper",
"model": "whisper-tiny",
"inference_completed": true,
"api_request_completed": false,
"external_request": false,
"latency_seconds": 2.710318042,
"transcript": "是男朋友叫这样的",
"language": "zh",
"runtime": {
"python": "3.11.4",
"torch": "2.7.0",
"openai_whisper": "20231106"
},
"model_path": "/Users/boj/.cache/whisper/tiny.pt",
"model_sha256": "65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9",
"model_load_seconds": 0.34045145800337195,
"model_inference_seconds": 1.3047717502340674,
"provider_reported_cost_usd": 0,
"cost_note": "Local open-source Whisper inference; no external ASR charge."
},
"llm": {
"execution": "real",
"mock": false,
"probe_only": false,
"fallback_used": false,
"provider": "ark",
"model": "doubao-seed-1-6-flash-250615",
"streamed": true,
"api_request_completed": true,
"external_request": true,
"first_token_seconds": 0.749332709,
"latency_seconds": 0.791579917,
"response": "那是男朋友叫这样的呀",
"provider_request_id": "021785339222980840fd37cfe82fdd108ca4a9d2a652575aa05c0",
"finish_reason": "stop",
"usage": {
"completion_tokens": 30,
"prompt_tokens": 83,
"total_tokens": 113,
"prompt_tokens_details": {
"cached_tokens": 0
},
"completion_tokens_details": {
"reasoning_tokens": 23
}
},
"provider_reported_cost_usd": null,
"cost_note": "The streamed response did not expose a monetary charge; consult the provider billing ledger."
},
"tts": {
"execution": "real",
"mock": false,
"probe_only": false,
"fallback_used": false,
"provider": "fish",
"model": "s1",
"voice": "authorized zero-shot reference",
"api_request_completed": true,
"external_request": true,
"first_audio_byte_seconds": 2.8189757498912513,
"latency_seconds": 3.2793434159830213,
"output_path": "assistant_response.mp3",
"output_sha256": "2ac0b766ac8afaafb6c6bd09e66a134eb6cc46188aa62edc403ddde32fdf92c8",
"output_bytes": 30928,
"output_duration_seconds": 1.933,
"output_format": "mp3",
"reference_id_sha256": "bb2ec197d6276bfad81bbdbcec4473040861e6bc20caf53cf4d1f8184a7416be",
"reference_id_source": "../../controllable-tts/reference_audio/manifest.json",
"billed_input_characters": 10,
"provider_reported_cost_usd": null,
"cost_note": "The Fish Audio SDK response did not expose a monetary charge; consult the provider billing ledger."
}
},
"experiment_complete": true,
"latency": {
"post_endpoint_to_first_audio_byte_seconds": 6.278626500891251,
"complete_serial_pipeline_seconds": 12.17432954098302,
"measurement_clock": "process.hrtime.bigint monotonic clock"
},
"cost": {
"paid_external_requests": 2,
"provider_reported_total_usd": 0,
"complete": false,
"note": "A zero total is not a zero-cost claim when complete=false; some providers omit per-request charges."
},
"acceptance": {
"gates": {
"schema_and_scope": true,
"real_websocket_microphone_media": true,
"real_silero_vad_endpoint": true,
"real_asr": true,
"real_streaming_llm": true,
"real_tts_media": true,
"measured_stage_latencies": true,
"provenance_complete": true,
"no_mock_probe_or_fallback": true
},
"passed": true,
"statement": "Passing proves one saved real microphone turn completed Silero VAD -> real ASR -> real LLM -> real TTS. It does not benchmark concurrency or production load."
}
}
@@ -0,0 +1,26 @@
# Experiment 6-3 real traditional-voice validation
- Run ID: `exp6-3-20260729T153334474Z`
- Complete: **true**
- Source: `microphone_input.wav` (5.056 s, saved browser microphone/WebSocket capture)
- VAD: Silero ONNX, 500 ms silence, non-forced endpoint = true
- ASR: local-openai-whisper / whisper-tiny, 2.710 s
- Transcript: 是男朋友叫这样的
- LLM: ark / doubao-seed-1-6-flash-250615, TTFT 0.749 s, total 0.792 s
- Response: 那是男朋友叫这样的呀
- TTS: fish / s1, first byte 2.819 s, total 3.279 s
- Post-endpoint time to first audio byte: 6.279 s
## Strict gates
- schema_and_scope: **true**
- real_websocket_microphone_media: **true**
- real_silero_vad_endpoint: **true**
- real_asr: **true**
- real_streaming_llm: **true**
- real_tts_media: **true**
- measured_stage_latencies: **true**
- provenance_complete: **true**
- no_mock_probe_or_fallback: **true**
Passing proves one saved real microphone turn completed Silero VAD -> real ASR -> real LLM -> real TTS. It does not benchmark concurrency or production load.
@@ -0,0 +1,102 @@
{
"schema_version": 1,
"experiment": "6-3",
"run_id": "exp6-3-20260729T153226031Z",
"generated_at_utc": "2026-07-29T15:32:26.031Z",
"credentials_persisted": false,
"provenance": {
"host": {
"platform": "darwin",
"release": "25.3.0",
"architecture": "arm64",
"cpu_model": "Apple M2 Max",
"logical_cpu_count": 12,
"total_memory_bytes": 103079215104
},
"runtime": {
"node": "v25.6.0",
"onnxruntime_node": "^1.22.0-rev",
"axios": "^1.7.5",
"ffprobe": "ffprobe version 8.0.1 Copyright (c) 2007-2025 the FFmpeg developers"
},
"timing_clock": "process.hrtime.bigint monotonic clock"
},
"source_media": {
"path": "microphone_input.wav",
"capture_method": "browser_microphone_over_websocket",
"original_repository_path": "backend/recordings/recording_2025-02-06T14-51-38-205Z.wav",
"sha256": "e69d77415ffa39e1a2e00b99e6dbedce675faa9b4c2b703a256585861c6d2085",
"size_bytes": 161836,
"original_sha256": "e69d77415ffa39e1a2e00b99e6dbedce675faa9b4c2b703a256585861c6d2085",
"duration_seconds": 5.056,
"sample_rate_hz": 16000,
"channels": 1,
"bits_per_sample": 16,
"provenance_note": "Existing real microphone capture saved by live-audio/backend/server.js; replayed through the production Silero class for reproducible validation."
},
"stages": {
"vad": {
"execution": "real",
"mock": false,
"probe_only": false,
"fallback_used": false,
"implementation": "Silero VAD ONNX",
"model": "models/silero_vad.onnx",
"model_sha256": "2623a2953f6ff3d2c1e61740c6cdb7168133479b267dfef114a4a3cc5bdd788f",
"threshold": 0.5,
"max_silence_ms": 500,
"endpoint_detected": true,
"detected_endpoint_count": 2,
"selected_endpoint": "longest detected speech segment",
"forced_endpoint": false,
"observed_trailing_silence_ms": 511,
"speech_duration_ms": 1531,
"latency_seconds": 5.362510583,
"segment_path": "vad_segment.wav",
"segment_sha256": "61d43291d32fdbce3a32a1809c7368e12a5bf98f799f28a31e08848b8e7dda06",
"segment_bytes": 46124
},
"asr": {
"execution": "real",
"mock": false,
"probe_only": false,
"fallback_used": false,
"provider": "local-openai-whisper",
"model": "whisper-tiny",
"inference_completed": true,
"api_request_completed": false,
"external_request": false,
"latency_seconds": 3.981504083,
"transcript": "倒是男生就要战争了",
"language": "zh",
"runtime": {
"python": "3.11.4",
"torch": "2.7.0",
"openai_whisper": "20231106"
},
"model_path": "/Users/boj/.cache/whisper/tiny.pt",
"model_sha256": "65147644a518d12f04e32d6f3b26facc3f8dd46e5390956a9424a650c0ce22b9",
"model_load_seconds": 0.34700404200702906,
"model_inference_seconds": 2.5749531253241003,
"provider_reported_cost_usd": 0,
"cost_note": "Local open-source Whisper inference; no external ASR charge."
}
},
"experiment_complete": false,
"error": "Error: Real LLM failed: Request failed with status code 401\n at runLlm (/Users/boj/book/ai-agent-book/chapter6/live-audio/backend/run_real_validation.js:234:30)\n at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n at async main (/Users/boj/book/ai-agent-book/chapter6/live-audio/backend/run_real_validation.js:407:27)",
"acceptance": {
"gates": {
"schema_and_scope": true,
"real_websocket_microphone_media": true,
"real_silero_vad_endpoint": true,
"real_asr": true,
"real_streaming_llm": false,
"real_tts_media": false,
"measured_stage_latencies": false,
"provenance_complete": true,
"no_mock_probe_or_fallback": false
},
"passed": false,
"statement": "Passing proves one saved real microphone turn completed Silero VAD -> real ASR -> real LLM -> real TTS. It does not benchmark concurrency or production load."
}
}
@@ -0,0 +1,77 @@
{
"schema_version": 1,
"experiment": "6-3",
"run_id": "exp6-3-20260729T152935363Z",
"generated_at_utc": "2026-07-29T15:29:35.363Z",
"credentials_persisted": false,
"provenance": {
"host": {
"platform": "darwin",
"release": "25.3.0",
"architecture": "arm64",
"cpu_model": "Apple M2 Max",
"logical_cpu_count": 12,
"total_memory_bytes": 103079215104
},
"runtime": {
"node": "v25.6.0",
"onnxruntime_node": "^1.22.0-rev",
"axios": "^1.7.5",
"ffprobe": "ffprobe version 8.0.1 Copyright (c) 2007-2025 the FFmpeg developers"
},
"timing_clock": "process.hrtime.bigint monotonic clock"
},
"source_media": {
"path": "microphone_input.wav",
"capture_method": "browser_microphone_over_websocket",
"original_repository_path": "backend/recordings/recording_2025-02-06T14-51-38-205Z.wav",
"sha256": "e69d77415ffa39e1a2e00b99e6dbedce675faa9b4c2b703a256585861c6d2085",
"size_bytes": 161836,
"original_sha256": "e69d77415ffa39e1a2e00b99e6dbedce675faa9b4c2b703a256585861c6d2085",
"duration_seconds": 5.056,
"sample_rate_hz": 16000,
"channels": 1,
"bits_per_sample": 16,
"provenance_note": "Existing real microphone capture saved by live-audio/backend/server.js; replayed through the production Silero class for reproducible validation."
},
"stages": {
"vad": {
"execution": "real",
"mock": false,
"probe_only": false,
"fallback_used": false,
"implementation": "Silero VAD ONNX",
"model": "models/silero_vad.onnx",
"model_sha256": "2623a2953f6ff3d2c1e61740c6cdb7168133479b267dfef114a4a3cc5bdd788f",
"threshold": 0.5,
"max_silence_ms": 500,
"endpoint_detected": true,
"detected_endpoint_count": 2,
"selected_endpoint": "longest detected speech segment",
"forced_endpoint": false,
"observed_trailing_silence_ms": 509,
"speech_duration_ms": 1532,
"latency_seconds": 5.396249041,
"segment_path": "vad_segment.wav",
"segment_sha256": "61d43291d32fdbce3a32a1809c7368e12a5bf98f799f28a31e08848b8e7dda06",
"segment_bytes": 46124
}
},
"experiment_complete": false,
"error": "Error: Real ASR failed: Request failed with status code 401\n at runAsr (/Users/boj/book/ai-agent-book/chapter6/live-audio/backend/run_real_validation.js:153:67)\n at process.processTicksAndRejections (node:internal/process/task_queues:104:5)\n at async main (/Users/boj/book/ai-agent-book/chapter6/live-audio/backend/run_real_validation.js:295:27)",
"acceptance": {
"gates": {
"schema_and_scope": true,
"real_websocket_microphone_media": true,
"real_silero_vad_endpoint": true,
"real_asr": false,
"real_streaming_llm": false,
"real_tts_media": false,
"measured_stage_latencies": false,
"provenance_complete": true,
"no_mock_probe_or_fallback": false
},
"passed": false,
"statement": "Passing proves one saved real microphone turn completed Silero VAD -> real ASR -> real LLM -> real TTS. It does not benchmark concurrency or production load."
}
}