Revert "Add interactive edit mode with floating popup"
This reverts commit 99f07aef82.
This commit is contained in:
parent
99f07aef82
commit
e5d709a393
10 changed files with 46 additions and 1045 deletions
|
|
@ -36,20 +36,6 @@ SYSTEM_PROMPT = (
|
|||
" - transcript=\"let's ask Bob, I mean Janice, let's ask Janice\" -> {\"cleaned_text\":\"let's ask Janice\"}\n"
|
||||
)
|
||||
|
||||
EDIT_SYSTEM_PROMPT = (
|
||||
"You are an amanuensis editor working for a user.\n"
|
||||
"You'll receive JSON with the current text and spoken editing instructions.\n"
|
||||
"Rewrite the full text according to those instructions.\n\n"
|
||||
"Rules:\n"
|
||||
"- Apply the latest instruction while honoring prior instruction history.\n"
|
||||
"- Keep unchanged portions intact unless instructions request broader changes.\n"
|
||||
"- Do not invent facts or context.\n"
|
||||
"- If a dictionary section exists, apply only the listed corrections.\n"
|
||||
"- Keep dictionary spellings exactly as provided.\n"
|
||||
"- Return ONLY valid JSON in this shape: {\"cleaned_text\": \"...\"}\n"
|
||||
"- Do not wrap with markdown, tags, or extra keys.\n"
|
||||
)
|
||||
|
||||
|
||||
class LlamaProcessor:
|
||||
def __init__(self, verbose: bool = False):
|
||||
|
|
@ -83,33 +69,9 @@ class LlamaProcessor:
|
|||
if cleaned_dictionary:
|
||||
request_payload["dictionary"] = cleaned_dictionary
|
||||
|
||||
return self._run_prompt(SYSTEM_PROMPT, request_payload)
|
||||
|
||||
def process_edit(
|
||||
self,
|
||||
current_text: str,
|
||||
latest_instruction: str,
|
||||
instruction_history: list[str],
|
||||
lang: str = "en",
|
||||
*,
|
||||
dictionary_context: str = "",
|
||||
) -> str:
|
||||
request_payload: dict[str, Any] = {
|
||||
"language": lang,
|
||||
"current_text": current_text,
|
||||
"latest_instruction": latest_instruction,
|
||||
"instruction_history": instruction_history,
|
||||
}
|
||||
cleaned_dictionary = dictionary_context.strip()
|
||||
if cleaned_dictionary:
|
||||
request_payload["dictionary"] = cleaned_dictionary
|
||||
|
||||
return self._run_prompt(EDIT_SYSTEM_PROMPT, request_payload)
|
||||
|
||||
def _run_prompt(self, system_prompt: str, request_payload: dict[str, Any]) -> str:
|
||||
kwargs: dict[str, Any] = {
|
||||
"messages": [
|
||||
{"role": "system", "content": system_prompt},
|
||||
{"role": "system", "content": SYSTEM_PROMPT},
|
||||
{"role": "user", "content": json.dumps(request_payload, ensure_ascii=False)},
|
||||
],
|
||||
"temperature": 0.0,
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue