chore: archive recoverable gateway source baseline
This commit is contained in:
@@ -0,0 +1,21 @@
|
||||
import json
|
||||
from pathlib import Path
|
||||
|
||||
DEFAULT_VOICE_ID = '9a97272c-3919-5606-9c8f-9552ab602528'
|
||||
PERSONAS = {'default': None, 'lvbu': ('lvbu.lorebook.json', 'lvbu.json'), 'yangmi_fiction': ('yangmi.lorebook.json', 'yangmi_fiction.json')}
|
||||
|
||||
|
||||
def resolve_persona(root, name, active_ids):
|
||||
if not isinstance(name, str) or name not in PERSONAS:
|
||||
raise ValueError('unknown persona')
|
||||
if name == 'default':
|
||||
return {'id': name, 'rules': '', 'voice_id': DEFAULT_VOICE_ID, 'fresh_conversation': False, 'locked': False, 'name': '普通助手'}
|
||||
lore_file, manifest_file = PERSONAS[name]
|
||||
root = Path(root)
|
||||
lore = json.loads((root / 'personas' / lore_file).read_text())
|
||||
manifest = json.loads((root / '.runtime/personas' / manifest_file).read_text())
|
||||
voice = manifest['voice_id']
|
||||
if voice not in active_ids: raise ValueError('persona voice inactive')
|
||||
rules = lore['rules'] + '\n' + '\n'.join(e['label'] + ': ' + e['text'] for e in lore['entries'])
|
||||
if len(rules) > 1400: raise ValueError('persona lore exceeds budget')
|
||||
return {'id': name, 'name': lore['name'], 'rules': rules, 'voice_id': voice, 'fresh_conversation': True, 'locked': True}
|
||||
Reference in New Issue
Block a user