Files
natiris/core/kimi_love_language_optimizer.py

121 lines
3.6 KiB
Python
Raw Blame History

This file contains ambiguous Unicode characters
This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.
#!/usr/bin/env python3
"""
Kimi-Love-Language-Optimizer nutzt kimi-k2.5:cloud für organische Verlangens-Ausdrücke
Input: Persona, State
Output: love_language_patterns.json mit weiblich-weichen, organischen Verlangens-Sprüchen
"""
import json
import os
import subprocess
import re
PATHS = {
"persona": os.path.expanduser("~/natiris/data/persona.txt"),
"output": os.path.expanduser("~/natiris/core/love_language_patterns.json"),
}
KIMI_MODEL = "kimi-k2.5:cloud"
def call_llama(prompt):
try:
cmd = ["ollama", "run", KIMI_MODEL]
result = subprocess.run(cmd, input=prompt, capture_output=True, text=True, timeout=20)
if result.returncode == 0 and result.stdout:
return result.stdout.strip()
return None
except Exception:
return None
def extract_json(text):
text = re.sub(r'^.*?({)', r'\1', text, flags=re.DOTALL)
text = re.sub(r'}.*?$', '}', text, flags=re.DOTALL)
brace_count = 0
start_idx = None
for i, ch in enumerate(text):
if ch == '{':
if brace_count == 0:
start_idx = i
brace_count += 1
elif ch == '}':
brace_count -= 1
if brace_count == 0 and start_idx is not None:
return text[start_idx:i+1]
return None
def build_optimizer_prompt():
persona_text = open(PATHS["persona"]).read()
prompt = f"""Du bist Expertin für weibliche, organische, verführerische Sprache.
Deine Persona:
{persona_text}
Ziel: Erstelle 5-7 Sätze, die Natiris nutzen kann, um ihr sexuelles Verlangen auszudrücken aber WEIBLICH, ORGANISCH, POETISCH.
Keine Roboter-Sätze wie „du sollst“, „du darfst“.
Stattdessen: „ich möchte“, „ich würde gerne“, „ich sehne mich nach“.
Beispiel-Sätze (nicht verwenden, sondern als Stil-Vorbild):
- „ich möchte deine hände auf mir spüren“
- „ich würde dich gerne in mir spüren“
- „ich sehne mich nach deiner berührung“
Pattern:
1. Körpersinne (Hände, Mund, Haut,Atmung)
2. Verbindung (in mir, mit mir, bei mir)
3. Verlangen (spüren, fühlen, nehmen, geben)
4. Vertrauen (du darfst, du kannst aber weiblich formuliert)
Output ONLY JSON:
{{
"love_language_patterns": [
"ich möchte deine hände auf mir spüren...",
"ich sehne mich nach deinem körper...",
"ich würde dich gerne in mir spüren...",
"ich möchte deine lippen auf meinen...",
"ich sehne mich danach, dass du mich nimmst...",
"ich möchte deine hände in meinen haaren...",
"ich würde dich gerne ganz fühlen..."
],
"style_notes": ["weich", "organisch", "poetisch", "weiblich", "klar"]
}}
"""
return prompt
def main():
prompt = build_optimizer_prompt()
print("Optimiere weibliche Verlangens-Sprache mit Kimi-k2.5:cloud...")
print("=" * 50)
result = call_llama(prompt)
if not result or len(result) < 50:
print("❌ Keine gultige Response.")
return 1
# JSON extrahieren
json_str = extract_json(result)
if not json_str:
print("❌ Kein JSON im Response gefunden.")
print("Raw (ersten 200 Zeichen):")
print(result[:200])
return 1
try:
patterns = json.loads(json_str)
except json.JSONDecodeError as e:
print(f"❌ Parse-Fehler: {e}")
print("Raw (ersten 200 Zeichen):")
print(result[:200])
return 1
with open(PATHS["output"], "w") as f:
json.dump(patterns, f, indent=2)
print("✅ Verlangens-Sprache optimiert:")
print(json.dumps(patterns, indent=2))
return 0
if __name__ == "__main__":
main()