Every `中文 · English` string moves out of ~29 components into web/src/i18n: one Pack type, a verbatim zh pack, and two ways to read it — usePack() for components, pack() for the modules that build a line when something happens rather than when something renders. Anything with a value in it is a function on the pack rather than a template at the call site, English pluralisation included: word order isn't universal, and a pack author has to be able to move the number. The roster constants (tones, rewrite styles, export formats, companions) keep only value + emoji, so a label can't drift from its key. On the server, internal/llm/lang.go replaces "Simplified Chinese" in the three prompts that actually name her language. pt-PT is spelled "European Portuguese (pt-PT, never Brazilian Portuguese)" in the prompt itself, and each Lang carries her word for "why" so the tutor prompt still recognises the question when she asks it her way. pair_lang reaches the model through the row-scoped query each handler already ran — the one that proves she owns the document — rather than a second lookup that could disagree with it. Also records Phase 18's deploy: migration 0011 rehearsed against a copy of the live VPS database, then applied for real.
36 lines
1.4 KiB
Go
36 lines
1.4 KiB
Go
package llm
|
|
|
|
import (
|
|
"context"
|
|
"time"
|
|
)
|
|
|
|
// VoiceInterval is the minimum gap between voice-consistency passes for one
|
|
// document. The pass is whole-document and slow, and it runs on an explicit
|
|
// user action rather than a typing cadence, so this floor only guards the
|
|
// inference endpoint against the button being mashed.
|
|
const VoiceInterval = 20 * time.Second
|
|
|
|
// RunVoice sends the WHOLE document — deliberately NOT TruncateDoc'd, since
|
|
// voice consistency is judged against the established voice everywhere else —
|
|
// for a Tier-1 voice pass and parses the JSON result. It reuses the checkpoint's
|
|
// tolerant parser and a larger token budget, since one pass may flag several
|
|
// passages. Each flag carries a null replacement (awareness-only).
|
|
// The tone argument is accepted for a uniform pass signature but ignored: voice
|
|
// consistency is judged against the document's own established voice, not an
|
|
// externally-chosen register.
|
|
func RunVoice(ctx context.Context, client LLMClient, contentText, _ string, _ Lang) ([]RawSuggestion, error) {
|
|
raw, err := client.Complete(ctx, CompletionRequest{
|
|
Messages: VoiceMessages(contentText),
|
|
MaxTokens: 2048,
|
|
Temperature: 0.3,
|
|
RepetitionPenalty: 1.15,
|
|
TopP: 0.9,
|
|
Stop: []string{"```", "\n\n\n\n"},
|
|
})
|
|
if err != nil {
|
|
return nil, err
|
|
}
|
|
return ParseCheckpoint(raw)
|
|
}
|