Implemented recommend

This commit is contained in:
Jamie Hardt
2025-08-27 15:27:30 -07:00
parent 4f7b2a73cb
commit de7ad3d65a

View File

@@ -14,7 +14,7 @@ from .util import ffmpeg_description, parse_ucs
def recommend_text(text: str, ctx: InferenceContext):
return None
return ctx.classify_text_ranked(text)
@click.group(epilog="For more information see "
"<https://git.squad51.us/jamie/ucsinfer>")
@@ -22,16 +22,15 @@ def recommend_text(text: str, ctx: InferenceContext):
def ucsinfer():
"""
Tools for applying UCS categories to sounds using large-language Models
"""
pass
@ucsinfer.command('recommend')
@click.option('--text', type=Optional[str], default=None,
@click.option('--text', default=None,
help="Recommend a category for given text instead of reading "
"from a file")
@click.argument('files', nargs=-1)
@click.argument('paths', nargs=-1)
@click.option('--model', type=str, metavar="<model-name>",
default="paraphrase-multilingual-mpnet-base-v2",
show_default=True,
@@ -65,7 +64,17 @@ def recommend(text, paths, model):
"text":None,
"recommendations":None
})
for rec in recommendations:
print("----------")
if 'path' in rec:
print(f"Path: {rec['path']}")
print(f"Text: {rec['text'] or '<None>'}")
if rec['recommendations']:
for r in rec['recommendations']:
cat, subcat, _ = ctx.lookup_category(r)
print(f"- {r}: {cat}-{subcat}")