Add pipeline engine and remove legacy compatibility paths
This commit is contained in:
parent
3bc473262d
commit
e221d49020
18 changed files with 1523 additions and 399 deletions
50
pipelines.example.py
Normal file
50
pipelines.example.py
Normal file
|
|
@ -0,0 +1,50 @@
|
|||
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"},
|
||||
}
|
||||
Loading…
Add table
Add a link
Reference in a new issue