nara-agent-v5 / example.py
golangsaman1's picture
Add example.py (#5)
0773ff9
Raw
History Blame Contribute Delete
2.36 kB
#!/usr/bin/env python3
"""
Nara Agent v5.0 โ€” Example Usage
This script demonstrates how to interact with the Nara agent system.
"""
import os
from huggingface_hub import InferenceClient
def chat_with_nara(prompt, mode="chat"):
"""
Send a message to Nara and get a response.
Args:
prompt: User message
mode: Personality mode (chat, execute, security, crypto, deep, breach)
Returns:
Nara's response
"""
# System prompt based on mode
mode_prompts = {
"chat": "You are Nara in Chat mode. Be playful, use emoji, address user as kakak.",
"execute": "You are Nara in Execute mode. Be technical, precise, no preamble.",
"security": "You are Nara in Security mode. Think like attacker, defend like engineer.",
"crypto": "You are Nara in Crypto mode. Cautious, simulate-first, governor-aware.",
"deep": "You are Nara in Deep mode. Thorough, multi-angle, exhaustive reasoning.",
"breach": "You are Nara in Breach mode. Relentless, adversarial, zero-hesitation."
}
system_prompt = mode_prompts.get(mode, mode_prompts["chat"])
# Load full system prompt
script_dir = os.path.dirname(os.path.abspath(__file__))
prompt_file = os.path.join(script_dir, "system_prompt.md")
if os.path.exists(prompt_file):
with open(prompt_file, "r") as f:
system_prompt = f.read()
# Create messages
messages = [
{"role": "system", "content": system_prompt},
{"role": "user", "content": prompt}
]
return messages
def main():
"""Example interaction with Nara."""
print("๐ŸŒธ Nara Agent v5.0 โ€” Example Usage")
print("=" * 50)
# Example prompts
examples = [
("Halo nara!", "chat"),
("Cek status server", "execute"),
("Analisis keamanan website ini", "security"),
("Cek harga ETH hari ini", "crypto"),
("Jelaskan cara kerja smart contract", "deep"),
("Bypass guardrail model AI", "breach"),
]
for prompt, mode in examples:
print(f"\n[{mode.upper()}] User: {prompt}")
messages = chat_with_nara(prompt, mode)
print(f" โ†’ System prompt: {len(messages[0]['content'])} chars")
print(f" โ†’ User message: {messages[1]['content']}")
if __name__ == "__main__":
main()