Separate stable API profile IDs from display names with legacy aliases
This commit is contained in:
1 parent
0cffcf4295
commit
a908313c8f
7 files changed
+88
-11
No files matched your search
+3
-3
@@ -147,7 +147,7 @@ class Endpoint:
|
||||
return bool(record and record.get('api_token_hash') and secrets.compare_digest(hashlib.sha256(header[7:].encode()).hexdigest(),record['api_token_hash']))
|
||||
def find_profile(self,name,kind):
|
||||
if not isinstance(name,str):raise APIError('model muss den API-Namen eines aktivierten Profils enthalten.')
|
||||
row=next((p for p in self.rows() if (p['name']==name or (kind=='image' and name=='athena-image')) and p['kind']==kind and p['enabled']),None)
|
||||
row=next((p for p in self.rows() if (name in [p.get('api_id',p['name']),p['name'],*p.get('api_aliases',[])] or (kind=='image' and name=='athena-image')) and p['kind']==kind and p['enabled']),None)
|
||||
if not row:raise APIError('Modellprofil nicht aktiviert oder unbekannt.',404,'model_not_found')
|
||||
if not row['runnable']:raise APIError('Profil derzeit nicht ausführbar: '+' '.join(row['blockers']),503,'model_unavailable')
|
||||
return row
|
||||
@@ -155,7 +155,7 @@ class Endpoint:
|
||||
data=[]
|
||||
for p in self.rows():
|
||||
if not (p['enabled'] and p['runnable'] and p['kind']==kind):continue
|
||||
row=dict(id='athena-image' if kind=='image' else p['name'],object='model',created=int(p['updated_at']),owned_by='athena-deck')
|
||||
row=dict(id='athena-image' if kind=='image' else p.get('api_id',p['name']),name=p['name'],display_name=p['name'],object='model',created=int(p['updated_at']),owned_by='athena-deck')
|
||||
if kind=='chat':
|
||||
params=p.get('parameters',{})
|
||||
row.update(context_window=int(params.get('context',8192)),parallel_slots=int(params.get('slots',1)),context_scope='shared',status={'configuration_only':True})
|
||||
@@ -316,7 +316,7 @@ class APIHandler(BaseHTTPRequestHandler):
|
||||
if set(data)-{'model','input','voice','response_format','speed','language'}:raise APIError('Nicht unterstützte TTS-Felder.')
|
||||
if data.get('response_format','wav')!='wav':raise APIError('Derzeit wird nur WAV unterstützt; response_format=wav setzen.')
|
||||
from profiles import voice_recipe
|
||||
voice=next((p for p in ep.rows() if p.get('model') and voice_recipe(p['model']) and p['name']==data.get('model') and p['enabled']),None)
|
||||
voice=next((p for p in ep.rows() if p.get('model') and voice_recipe(p['model']) and data.get('model') in [p.get('api_id',p['name']),p['name'],*p.get('api_aliases',[])] and p['enabled']),None)
|
||||
if voice:
|
||||
profile=ep.find_profile(data.get('model'),voice['kind']);backend=ep.voxcpm
|
||||
if data.get('voice','default')!='default' or data.get('speed',1)!=1:raise APIError('VoxCPM2: voice=default und speed=1 verwenden; Referenzstimme im Deck-Testbereich.')
|
||||
|
||||
Reference in new issue
Block a user