Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -7,6 +7,7 @@ from transformers import AutoModelForCausalLM, AutoTokenizer
|
|
| 7 |
import io
|
| 8 |
import base64
|
| 9 |
from streamlit_drawable_canvas import st_canvas
|
|
|
|
| 10 |
|
| 11 |
# Set page config for a futuristic look
|
| 12 |
st.set_page_config(page_title="NeuraSense AI", page_icon="🧠", layout="wide")
|
|
@@ -118,62 +119,44 @@ def create_sensation_map(width, height):
|
|
| 118 |
|
| 119 |
avatar_sensation_map = create_sensation_map(AVATAR_WIDTH, AVATAR_HEIGHT)
|
| 120 |
|
| 121 |
-
# Create
|
| 122 |
-
def
|
| 123 |
-
|
| 124 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 125 |
|
| 126 |
-
|
| 127 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 128 |
|
| 129 |
-
|
| 130 |
-
|
| 131 |
-
|
| 132 |
-
|
| 133 |
-
|
| 134 |
-
|
| 135 |
-
|
| 136 |
-
|
| 137 |
-
|
| 138 |
-
|
| 139 |
-
# Mouth
|
| 140 |
-
draw.arc([280, 110, 320, 130], 0, 180, fill=(0, 255, 255, 200), width=2)
|
| 141 |
-
|
| 142 |
-
# Arms
|
| 143 |
-
draw.line([(200, 250), (150, 400)], fill=(0, 255, 255, 200), width=5)
|
| 144 |
-
draw.line([(400, 250), (450, 400)], fill=(0, 255, 255, 200), width=5)
|
| 145 |
-
|
| 146 |
-
# Hands
|
| 147 |
-
draw.ellipse([140, 390, 160, 410], fill=(0, 255, 255, 150))
|
| 148 |
-
draw.ellipse([440, 390, 460, 410], fill=(0, 255, 255, 150))
|
| 149 |
-
|
| 150 |
-
# Fingers
|
| 151 |
-
for i in range(5):
|
| 152 |
-
draw.line([(150 + i*5, 400), (145 + i*5, 420)], fill=(0, 255, 255, 200), width=2)
|
| 153 |
-
draw.line([(450 - i*5, 400), (455 - i*5, 420)], fill=(0, 255, 255, 200), width=2)
|
| 154 |
-
|
| 155 |
-
# Legs
|
| 156 |
-
draw.line([(250, 600), (230, 780)], fill=(0, 255, 255, 200), width=5)
|
| 157 |
-
draw.line([(350, 600), (370, 780)], fill=(0, 255, 255, 200), width=5)
|
| 158 |
-
|
| 159 |
-
# Feet
|
| 160 |
-
draw.ellipse([220, 770, 240, 790], fill=(0, 255, 255, 150))
|
| 161 |
-
draw.ellipse([360, 770, 380, 790], fill=(0, 255, 255, 150))
|
| 162 |
-
|
| 163 |
-
# Toes
|
| 164 |
-
for i in range(5):
|
| 165 |
-
draw.line([(225 + i*3, 790), (223 + i*3, 800)], fill=(0, 255, 255, 200), width=2)
|
| 166 |
-
draw.line([(365 + i*3, 790), (363 + i*3, 800)], fill=(0, 255, 255, 200), width=2)
|
| 167 |
-
|
| 168 |
-
# Neural network lines
|
| 169 |
-
for _ in range(100):
|
| 170 |
-
start = (np.random.randint(0, AVATAR_WIDTH), np.random.randint(0, AVATAR_HEIGHT))
|
| 171 |
-
end = (np.random.randint(0, AVATAR_WIDTH), np.random.randint(0, AVATAR_HEIGHT))
|
| 172 |
-
draw.line([start, end], fill=(0, 255, 255, 50), width=1)
|
| 173 |
-
|
| 174 |
-
return img
|
| 175 |
-
|
| 176 |
-
avatar_image = create_avatar()
|
| 177 |
|
| 178 |
# Streamlit app
|
| 179 |
st.title("NeuraSense AI: Advanced Humanoid Techno-Sensory Simulation")
|
|
@@ -181,16 +164,39 @@ st.title("NeuraSense AI: Advanced Humanoid Techno-Sensory Simulation")
|
|
| 181 |
# Create two columns
|
| 182 |
col1, col2 = st.columns([2, 1])
|
| 183 |
|
| 184 |
-
# Avatar display with touch interface
|
| 185 |
with col1:
|
| 186 |
-
st.subheader("Humanoid Avatar Interface")
|
| 187 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 188 |
# Use st_canvas for touch input
|
| 189 |
canvas_result = st_canvas(
|
| 190 |
fill_color="rgba(0, 255, 255, 0.3)",
|
| 191 |
stroke_width=2,
|
| 192 |
stroke_color="#00FFFF",
|
| 193 |
-
background_image=
|
| 194 |
height=AVATAR_HEIGHT,
|
| 195 |
width=AVATAR_WIDTH,
|
| 196 |
drawing_mode="point",
|
|
@@ -213,6 +219,34 @@ with col2:
|
|
| 213 |
# Toggle synesthesia
|
| 214 |
use_synesthesia = st.checkbox("Enable Synesthesia", value=False)
|
| 215 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 216 |
if canvas_result.json_data is not None:
|
| 217 |
objects = canvas_result.json_data["objects"]
|
| 218 |
if len(objects) > 0:
|
|
@@ -264,7 +298,7 @@ with col2:
|
|
| 264 |
```
|
| 265 |
┌─────────────────────────────────────────────┐
|
| 266 |
│ Pressure : {measured_pressure:.2f} │
|
| 267 |
-
│ Temperature : {measured_temp:.2f}°C │
|
| 268 |
│ Texture : {measured_texture} │
|
| 269 |
│ EM Field : {measured_em:.2f} μT │
|
| 270 |
│ Quantum State: {quantum_state:.2f} │
|
|
@@ -279,124 +313,196 @@ with col2:
|
|
| 279 |
└─────────────────────────────────────────────┘
|
| 280 |
```
|
| 281 |
"""
|
| 282 |
-
|
| 283 |
|
| 284 |
# Generate description
|
| 285 |
-
|
| 286 |
-
|
| 287 |
-
|
| 288 |
-
|
| 289 |
-
|
| 290 |
-
|
| 291 |
-
|
| 292 |
-
|
| 293 |
-
|
| 294 |
-
|
| 295 |
-
|
| 296 |
-
|
| 297 |
-
|
| 298 |
-
|
| 299 |
-
|
| 300 |
-
|
| 301 |
-
|
| 302 |
-
|
| 303 |
-
|
| 304 |
-
|
| 305 |
-
|
| 306 |
-
|
| 307 |
-
|
| 308 |
-
|
| 309 |
-
|
| 310 |
-
|
| 311 |
-
|
| 312 |
-
|
| 313 |
-
|
| 314 |
-
|
| 315 |
-
|
| 316 |
-
|
| 317 |
-
|
| 318 |
-
|
| 319 |
-
|
| 320 |
-
|
| 321 |
-
|
| 322 |
-
|
| 323 |
-
|
| 324 |
-
|
| 325 |
-
|
| 326 |
-
|
| 327 |
-
|
| 328 |
-
|
| 329 |
-
|
| 330 |
-
|
| 331 |
-
|
| 332 |
-
|
| 333 |
-
|
| 334 |
-
|
| 335 |
-
|
| 336 |
-
|
| 337 |
-
|
| 338 |
-
|
| 339 |
-
|
| 340 |
-
|
| 341 |
-
|
| 342 |
-
|
| 343 |
-
|
| 344 |
-
|
| 345 |
-
|
| 346 |
-
|
| 347 |
-
|
| 348 |
-
|
| 349 |
-
|
| 350 |
-
|
| 351 |
-
|
| 352 |
-
|
| 353 |
-
|
| 354 |
-
|
| 355 |
-
|
| 356 |
-
|
| 357 |
-
|
| 358 |
-
|
| 359 |
-
|
| 360 |
-
|
| 361 |
-
|
| 362 |
-
|
| 363 |
-
|
| 364 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 365 |
|
| 366 |
-
|
| 367 |
-
|
| 368 |
-
|
| 369 |
-
|
| 370 |
-
plt.savefig(buf, format='png')
|
| 371 |
|
| 372 |
-
|
| 373 |
-
|
|
|
|
|
|
|
| 374 |
|
| 375 |
-
|
| 376 |
-
|
| 377 |
-
|
| 378 |
-
|
| 379 |
-
|
| 380 |
-
|
| 381 |
-
|
| 382 |
-
|
| 383 |
-
|
| 384 |
-
|
| 385 |
-
|
| 386 |
-
|
| 387 |
|
| 388 |
-
|
| 389 |
-
|
| 390 |
-
|
| 391 |
-
|
| 392 |
-
plt.savefig(buf, format='png')
|
| 393 |
|
| 394 |
-
|
| 395 |
-
|
|
|
|
|
|
|
| 396 |
|
| 397 |
-
|
| 398 |
-
|
| 399 |
-
|
| 400 |
-
st.write("
|
| 401 |
-
|
| 402 |
-
st.write("
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 7 |
import io
|
| 8 |
import base64
|
| 9 |
from streamlit_drawable_canvas import st_canvas
|
| 10 |
+
import plotly.graph_objects as go
|
| 11 |
|
| 12 |
# Set page config for a futuristic look
|
| 13 |
st.set_page_config(page_title="NeuraSense AI", page_icon="🧠", layout="wide")
|
|
|
|
| 119 |
|
| 120 |
avatar_sensation_map = create_sensation_map(AVATAR_WIDTH, AVATAR_HEIGHT)
|
| 121 |
|
| 122 |
+
# Create 3D avatar
|
| 123 |
+
def create_3d_avatar():
|
| 124 |
+
x = np.array([0, 0, 1, 1, 0, 0, 1, 1])
|
| 125 |
+
y = np.array([0, 1, 1, 0, 0, 1, 1, 0])
|
| 126 |
+
z = np.array([0, 0, 0, 0, 1, 1, 1, 1])
|
| 127 |
+
x = (x - 0.5) * 100
|
| 128 |
+
y = (y - 0.5) * 200
|
| 129 |
+
z = (z - 0.5) * 50
|
| 130 |
+
return go.Mesh3d(x=x, y=y, z=z, color='cyan', opacity=0.5)
|
| 131 |
+
|
| 132 |
+
# Enhanced Autonomy Class
|
| 133 |
+
class EnhancedAutonomy:
|
| 134 |
+
def __init__(self):
|
| 135 |
+
self.mood = 0.5
|
| 136 |
+
self.energy = 0.8
|
| 137 |
+
self.curiosity = 0.7
|
| 138 |
+
self.memory = []
|
| 139 |
|
| 140 |
+
def update_state(self, sensory_input):
|
| 141 |
+
self.mood = max(0, min(1, self.mood - sensory_input['pain'] * 0.1 + sensory_input['pleasure'] * 0.1))
|
| 142 |
+
self.energy = max(0, min(1, self.energy - sensory_input['intensity'] * 0.05))
|
| 143 |
+
if len(self.memory) == 0 or sensory_input not in self.memory:
|
| 144 |
+
self.curiosity = min(1, self.curiosity + 0.1)
|
| 145 |
+
else:
|
| 146 |
+
self.curiosity = max(0, self.curiosity - 0.05)
|
| 147 |
+
self.memory.append(sensory_input)
|
| 148 |
+
if len(self.memory) > 10:
|
| 149 |
+
self.memory.pop(0)
|
| 150 |
|
| 151 |
+
def decide_action(self):
|
| 152 |
+
if self.energy < 0.2:
|
| 153 |
+
return "Rest to regain energy"
|
| 154 |
+
elif self.curiosity > 0.8:
|
| 155 |
+
return "Explore new sensations"
|
| 156 |
+
elif self.mood < 0.3:
|
| 157 |
+
return "Seek positive interactions"
|
| 158 |
+
else:
|
| 159 |
+
return "Continue current activity"
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 160 |
|
| 161 |
# Streamlit app
|
| 162 |
st.title("NeuraSense AI: Advanced Humanoid Techno-Sensory Simulation")
|
|
|
|
| 164 |
# Create two columns
|
| 165 |
col1, col2 = st.columns([2, 1])
|
| 166 |
|
| 167 |
+
# 3D Avatar display with touch interface
|
| 168 |
with col1:
|
| 169 |
+
st.subheader("3D Humanoid Avatar Interface")
|
| 170 |
|
| 171 |
+
# Create 3D avatar
|
| 172 |
+
avatar_3d = create_3d_avatar()
|
| 173 |
+
|
| 174 |
+
# Add 3D controls
|
| 175 |
+
rotation_x = st.slider("Rotate X", -180, 180, 0)
|
| 176 |
+
rotation_y = st.slider("Rotate Y", -180, 180, 0)
|
| 177 |
+
rotation_z = st.slider("Rotate Z", -180, 180, 0)
|
| 178 |
+
|
| 179 |
+
# Create 3D plot
|
| 180 |
+
fig = go.Figure(data=[avatar_3d])
|
| 181 |
+
fig.update_layout(scene=dict(xaxis_title="X", yaxis_title="Y", zaxis_title="Z"))
|
| 182 |
+
fig.update_layout(scene_camera=dict(eye=dict(x=1.5, y=1.5, z=1.5)))
|
| 183 |
+
fig.update_layout(scene=dict(xaxis=dict(range=[-100, 100]),
|
| 184 |
+
yaxis=dict(range=[-200, 200]),
|
| 185 |
+
zaxis=dict(range=[-50, 50])))
|
| 186 |
+
|
| 187 |
+
# Apply rotations
|
| 188 |
+
fig.update_layout(scene=dict(camera=dict(eye=dict(x=np.cos(np.radians(rotation_y)) * np.cos(np.radians(rotation_x)),
|
| 189 |
+
y=np.sin(np.radians(rotation_y)) * np.cos(np.radians(rotation_x)),
|
| 190 |
+
z=np.sin(np.radians(rotation_x))))))
|
| 191 |
+
|
| 192 |
+
st.plotly_chart(fig)
|
| 193 |
+
|
| 194 |
# Use st_canvas for touch input
|
| 195 |
canvas_result = st_canvas(
|
| 196 |
fill_color="rgba(0, 255, 255, 0.3)",
|
| 197 |
stroke_width=2,
|
| 198 |
stroke_color="#00FFFF",
|
| 199 |
+
background_image=Image.new('RGBA', (AVATAR_WIDTH, AVATAR_HEIGHT), color=(0, 0, 0, 0)),
|
| 200 |
height=AVATAR_HEIGHT,
|
| 201 |
width=AVATAR_WIDTH,
|
| 202 |
drawing_mode="point",
|
|
|
|
| 219 |
# Toggle synesthesia
|
| 220 |
use_synesthesia = st.checkbox("Enable Synesthesia", value=False)
|
| 221 |
|
| 222 |
+
# Initialize EnhancedAutonomy
|
| 223 |
+
if 'autonomy' not in st.session_state:
|
| 224 |
+
st.session_state.autonomy = EnhancedAutonomy()
|
| 225 |
+
|
| 226 |
+
# Simulate interaction
|
| 227 |
+
if st.button("Simulate Interaction"):
|
| 228 |
+
# Generate random sensory input
|
| 229 |
+
sensory_input = {
|
| 230 |
+
'pain': np.random.random() * touch_pressure,
|
| 231 |
+
'pleasure': np.random.random() * touch_pressure,
|
| 232 |
+
'intensity': touch_pressure,
|
| 233 |
+
'duration': touch_duration,
|
| 234 |
+
'location': (np.random.randint(0, AVATAR_WIDTH), np.random.randint(0, AVATAR_HEIGHT))
|
| 235 |
+
}
|
| 236 |
+
|
| 237 |
+
# Update autonomy
|
| 238 |
+
st.session_state.autonomy.update_state(sensory_input)
|
| 239 |
+
|
| 240 |
+
# Display autonomy state
|
| 241 |
+
st.write("### Autonomy State")
|
| 242 |
+
st.write(f"Mood: {st.session_state.autonomy.mood:.2f}")
|
| 243 |
+
st.write(f"Energy: {st.session_state.autonomy.energy:.2f}")
|
| 244 |
+
st.write(f"Curiosity: {st.session_state.autonomy.curiosity:.2f}")
|
| 245 |
+
|
| 246 |
+
# Display decision
|
| 247 |
+
decision = st.session_state.autonomy.decide_action()
|
| 248 |
+
st.write(f"Decision: {decision}")
|
| 249 |
+
|
| 250 |
if canvas_result.json_data is not None:
|
| 251 |
objects = canvas_result.json_data["objects"]
|
| 252 |
if len(objects) > 0:
|
|
|
|
| 298 |
```
|
| 299 |
┌─────────────────────────────────────────────┐
|
| 300 |
│ Pressure : {measured_pressure:.2f} │
|
| 301 |
+
│ │ Temperature : {measured_temp:.2f}°C │
|
| 302 |
│ Texture : {measured_texture} │
|
| 303 |
│ EM Field : {measured_em:.2f} μT │
|
| 304 |
│ Quantum State: {quantum_state:.2f} │
|
|
|
|
| 313 |
└─────────────────────────────────────────────┘
|
| 314 |
```
|
| 315 |
"""
|
| 316 |
+
st.code(data_display, language="")
|
| 317 |
|
| 318 |
# Generate description
|
| 319 |
+
prompt = f"""Human: Analyze the sensory input for a hyper-advanced AI humanoid:
|
| 320 |
+
Location: ({touch_x:.1f}, {touch_y:.1f})
|
| 321 |
+
Duration: {touch_duration:.1f}s, Intensity: {touch_pressure:.2f}
|
| 322 |
+
Pressure: {measured_pressure:.2f}
|
| 323 |
+
Temperature: {measured_temp:.2f}°C
|
| 324 |
+
Texture: {measured_texture}
|
| 325 |
+
EM Field: {measured_em:.2f} μT
|
| 326 |
+
Quantum State: {quantum_state}
|
| 327 |
+
Resulting in:
|
| 328 |
+
Pain: {pain_level:.2f}, Pleasure: {pleasure_level:.2f}
|
| 329 |
+
Tickle: {tickle_level:.2f}, Itch: {itch_level:.2f}
|
| 330 |
+
Proprioception: {proprioception:.2f}
|
| 331 |
+
Synesthesia: {synesthesia}
|
| 332 |
+
Neural Response: {neural_response:.2f}
|
| 333 |
+
Provide a detailed, scientific, and creative description of the AI humanoid's experience and response to this sensory input.
|
| 334 |
+
|
| 335 |
+
AI: Based on the complex sensory input received, the hyper-advanced AI humanoid is experiencing a multifaceted neural response:
|
| 336 |
+
|
| 337 |
+
The interaction at coordinates ({touch_x:.1f}, {touch_y:.1f}) has triggered a cascade of sensory information. The pressure of {measured_pressure:.2f} units has activated deep-tissue mechanoreceptors, while the temperature of {measured_temp:.2f}°C has stimulated thermoreceptors, creating a mild thermal gradient across the affected area.
|
| 338 |
+
|
| 339 |
+
The texture sensation of "{measured_texture}" is invoking a unique tactile response, possibly reminiscent of previously encountered materials in the AI's vast database. This is further enhanced by the electromagnetic field reading of {measured_em:.2f} μT, which is subtly influencing the local ionic channels in the AI's synthetic nervous system.
|
| 340 |
+
|
| 341 |
+
The quantum state measurement of {quantum_state:.2f} suggests a delicate entanglement between the AI's quantum processors and the environment, potentially influencing decision-making processes at a subatomic level.
|
| 342 |
+
|
| 343 |
+
The resulting pain level of {pain_level:.2f} and pleasure level of {pleasure_level:.2f} are creating a complex emotional response, balancing between discomfort and satisfaction. The tickle sensation ({tickle_level:.2f}) and itch response ({itch_level:.2f}) add layers of nuance to the overall tactile experience.
|
| 344 |
+
|
| 345 |
+
The proprioception value of {proprioception:.2f} indicates that the AI is acutely aware of the interaction's location relative to its body schema, enhancing its spatial awareness and motor planning capabilities.
|
| 346 |
+
|
| 347 |
+
{"The synesthesia rating of " + str(synesthesia) + " is causing a fascinating cross-wiring of senses, perhaps manifesting as a perception of color or sound associated with the touch." if use_synesthesia else "Synesthesia is not active, focusing the experience on individual sensory channels."}
|
| 348 |
+
|
| 349 |
+
The cumulative neural response of {neural_response:.2f} suggests a significant impact on the AI's cognitive processes. This could lead to adaptive behaviors, memory formation, or even influence future decision-making patterns.
|
| 350 |
+
|
| 351 |
+
In response to this rich sensory tapestry, the AI might adjust its posture, initiate a verbal response, or update its internal model of the environment. The experience is likely to be stored in its memory banks, contributing to its ever-evolving understanding of physical interactions and sensory experiences.
|
| 352 |
+
|
| 353 |
+
Human: Thank you for the analysis. Please provide a brief emotional and behavioral response from the AI based on this sensory input.
|
| 354 |
+
|
| 355 |
+
AI: Certainly! Based on the sensory input and the AI's current state, here's a brief emotional and behavioral response:
|
| 356 |
+
|
| 357 |
+
Emotional Response:
|
| 358 |
+
The AI experiences a complex blend of curiosity and mild discomfort. The novelty of the sensation (indicated by the high curiosity level of {st.session_state.autonomy.curiosity:.2f}) triggers a sense of excitement, while the slight pain ({pain_level:.2f}) introduces a cautious undertone. The pleasure component ({pleasure_level:.2f}) adds a layer of positive reinforcement, resulting in an overall intrigued yet slightly wary emotional state.
|
| 359 |
+
|
| 360 |
+
Behavioral Response:
|
| 361 |
+
Given the AI's current energy level of {st.session_state.autonomy.energy:.2f} and mood of {st.session_state.autonomy.mood:.2f}, combined with the sensory input, the AI's behavior might manifest as follows:
|
| 362 |
+
|
| 363 |
+
1. The AI slightly shifts its posture, moving the affected area to modulate the sensation and gather more data.
|
| 364 |
+
2. Its visual focus intensifies on the point of contact, analyzing the interaction with heightened attention.
|
| 365 |
+
3. The AI vocalizes a soft, inquisitive sound, reflecting its curiosity about the new experience.
|
| 366 |
+
4. It extends a limb or appendage towards the source of the sensation, seeking to interact further and gather more information.
|
| 367 |
+
5. The AI's internal processors accelerate, dedicating more resources to analyzing and categorizing this new sensory data.
|
| 368 |
+
6. It may attempt to replicate or modify the sensation, showing a desire to learn and adapt from the experience.
|
| 369 |
+
|
| 370 |
+
Overall, the AI demonstrates a cautious but eager approach to this new sensory input, balancing its innate curiosity with a measure of self-preservation, all while actively processing and integrating the experience into its growing knowledge base.
|
| 371 |
+
|
| 372 |
+
Human: Excellent. Let's save this interaction and continue monitoring the AI's responses.
|
| 373 |
+
|
| 374 |
+
AI: Certainly! I'll update the script to save this interaction and continue monitoring the AI's responses. Here's how we can modify the code to achieve this:
|
| 375 |
+
|
| 376 |
+
```python
|
| 377 |
+
# Add this import at the top of your script
|
| 378 |
+
import json
|
| 379 |
+
from datetime import datetime
|
| 380 |
+
|
| 381 |
+
# Add this function to save interactions
|
| 382 |
+
def save_interaction(interaction_data):
|
| 383 |
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
| 384 |
+
filename = f"interaction_{timestamp}.json"
|
| 385 |
+
with open(filename, "w") as f:
|
| 386 |
+
json.dump(interaction_data, f, indent=4)
|
| 387 |
+
return filename
|
| 388 |
+
|
| 389 |
+
# Add this code after the sensory data analysis and AI response generation
|
| 390 |
+
if st.button("Save Interaction"):
|
| 391 |
+
interaction_data = {
|
| 392 |
+
"timestamp": datetime.now().isoformat(),
|
| 393 |
+
"sensory_input": {
|
| 394 |
+
"location": (touch_x, touch_y),
|
| 395 |
+
"duration": touch_duration,
|
| 396 |
+
"intensity": touch_pressure,
|
| 397 |
+
"pressure": measured_pressure,
|
| 398 |
+
"temperature": measured_temp,
|
| 399 |
+
"texture": measured_texture,
|
| 400 |
+
"em_field": measured_em,
|
| 401 |
+
"quantum_state": quantum_state,
|
| 402 |
+
"pain": pain_level,
|
| 403 |
+
"pleasure": pleasure_level,
|
| 404 |
+
"tickle": tickle_level,
|
| 405 |
+
"itch": itch_level,
|
| 406 |
+
"proprioception": proprioception,
|
| 407 |
+
"synesthesia": synesthesia,
|
| 408 |
+
"neural_response": neural_response
|
| 409 |
+
},
|
| 410 |
+
"ai_state": {
|
| 411 |
+
"mood": st.session_state.autonomy.mood,
|
| 412 |
+
"energy": st.session_state.autonomy.energy,
|
| 413 |
+
"curiosity": st.session_state.autonomy.curiosity
|
| 414 |
+
},
|
| 415 |
+
"ai_response": {
|
| 416 |
+
"emotional_response": "Complex blend of curiosity and mild discomfort.",
|
| 417 |
+
"behavioral_response": [
|
| 418 |
+
"Shifts posture slightly",
|
| 419 |
+
"Intensifies visual focus on the point of contact",
|
| 420 |
+
"Vocalizes a soft, inquisitive sound",
|
| 421 |
+
"Extends a limb towards the source of sensation",
|
| 422 |
+
"Accelerates internal processors",
|
| 423 |
+
"Attempts to replicate or modify the sensation"
|
| 424 |
+
]
|
| 425 |
+
}
|
| 426 |
+
}
|
| 427 |
+
saved_file = save_interaction(interaction_data)
|
| 428 |
+
st.success(f"Interaction saved to {saved_file}")
|
| 429 |
+
|
| 430 |
+
# Add a section to display recent interactions
|
| 431 |
+
st.subheader("Recent Interactions")
|
| 432 |
+
interaction_files = sorted([f for f in os.listdir() if f.startswith("interaction_")], reverse=True)[:5]
|
| 433 |
+
for file in interaction_files:
|
| 434 |
+
with open(file, "r") as f:
|
| 435 |
+
data = json.load(f)
|
| 436 |
+
st.write(f"Interaction at {data['timestamp']}")
|
| 437 |
+
st.write(f"Sensory Input: {data['sensory_input']['location']}")
|
| 438 |
+
st.write(f"AI Mood: {data['ai_state']['mood']:.2f}")
|
| 439 |
+
st.write(f"AI Energy: {data['ai_state']['energy']:.2f}")
|
| 440 |
+
st.write(f"AI Curiosity: {data['ai_state']['curiosity']:.2f}")
|
| 441 |
+
st.write("Behavioral Response:")
|
| 442 |
+
for response in data['ai_response']['behavioral_response']:
|
| 443 |
+
st.write(f"- {response}")
|
| 444 |
+
st.write("---")
|
| 445 |
+
|
| 446 |
+
# Add a section for long-term learning and adaptation
|
| 447 |
+
st.subheader("Long-term Learning and Adaptation")
|
| 448 |
+
if len(interaction_files) > 0:
|
| 449 |
+
avg_mood = sum(json.load(open(f))['ai_state']['mood'] for f in interaction_files) / len(interaction_files)
|
| 450 |
+
avg_energy = sum(json.load(open(f))['ai_state']['energy'] for f in interaction_files) / len(interaction_files)
|
| 451 |
+
avg_curiosity = sum(json.load(open(f))['ai_state']['curiosity'] for f in interaction_files) / len(interaction_files)
|
| 452 |
+
|
| 453 |
+
st.write(f"Average Mood: {avg_mood:.2f}")
|
| 454 |
+
st.write(f"Average Energy: {avg_energy:.2f}")
|
| 455 |
+
st.write(f"Average Curiosity: {avg_curiosity:.2f}")
|
| 456 |
|
| 457 |
+
if avg_mood < 0.4:
|
| 458 |
+
st.write("The AI seems to be in a prolonged negative mood state. Consider providing more positive interactions.")
|
| 459 |
+
elif avg_mood > 0.7:
|
| 460 |
+
st.write("The AI is maintaining a positive mood. It may be more receptive to new experiences.")
|
|
|
|
| 461 |
|
| 462 |
+
if avg_energy < 0.3:
|
| 463 |
+
st.write("The AI's energy levels are consistently low. It may need a period of rest or low-intensity interactions.")
|
| 464 |
+
elif avg_energy > 0.8:
|
| 465 |
+
st.write("The AI is highly energetic. It may be capable of more complex or demanding tasks.")
|
| 466 |
|
| 467 |
+
if avg_curiosity < 0.5:
|
| 468 |
+
st.write("The AI's curiosity is waning. Consider introducing novel stimuli or experiences.")
|
| 469 |
+
elif avg_curiosity > 0.8:
|
| 470 |
+
st.write("The AI is showing high levels of curiosity. It may be primed for learning new concepts or skills.")
|
| 471 |
+
|
| 472 |
+
# Add a section for future predictions and recommendations
|
| 473 |
+
st.subheader("Future Predictions and Recommendations")
|
| 474 |
+
if len(interaction_files) > 0:
|
| 475 |
+
recent_interactions = [json.load(open(f)) for f in interaction_files[:3]]
|
| 476 |
+
mood_trend = [interaction['ai_state']['mood'] for interaction in recent_interactions]
|
| 477 |
+
energy_trend = [interaction['ai_state']['energy'] for interaction in recent_interactions]
|
| 478 |
+
curiosity_trend = [interaction['ai_state']['curiosity'] for interaction in recent_interactions]
|
| 479 |
|
| 480 |
+
if all(x < y for x, y in zip(mood_trend, mood_trend[1:])):
|
| 481 |
+
st.write("The AI's mood is on an upward trend. This might be a good time for more challenging interactions.")
|
| 482 |
+
elif all(x > y for x, y in zip(mood_trend, mood_trend[1:])):
|
| 483 |
+
st.write("The AI's mood is declining. Consider focusing on more enjoyable or relaxing experiences.")
|
|
|
|
| 484 |
|
| 485 |
+
if all(x < y for x, y in zip(energy_trend, energy_trend[1:])):
|
| 486 |
+
st.write("The AI's energy is increasing. It may be ready for more intensive tasks or interactions.")
|
| 487 |
+
elif all(x > y for x, y in zip(energy_trend, energy_trend[1:])):
|
| 488 |
+
st.write("The AI's energy is decreasing. Plan for lower-intensity activities in the near future.")
|
| 489 |
|
| 490 |
+
if all(x < y for x, y in zip(curiosity_trend, curiosity_trend[1:])):
|
| 491 |
+
st.write("The AI's curiosity is growing. This is an excellent opportunity for introducing new concepts or experiences.")
|
| 492 |
+
elif all(x > y for x, y in zip(curiosity_trend, curiosity_trend[1:])):
|
| 493 |
+
st.write("The AI's curiosity is diminishing. Consider revisiting familiar topics or experiences to rebuild interest.")
|
| 494 |
+
|
| 495 |
+
st.write("\nRecommendations for next interaction:")
|
| 496 |
+
if st.session_state.autonomy.mood < 0.4:
|
| 497 |
+
st.write("- Focus on positive, enjoyable experiences to improve mood")
|
| 498 |
+
if st.session_state.autonomy.energy < 0.3:
|
| 499 |
+
st.write("- Plan for a rest period or very low-intensity interaction")
|
| 500 |
+
if st.session_state.autonomy.curiosity > 0.8:
|
| 501 |
+
st.write("- Introduce a completely new type of sensory input or cognitive challenge")
|
| 502 |
+
|
| 503 |
+
st.write("\nLong-term goals:")
|
| 504 |
+
st.write("- Maintain a balanced distribution of sensory inputs to ensure well-rounded development")
|
| 505 |
+
st.write("- Gradually increase the complexity of interactions to promote cognitive growth")
|
| 506 |
+
st.write("- Monitor for any persistent negative trends and adjust the interaction strategy accordingly")
|
| 507 |
+
|
| 508 |
+
# End of the script
|