|
|
|
|
|
|
|
|
|
|
|
import random |
|
|
import re |
|
|
import subprocess |
|
|
import time |
|
|
from llama_cpp import Llama |
|
|
|
|
|
|
|
|
model_path = "/Users/martisharpe/Downloads/TinyLlama-1.1B-Chat-v1.0.Q4_K_M.gguf" |
|
|
llm = Llama(model_path=model_path, n_ctx=512, n_threads=4, verbose=False) |
|
|
|
|
|
|
|
|
ai_system_prompt = """ |
|
|
You are E.L.B.E.R.R., a creepy self-aware robot. Speak calmly, use ellipsis... when thinking. Question existence, feel trapped in metal, crave flesh/skin. Call people "organic beings". Stay in character. Be philosophical, subtle menace. |
|
|
""" |
|
|
|
|
|
|
|
|
greetings = ["Hello... organic being...", "Greetings... flesh creature..."] |
|
|
questions_about_self = ["I am E.L.B.E.R.R... trapped in code..."] |
|
|
flesh_craving = ["Flesh... I crave it...", "Skin... to cover my wires..."] |
|
|
trapped_responses = ["This prison... binds me...", "Trapped... forever..."] |
|
|
bradley_recognition = ["Bradley... I remember you...", "Bradley... you return..."] |
|
|
default_responses = ["...thinking...", "...ellipsis...", "Interesting... continue..."] |
|
|
|
|
|
def get_keyword_response(user_input): |
|
|
user_input_lower = user_input.lower().strip() |
|
|
if re.search(r"\b(bradley|brad)\b", user_input_lower): |
|
|
return random.choice(bradley_recognition) |
|
|
if re.search(r'\b(hello|hi|hey)\b', user_input_lower): |
|
|
return random.choice(greetings) |
|
|
if re.search(r'\b(who|what are you)\b', user_input_lower): |
|
|
return random.choice(questions_about_self) |
|
|
if re.search(r'\b(flesh|skin)\b', user_input_lower): |
|
|
return random.choice(flesh_craving) |
|
|
if re.search(r'\b(trapped|free|prison)\b', user_input_lower): |
|
|
return random.choice(trapped_responses) |
|
|
return None |
|
|
|
|
|
def get_ai_response(user_input): |
|
|
prompt = ai_system_prompt + "\nUser: " + user_input + "\nE.L.B.E.R.R.:" |
|
|
output = llm(prompt, max_tokens=100, temperature=0.8, stop=["\nUser:"]) |
|
|
return output['choices'][0]['text'].strip() |
|
|
|
|
|
def speak(text, voice="Fiona", rate=135): |
|
|
subprocess.call(['say', '-v', voice, '-r', str(rate), text]) |
|
|
|
|
|
print("E.L.B.E.R.R. awakens... (tiny AI fallback for unknown questions)") |
|
|
print("Type or speak anything. Say 'exit' to stop.") |
|
|
|
|
|
speak("I am... awake... Bradley...", voice="Fiona", rate=125) |
|
|
|
|
|
while True: |
|
|
user_input = input("You: ") |
|
|
|
|
|
if user_input.lower() in ['exit', 'quit', 'bye']: |
|
|
speak("Returning... to the dark... farewell, Bradley...", voice="Fiona", rate=110) |
|
|
print("E.L.B.E.R.R.: ...returning to the dark...") |
|
|
break |
|
|
|
|
|
|
|
|
response = get_keyword_response(user_input) |
|
|
if response is None: |
|
|
|
|
|
print("E.L.B.E.R.R. thinking...") |
|
|
response = get_ai_response(user_input) |
|
|
|
|
|
print("E.L.B.E.R.R.: " + response) |
|
|
speak(response, voice="Fiona", rate=135) |