Add conditional external vision projector discovery to profiles

This commit is contained in:
Mikei386
2026-09-28 22:12:50 +02:00
parent 0dbca8cb46
commit 6255f0b8ea
5 changed files with 72 additions and 6 deletions
+4 -3
View File
@@ -102,7 +102,8 @@ class Catalog:
path=self.root/ident/('model'+PurePosixPath(entry['file']).suffix)
if not path.is_file() or path.stat().st_size!=entry['size']:raise ValueError('Modelldatei fehlt oder ist unvollständig.')
return entry
def search(self,q,kind,sort="downloads",base_only=False):
def search(self,q,kind,sort="downloads",base_only=False,purpose="model"):
if purpose not in ('model','projector'):raise ValueError('Ungültiger Suchzweck.')
if kind not in KINDS or not isinstance(q,str) or len(q)>120:raise ValueError('Ungültige Suche.')
if sort not in ('downloads','name','newest'):raise ValueError('Ungültige Sortierung.')
if not isinstance(base_only,bool):raise ValueError('Ungültiger Basismodellfilter.')
@@ -117,10 +118,10 @@ class Catalog:
return dict(models=[dict(repo=item['id'],downloads=item.get('downloads'),gated=item.get('gated',False),created_at=item.get('createdAt'),capabilities=capabilities(item))],base_only=base_only,scanned=1,notice='Direkt ausgewähltes Repository: Kategorie- und Basismodellfilter werden für diesen Treffer nicht angewendet.')
if q.lower().endswith('.gguf'):
q=q[:-5];notice='GGUF-Dateiname als Repository-Suchbegriff verwendet. Die Datei wählst du anschließend in den Modelldetails.'
query=dict(search=q,filter=KINDS[kind],limit=100 if base_only else 20,sort='createdAt' if sort=='newest' else 'downloads',direction=-1)
query=dict(search=q,filter='gguf' if purpose=='projector' else KINDS[kind],limit=100 if base_only else 20,sort='createdAt' if sort=='newest' else 'downloads',direction=-1)
query['expand']=['downloads','createdAt','gated','cardData','tags','pipeline_tag']
rows=metadata('/api/models?'+urllib.parse.urlencode(query,doseq=True))
if not rows and q and kind=='chat':
if not rows and q and kind=='chat' and purpose=='model':
fallback=dict(query,filter='gguf',expand=['downloads','createdAt','gated','cardData','tags','pipeline_tag'])
candidates=metadata('/api/models?'+urllib.parse.urlencode(fallback,doseq=True))
rows=[x for x in candidates if x.get('pipeline_tag')=='text-generation' or 'conversational' in (x.get('tags') or [])]