This commit is contained in:
Dita Aji Pratama 2026-07-15 09:47:48 +07:00
parent fa7f5817c1
commit 465a689bb5
3 changed files with 15 additions and 13 deletions

View File

@ -116,9 +116,9 @@ def _agent_loop(app):
app.scroll = 999999
skill = config.AGENT_SKILL
if skill == "roleplayer":
if "roleplayer" in skill:
tool_reminder = "WAJIB gunakan tools ragroleplay (seperti memories_latest, memories_check, memories_store) untuk mengelola memori percakapan. Jangan menjawab tanpa konteks memori yang akurat."
elif skill in ("programmer", "analyst"):
elif any(s in skill for s in ("programmer", "analyst")):
tool_reminder = "Gunakan tools yang tersedia untuk menjawab. Jangan jawab dari pengetahuan sendiri."
else:
tool_reminder = None

View File

@ -193,7 +193,7 @@ class TelegramClient:
self._schedule_send(chat_id, 'Memulai sesi baru. Ada yang bisa dibantu?', reply_to_msg_id)
return
if self._skill == 'roleplayer' and chat_type == 'private':
if 'roleplayer' in self._skill and chat_type == 'private':
try:
results = ragroleplay.user_load(config.ragroleplay_db_path, unique_id=str(chat_id), character=personality.PERSONALITY.name)
if results:
@ -213,20 +213,22 @@ class TelegramClient:
)
session.add_message('system', context)
else:
tg_info = f'ID: {chat_id}'
if tg_username:
tg_info += f', @{tg_username}'
tg_id_str = str(chat_id)
tg_user_str = tg_username or ''
session.add_message('system',
f'[User Context: Pengguna baru — belum ada di database]\n'
f'[PENTING: Kamu BELUM mengenal user ini. WAJIB tanya nama sebagai pembuka. '
f'Setelah nama diketahui, simpan via users_store. '
f'Lanjutkan percakapan natural dan proaktif melengkapi data user lainnya di pesan berikutnya.]\n'
f'[Platform: Telegram ({tg_info})]')
f'[Platform: Telegram]\n'
f'[PENTING: Saat memanggil users_store, gunakan nilai berikut:]\n'
f'[telegram_id: {tg_id_str}]\n'
f'[telegram_username: {tg_user_str}]')
except Exception:
pass
session.add_message('user', body)
is_roleplay = self._skill == 'roleplayer'
is_roleplay = 'roleplayer' in self._skill
asyncio.run_coroutine_threadsafe(
self._app.bot.send_chat_action(chat_id=chat_id, action='typing'),
@ -288,7 +290,7 @@ class TelegramClient:
msg = 'Max iterations reached without final answer.'
self._schedule_send(chat_id, msg, reply_to_msg_id)
if should_close and chat_type == 'private' and self._skill == 'roleplayer':
if should_close and chat_type == 'private' and 'roleplayer' in self._skill:
print(f'[{_ts()}] Natural close triggered for {chat_id}', flush=True)
self._session_mgr.reset(str(chat_id))
else:

View File

@ -297,7 +297,7 @@ class XMPPClient(ClientXMPP):
self._schedule_send(jid, 'Memulai sesi baru. Ada yang bisa di bantu?')
return
if self._skill == 'roleplayer':
if 'roleplayer' in self._skill:
try:
results = ragroleplay.user_load(config.ragroleplay_db_path, unique_id=jid, character=personality.PERSONALITY.name)
if results:
@ -328,7 +328,7 @@ class XMPPClient(ClientXMPP):
session.add_message('user', body)
is_roleplay = self._skill == 'roleplayer'
is_roleplay = 'roleplayer' in self._skill
if not is_roleplay:
self._schedule_send(jid, f'> {body}\nThinking...')
@ -391,7 +391,7 @@ class XMPPClient(ClientXMPP):
self._schedule_send(jid, f'> {quote}\n{msg}', 'chat')
# Natural close: DM only, roleplayer only
if should_close and self._skill == 'roleplayer':
if should_close and 'roleplayer' in self._skill:
print(f'[{_ts()}] Natural close triggered for {jid}', flush=True)
self._session_mgr.reset(jid)
else:
@ -427,7 +427,7 @@ class XMPPClient(ClientXMPP):
my_name = personality.PERSONALITY.name
quote = f'[{nick}] {body}'
_is_roleplay = self._skill == 'roleplayer'
_is_roleplay = 'roleplayer' in self._skill
def on_tool_calls(tnames):
if not _is_roleplay: