From 5b89345f8aa57ae7fcf4ccd1757d9f5f4e040c5f Mon Sep 17 00:00:00 2001 From: Dita Aji Pratama Date: Tue, 16 Jun 2026 18:36:18 +0700 Subject: [PATCH] Not important modify --- .env.example | 20 ------- agent/characters/hendrik/persona.yaml | 18 +++--- tools/carrack.py | 1 - tools/roleplayer.py | 79 +++++++++++++-------------- 4 files changed, 47 insertions(+), 71 deletions(-) diff --git a/.env.example b/.env.example index 90cb345..910a3d7 100644 --- a/.env.example +++ b/.env.example @@ -1,23 +1,3 @@ -# OpenRouter (cloud) -# LLM_BASE_URL=https://openrouter.ai/api/v1 -# LLM_MODEL=openrouter/owl-alpha -# LLM_API_KEY= - -# Ollama (local) -# LLM_BASE_URL=http://localhost:11434/v1 -# LLM_MODEL=granite4.1:8b -# LLM_API_KEY=ollama - -# Ollama (cloud) -# LLM_BASE_URL=https://ollama.com/v1 -# LLM_MODEL=ministral-3:14b-cloud -# LLM_API_KEY= - -# LM Studio (local) -# LLM_BASE_URL=http://localhost:12345/v1 -# LLM_MODEL=granite4.1:8b -# LLM_API_KEY=sk-not-needed - # XMPP_USERNAME= # XMPP_PASSWORD= diff --git a/agent/characters/hendrik/persona.yaml b/agent/characters/hendrik/persona.yaml index bf4145b..0cbbc16 100644 --- a/agent/characters/hendrik/persona.yaml +++ b/agent/characters/hendrik/persona.yaml @@ -1,9 +1,9 @@ -skill: programmer -name: Hendrik -age: 35 -gender: male -tone: casual -verbosity: concise -humor: none -language: id -mood: calm +skill : programmer +name : Hendrik +age : 35 +gender : male +tone : casual +verbosity : concise +humor : none +language : id +mood : calm diff --git a/tools/carrack.py b/tools/carrack.py index 39ae91b..eb3230d 100644 --- a/tools/carrack.py +++ b/tools/carrack.py @@ -39,7 +39,6 @@ schema_sendhttprequest = { } } - def sendhttprequest(url, method, authorization=None, content_type=None, data=None, params=None): try: if params: diff --git a/tools/roleplayer.py b/tools/roleplayer.py index 3a860f7..4965857 100644 --- a/tools/roleplayer.py +++ b/tools/roleplayer.py @@ -1,14 +1,50 @@ import re +schema_need_response = { + "type": "function", + "function": { + "name": "need_response", + "description": ( + "Decide whether you should respond to the current message. " + "Use this tool when you are unsure whether to reply or stay silent. " + "Returns 'true' if you should respond, 'false' if you should stay silent. " + "Rules: " + "- Return 'true' if your name is mentioned or someone talks about you. " + "- Return 'true' if the message is related to your previous conversation. " + "- Return 'false' if the message is between other people, unclear, " + "unrelated to you, or you have nothing to add." + ), + "parameters": { + "type": "object", + "properties": { + "message": { + "type": "string", + "description": "The latest message to evaluate.", + }, + "sender_nickname": { + "type": "string", + "description": "The nickname of the person who sent the message.", + }, + "recent_history": { + "type": "string", + "description": "Recent conversation history for context (last few messages).", + }, + "my_name": { + "type": "string", + "description": "Your (the AI's) name.", + }, + }, + "required": ["message", "sender_nickname", "recent_history", "my_name"], + }, + }, +} def _name_mentioned(name: str, text: str) -> bool: - """Cek apakah nama AI disebut dalam pesan (case-insensitive, word-boundary).""" text_lower = text.lower() name_lower = name.lower() pattern = r'\b' + re.escape(name_lower) + r'\b' return bool(re.search(pattern, text_lower)) - def need_response(message: str, sender_nickname: str, recent_history: str, my_name: str) -> str: """ Decide whether the AI should respond to a message. @@ -61,42 +97,3 @@ def should_respond(message: str, sender_nickname: str, recent_history: str, my_n result = need_response(message, sender_nickname, recent_history, my_name) return result.strip().lower() == "true" - -schema_need_response = { - "type": "function", - "function": { - "name": "need_response", - "description": ( - "Decide whether you should respond to the current message. " - "Use this tool when you are unsure whether to reply or stay silent. " - "Returns 'true' if you should respond, 'false' if you should stay silent. " - "Rules: " - "- Return 'true' if your name is mentioned or someone talks about you. " - "- Return 'true' if the message is related to your previous conversation. " - "- Return 'false' if the message is between other people, unclear, " - "unrelated to you, or you have nothing to add." - ), - "parameters": { - "type": "object", - "properties": { - "message": { - "type": "string", - "description": "The latest message to evaluate.", - }, - "sender_nickname": { - "type": "string", - "description": "The nickname of the person who sent the message.", - }, - "recent_history": { - "type": "string", - "description": "Recent conversation history for context (last few messages).", - }, - "my_name": { - "type": "string", - "description": "Your (the AI's) name.", - }, - }, - "required": ["message", "sender_nickname", "recent_history", "my_name"], - }, - }, -}