source/main.py aktualisiert
This commit is contained in:
@@ -38,6 +38,8 @@ load_dotenv(ENV_FILE)
|
||||
DB_PATH = DATA_DIR / "cluster.db"
|
||||
PROMPT_FILE = CONFIG_DIR / "system_prompt.txt"
|
||||
|
||||
WEB_USER_NAME = os.getenv("WEB_USER_NAME", "Admin")
|
||||
|
||||
# Workspace Dateien
|
||||
NOTES_FILE = WORKSPACE_DIR / "NOTIZEN.md"
|
||||
TODO_FILE = WORKSPACE_DIR / "TODO.md"
|
||||
@@ -107,7 +109,7 @@ def get_db():
|
||||
conn.row_factory = sqlite3.Row
|
||||
return conn
|
||||
|
||||
def get_system_prompt():
|
||||
def get_system_prompt(current_user=WEB_USER_NAME):
|
||||
conn = get_db()
|
||||
nodes = conn.execute('SELECT * FROM nodes').fetchall()
|
||||
conn.close()
|
||||
@@ -123,11 +125,12 @@ def get_system_prompt():
|
||||
else:
|
||||
prompt = "Fehler: system_prompt.txt nicht gefunden!"
|
||||
|
||||
# Platzhalter durch die echten Pfade ersetzen
|
||||
# Platzhalter durch die echten Werte ersetzen
|
||||
prompt = prompt.replace("{node_info}", node_info)
|
||||
prompt = prompt.replace("{workspace_dir}", str(WORKSPACE_DIR))
|
||||
prompt = prompt.replace("{notes_file}", str(NOTES_FILE))
|
||||
prompt = prompt.replace("{todo_file}", str(TODO_FILE))
|
||||
prompt = prompt.replace("{user_name}", current_user) # <-- NEU: Der Name!
|
||||
|
||||
return prompt
|
||||
|
||||
@@ -232,7 +235,14 @@ async def handle_telegram_message(update: Update, context: ContextTypes.DEFAULT_
|
||||
await update.message.reply_chat_action(action="typing")
|
||||
|
||||
# 2. KI fragen
|
||||
ai_response = await get_ai_response(user_msg, get_system_prompt())
|
||||
# Vorname des Telegram-Nutzers auslesen
|
||||
sender_name = update.message.from_user.first_name
|
||||
|
||||
# Tipp-Status anzeigen
|
||||
await update.message.reply_chat_action(action="typing")
|
||||
|
||||
# 2. KI fragen (und den dynamischen Namen übergeben!)
|
||||
ai_response = await get_ai_response(user_msg, get_system_prompt(sender_name))
|
||||
|
||||
commands = re.findall(r'<EXECUTE target="(.*?)">(.*?)</EXECUTE>', ai_response, re.I | re.S)
|
||||
clean_msg = re.sub(r'<EXECUTE.*?>.*?</EXECUTE>', '', ai_response, flags=re.I | re.S).strip()
|
||||
|
||||
Reference in New Issue
Block a user