chore: project foundation

Contracts (the shared language):
- percept / state / context / utterance / render / audio / capabilities
- Capability model instead of vendor schemas (see below)

Providers (capability-based abstraction):
- LLM + Embedding: OpenAI-compatible shape IS the standard, adopted directly
- ASR: internal contract is an event stream (partial -> final), because
  /v1/audio/transcriptions has no partial and dialogue needs it for
  endpointing. OpenAI adapter degrades to supports_partial=False.
- TTS: internal contract carries tags/emotion/style, because
  /v1/audio/speech has no paralinguistics and [laughter]/[breath] are
  the core of feeling alive. Unsupported providers are stripped AND
  reported via Degradation -- silent degradation is forbidden.
- Avatar: no de-facto standard, custom RenderCmd protocol driven by State.

Core:
- mood: dynamical system, slow variables, negativity bias (grudge),
  numbing after prolonged negativity
- bazi: four pillars -> numeric vector; 'ming' is data, not prose
- projection: phi, system event -> in-world statement; uncovered events
  are counted as projection gaps

Storage:
- SQLite schema, three memory layers, dyad ledger
- accessibility floor 0.03 (not 0): forgettable but still there

Config split:
- models.yaml is the ONLY place model versions live
- character.yaml holds world rules / emotion params, no version numbers

58 tests pass; ruff clean.
This commit is contained in:
mobai
2026-10-19 20:08:52 +08:00
commit 1012d8bb79
57 changed files with 6452 additions and 0 deletions
+90
View File
@@ -0,0 +1,90 @@
# =============================================================================
# 模型选型 —— 全项目唯一允许写模型版本号的地方
# =============================================================================
#
# 为什么集中在这里:
# 任何写死版本号的代码,三个月后都会过时。把"会过期的东西"压缩到
# 这一个文件,换模型时只改这里,其余部分不动。
#
# 版本依据:2026-10 调研。每季度复核一次。
#
# 换模型时的纪律:
# 1. 新模型发布到入选,至少间隔一个季度(除非它解决的是你的阻塞问题)
# 2. 换完跑一遍 tests/test_providers_contract.py
# 3. 记录降级情况:如果新 provider 少了某项能力,日志里会有 [degraded]
# =============================================================================
# ---- 主对话 ----
# OpenAI 兼容 /v1/chat/completions。DeepSeek / Qwen / vLLM / Ollama 都通用。
llm:
provider: openai_compat
model: deepseek-v4.1-flash
base_url: https://api.deepseek.com/v1
api_key_env: DEEPSEEK_API_KEY
timeout: 60.0
temperature: 0.85
# ---- 快反 / 后台(本地小模型,可选)----
# 用不到就整段注释掉,代码会回退到 llm。
# llm_fast:
# provider: openai_compat
# model: qwen3.5-4b-instruct
# base_url: http://127.0.0.1:8000/v1
# api_key_env: null
# timeout: 20.0
# ---- 主 ASR ----
# 内部契约是「事件流」:partial → final。
# 如果你的后端只有「文件进→文本出」,它会以 supports_partial=False 降级,
# 端点检测会退化成纯能量判定(会抢话)。
asr:
provider: scripted # 起步用 scripted;生产换流式后端
model: qwen3-asr-1.7b
language: zh
# ---- 副语言旁路 ----
# 独立于主 ASR。2026-10 仍不存在「中文流式识别 + 结构化副语言」的单一模型。
# 关掉它,伴侣就不知道用户笑了,只知道看到了「哈哈」两个字。
paralinguistic:
provider: scripted
model: sensevoice-small
window_ms: 1500
enabled: true
# ---- TTS ----
# 注意 provider 能力差异:
# silence / cosyvoice → 支持 speech_tags([laughter] [breath])
# openai_compat → 不支持,标签会被剥掉并上报降级
tts:
provider: silence
model: fun-cosyvoice3-0.5b
voice_ref: null # 零样本克隆参考音频,3–10 秒
sample_rate: 16000
# ---- VAD ----
# Silero v6 只吃 16kHz。改 sample_rate 前先确认模型支持。
vad:
provider: energy # 起步用 energy;生产换 silero
model: silero-v6
sample_rate: 16000
# ---- 轮次判定 ----
# 两段式的第二段:判断「说完了没」,不是「有没有声音」。
turn:
provider: heuristic
silence_min_ms: 150
silence_hard_end_ms: 800 # 伴侣场景建议 700–900,宁可多等不抢话
# ---- Embedding ----
embedding:
provider: openai_compat
model: qwen3-embedding-0.6b
base_url: null
api_key_env: null
dim: 1024
# ---- 形象 ----
avatar:
route: vrm
renderer: three.js
lipsync: envelope