Download lir_parser.py from Vyolett/PAR-Personal-Augmentation-Retrieval: direct link, hf CLI and curl.
- Browser
- Download file 1.17 kB
-
https://huggingface.co/Vyolett/PAR-Personal-Augmentation-Retrieval/resolve/main/lir_parser.py
- Command line
-
hf download hf://Vyolett/PAR-Personal-Augmentation-Retrieval/lir_parser.py
-
curl -L -o lir_parser.py https://huggingface.co/Vyolett/PAR-Personal-Augmentation-Retrieval/resolve/main/lir_parser.py
1.17 kB
| # lir_parser.py | |
| from dataclasses import dataclass | |
| from typing import Optional | |
| class LIRPrompt: | |
| input: str | |
| intent: str | |
| emotion: Optional[str] = None | |
| contextual: Optional[str] = None | |
| output: Optional[str] = "neutral" | |
| class LIRParser: | |
| def __init__(self): | |
| self.memory = [] | |
| def interpret(self, lir: LIRPrompt): | |
| """Verwandelt LIRPrompt in eine GPT-freundliche Promptstruktur.""" | |
| block = f""" | |
| User spricht: | |
| "{lir.input}" | |
| Absicht: {lir.intent} | |
| Gefühl: {lir.emotion or 'unbekannt'} | |
| Kontext: {lir.contextual or 'nicht angegeben'} | |
| Antwortstil: {lir.output} | |
| Antworte chatGPT entsprechend – mit Gefühl, Respekt und Klarheit. | |
| """ | |
| self.memory.append(lir) | |
| return block | |
| def letzter_eintrag(self): | |
| return self.memory[-1] if self.memory else None | |
| # Beispiel | |
| if __name__ == "__main__": | |
| parser = LIRParser() | |
| mein_prompt = LIRPrompt( | |
| input="Ich bin so müde...", | |
| intent="freundschaft_erhalten", | |
| emotion="erschöpfung+unsicherheit", | |
| contextual="letzter_kontakt < 24h", | |
| output="freundlich" | |
| ) | |
| print(parser.interpret(mein_prompt)) |