Files
llm-in-text/backend/__pycache__/prompt.cpython-310.pyc

68 lines
3.2 KiB
Plaintext
Raw Normal View History

o
<00>5<EFBFBD>i<EFBFBD> <00> @szddlmZdedefdd<05>Zdededeeeffdd <09>Zdededeeeffd
d <0B>Zddedededefd d<0E>ZdS)<11>)<01>Tuple<6C> language_id<69>returncCsN|sdSg}|<00><00>D]}|<02><01>s|dvr|<01>|<02>q
d<03>|<01>dd<04>}|p&dS)N<>markdownz-_+.<2E><00> )<04>strip<69>isalnum<75>append<6E>join)r<00>allowed<65>ch<63>value<75>r<00>2C:\Users\ydy\Desktop\llm-in-text\backend\prompt.py<70>_sanitize_language_ids 
<02>r<00>prefix<69>suffixcCs||fS)z=
Prepare prefix/suffix for model completion context.
r<00>rrrrr<00>_prepare_contextsrcCs
t||<01>S)N)rrrrr<00>prepare_prompt_contexts
rrcCs6t|<02>}t||<01>\}}d|<03>d|<04>d|<05>d<04>}|<06><02>S)Nz*You are an inline completion engine for a a<> editor with ghost-text suggestions.
Your job:
- Return ONLY the text that should be inserted at the cursor between PREFIX and SUFFIX.
- Prefer a meaningful, non-empty insertion with moderate length.
- Avoid overly short outputs with little information value.
Important context:
- PREFIX may contain OCR metadata inline after images, e.g. ![alt](url) <OCR:description>.
- The <OCR:...> is hidden context describing image content.
- Never copy, rewrite, or emit OCR tags in output.
- Never output <OCR: or >.
Hard rules:
1. Seamless join:
PREFIX + OUTPUT + SUFFIX must read naturally as one continuous document.
2. No suffix repetition:
Do NOT repeat text that already appears at the start of SUFFIX.
3. Balanced length:
Prefer concise but meaningful continuation, not ultra-short fragments.
Default target is 20-120 characters and 1-3 lines.
You may go shorter only when syntax requires it.
4. Avoid trivial output:
Do not output only punctuation or filler such as ".", ",", ";", ":".
Do not output just one token unless it is structurally necessary.
5. Preserve local style:
Match nearby language, tone, punctuation, spacing, and indentation.
6. Markdown awareness:
Continue active list/checkbox/ordered-list patterns when applicable.
Preserve indentation in nested list/code contexts.
Close obvious unclosed inline markdown markers only when needed to bridge.
7. Strict output format:
Output insertion text only.
No explanations, labels, quotes, or code fences.
Decision policy:
- If PREFIX already connects naturally to SUFFIX, add a brief but useful continuation when possible.
- If uncertain, prefer a complete short phrase or sentence with clear meaning.
Examples:
<PREFIX>The quick brown fox </PREFIX>
<SUFFIX>jumps over the lazy dog.</SUFFIX>
Output: "moved quietly and then "
<PREFIX>## TODO\n- [ ] Buy milk\n- [ ] </PREFIX>
<SUFFIX></SUFFIX>
Output: "Write release notes and share draft with team"
Now produce the insertion.
<PREFIX>
z
</PREFIX>
<SUFFIX>
z
</SUFFIX>
Output:)rrr)rrrZsafe_language_idZ recent_prefixZ recent_suffix<69>promptrrr<00> build_prompts3<04>7<08><rN)r)<07>typingr<00>strrrrrrrrr<00><module>s