aman/pipelines.example.py

50 lines
1.1 KiB
Python

import json
CONTEXT_PROMPT = (
"Return a concise plain-text context hint (max 12 words) "
"for the transcript domain and style."
)
AMANUENSIS_PROMPT = (
"Rewrite the transcript into clean prose without changing intent. "
"Return only the final text."
)
def default_pipeline(audio, lib) -> str:
text = lib.transcribe(audio)
if not text:
return ""
context = lib.llm(
system_prompt=CONTEXT_PROMPT,
user_prompt=json.dumps({"transcript": text}, ensure_ascii=False),
llm_opts={"temperature": 0.0},
).strip()
output = lib.llm(
system_prompt=AMANUENSIS_PROMPT,
user_prompt=json.dumps(
{"transcript": text, "context": context},
ensure_ascii=False,
),
llm_opts={"temperature": 0.0},
)
return output.strip()
def caps_pipeline(audio, lib) -> str:
return lib.transcribe(audio).upper()
HOTKEY_PIPELINES = {
"Super+m": default_pipeline,
"Super+Shift+m": caps_pipeline,
}
PIPELINE_OPTIONS = {
"Super+m": {"failure_policy": "best_effort"},
"Super+Shift+m": {"failure_policy": "strict"},
}