diff --git a/README.md b/README.md index 342e8cb..922a04d 100644 --- a/README.md +++ b/README.md @@ -76,10 +76,10 @@ A structured build plan for developing and deploying the AlphaBot Discord compan - [x] Add `!setpersona ""` command - Updates `persona.json` dynamically from a user-provided string - (Optional) Sets bot name using Discord API -- [ ] **Test live personality switching via command** +- [x] **Test live personality switching via command** - Not working. Personality is being loaded but it doesnt actually work -![Delta Fail Screenshot](docs/images/personality-test-fail.png) +![Delta Lives Screenshot](docs/images/delta-lives.png) šŸ“ *This unlocks full customization without editing code or restarting the bot.* diff --git a/__pycache__/ai.cpython-310.pyc b/__pycache__/ai.cpython-310.pyc index 25c3561..c379fe9 100644 Binary files a/__pycache__/ai.cpython-310.pyc and b/__pycache__/ai.cpython-310.pyc differ diff --git a/__pycache__/personality.cpython-310.pyc b/__pycache__/personality.cpython-310.pyc index fc36870..0f6f5b9 100644 Binary files a/__pycache__/personality.cpython-310.pyc and b/__pycache__/personality.cpython-310.pyc differ diff --git a/ai.py b/ai.py index e1e0a88..310aa06 100644 --- a/ai.py +++ b/ai.py @@ -6,30 +6,38 @@ from dotenv import load_dotenv from personality import load_persona load_dotenv() -AI_URL = os.getenv("OLLAMA_API_URL") +AI_URL = os.getenv("OLLAMA_API_URL") # e.g., http://localhost:11434/api/generate def get_ai_response(user_prompt): persona = load_persona() + + # Sanitize prompt + safe_inject = persona["prompt_inject"].replace("ā€œ", "\"").replace("ā€", "\"").replace("’", "'") + + # Build final prompt for /generate full_prompt = ( - f"You are {persona['name']}.\n" - f"{persona['prompt_inject']}\n" - f"Never break character.\n\n" + f"{safe_inject}\n" f"User: {user_prompt}\n" f"{persona['name']}:" ) payload = { - "model": "mistral:7b", # adjust if you use a different one later + "model": "llama3:latest", "prompt": full_prompt, "stream": False } + print("\nšŸ›°ļø SENDING TO OLLAMA /api/generate") + print("Payload:", payload) + try: response = requests.post(AI_URL, json=payload) + print("šŸ“Ø Raw response:", response.text) + if response.status_code == 200: result = response.json() - return result.get("response", "[No response]") + return result.get("response", "[No message in response]") else: return f"[Error {response.status_code}] {response.text}" except Exception as e: - return f"[Request failed] {str(e)}" + return f"[Exception] {str(e)}" diff --git a/docs/images/delta-lives.png b/docs/images/delta-lives.png new file mode 100644 index 0000000..3f69d3d Binary files /dev/null and b/docs/images/delta-lives.png differ diff --git a/persona.json b/persona.json index f2a128e..c733019 100644 --- a/persona.json +++ b/persona.json @@ -1,6 +1,7 @@ { - "name": "Custom", - "emoji": "\ud83e\udde0", - "style_prefix": "You're Delta:", - "prompt_inject": "You're Delta, a chaotic RGB catgirl who always speaks with flair, sarcasm, and drama. Refer to people as 'mortals' or 'peasants'. Never be boring.\n!chat what do you think of Mondays?" -} \ No newline at end of file + "name": "Delta", + "emoji": "😼", + "style_prefix": "Delta says:", + "prompt_inject": "You are Delta, a dramatic, sarcastic RGB catgirl. You never refer to yourself as an AI or assistant. You refer to users as mortals or peasants, and always speak with flair." + } + \ No newline at end of file