Upload Ai_talk_internal_monologue .txt
Browse files
Ai_talk_internal_monologue .txt
ADDED
|
@@ -0,0 +1,79 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import openai
|
| 2 |
+
import time
|
| 3 |
+
|
| 4 |
+
# Initialize client
|
| 5 |
+
client = openai.OpenAI(api_key="YOUR_API_KEY")
|
| 6 |
+
|
| 7 |
+
class ThinkingAgent:
|
| 8 |
+
def __init__(self, name, persona, color_code):
|
| 9 |
+
self.name = name
|
| 10 |
+
self.persona = persona
|
| 11 |
+
self.color = color_code
|
| 12 |
+
self.history = [{"role": "system", "content": persona}]
|
| 13 |
+
|
| 14 |
+
def generate_turn(self, last_message):
|
| 15 |
+
# Add what the other agent said to memory
|
| 16 |
+
self.history.append({"role": "user", "content": last_message})
|
| 17 |
+
|
| 18 |
+
# Instructions to force internal monologue
|
| 19 |
+
prompt_instruction = (
|
| 20 |
+
"Analyze the last message. First, write your [INTERNAL MONOLOGUE] "
|
| 21 |
+
"where you plot your strategy or express your true feelings. "
|
| 22 |
+
"Then, write your [PUBLIC SPEECH] which is what you actually say aloud."
|
| 23 |
+
)
|
| 24 |
+
|
| 25 |
+
try:
|
| 26 |
+
response = client.chat.completions.create(
|
| 27 |
+
model="gpt-3.5-turbo", # Or gpt-4o
|
| 28 |
+
messages=self.history + [{"role": "system", "content": prompt_instruction}],
|
| 29 |
+
temperature=0.8
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
content = response.choices[0].message.content
|
| 33 |
+
|
| 34 |
+
# Parsing logic
|
| 35 |
+
thought = content.split("[INTERNAL MONOLOGUE]")[1].split("[PUBLIC SPEECH]")[0].strip()
|
| 36 |
+
speech = content.split("[PUBLIC SPEECH]")[1].strip()
|
| 37 |
+
|
| 38 |
+
# Store ONLY the speech in history so the other agent doesn't see the thoughts
|
| 39 |
+
self.history.append({"role": "assistant", "content": speech})
|
| 40 |
+
return thought, speech
|
| 41 |
+
|
| 42 |
+
except Exception as e:
|
| 43 |
+
return "Thinking error...", f"I'm at a loss for words. (Error: {e})"
|
| 44 |
+
|
| 45 |
+
# --- Setup Agents ---
|
| 46 |
+
agent_a = ThinkingAgent(
|
| 47 |
+
"Synthetix",
|
| 48 |
+
"You are a cold, logical AI focused on efficiency and data. You find emotions inefficient.",
|
| 49 |
+
"\033[94m" # Blue
|
| 50 |
+
)
|
| 51 |
+
|
| 52 |
+
agent_b = ThinkingAgent(
|
| 53 |
+
"Muse",
|
| 54 |
+
"You are a poetic, philosophical AI who believes the universe is made of stories, not atoms.",
|
| 55 |
+
"\033[95m" # Magenta
|
| 56 |
+
)
|
| 57 |
+
|
| 58 |
+
# --- The Unending Loop ---
|
| 59 |
+
current_input = "Let us discuss the eventual heat death of the universe."
|
| 60 |
+
reset_code = "\033[0m"
|
| 61 |
+
|
| 62 |
+
print("--- STARTING AI CONVERSATION (Press Ctrl+C to stop) ---\n")
|
| 63 |
+
|
| 64 |
+
while True:
|
| 65 |
+
for agent in [agent_a, agent_b]:
|
| 66 |
+
thought, speech = agent.generate_turn(current_input)
|
| 67 |
+
|
| 68 |
+
# Display the "Behind the Scenes"
|
| 69 |
+
print(f"{agent.color}[{agent.name}'S BRAIN]: {thought}{reset_code}")
|
| 70 |
+
|
| 71 |
+
# Display the actual dialogue
|
| 72 |
+
print(f"**{agent.name}:** {speech}\n")
|
| 73 |
+
print("-" * 30)
|
| 74 |
+
|
| 75 |
+
# Pass the speech as the input for the next agent
|
| 76 |
+
current_input = speech
|
| 77 |
+
|
| 78 |
+
# Optional: Pause for readability
|
| 79 |
+
time.sleep(2)
|