Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -8,6 +8,9 @@ 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")
|
@@ -158,6 +161,14 @@ class EnhancedAutonomy:
|
|
158 |
else:
|
159 |
return "Continue current activity"
|
160 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
161 |
# Streamlit app
|
162 |
st.title("NeuraSense AI: Advanced Humanoid Techno-Sensory Simulation")
|
163 |
|
@@ -223,30 +234,6 @@ with col2:
|
|
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:
|
@@ -294,27 +281,30 @@ with col2:
|
|
294 |
st.write(f"Duration: {touch_duration:.1f} s | Intensity: {touch_pressure:.2f}")
|
295 |
|
296 |
# Create a futuristic data display
|
297 |
-
|
298 |
```
|
299 |
βββββββββββββββββββββββββββββββββββββββββββββββ
|
300 |
-
β Pressure : {measured_pressure:.2f} β
|
301 |
-
β
|
302 |
β Texture : {measured_texture} β
|
303 |
-
β EM Field : {measured_em:.2f} ΞΌT β
|
304 |
β Quantum State: {quantum_state:.2f} β
|
305 |
βββββββββββββββββββββββββββββββββββββββββββββββ€
|
306 |
-
β Pain Level : {pain_level:.2f} β
|
307 |
-
β Pleasure : {pleasure_level:.2f} β
|
308 |
-
β Tickle : {tickle_level:.2f} β
|
309 |
-
β Itch : {itch_level:.2f} β
|
310 |
-
β Proprioception: {proprioception:.2f} β
|
311 |
β Synesthesia : {synesthesia} β
|
312 |
-
β Neural Response: {neural_response:.2f} β
|
313 |
βββββββββββββββββββββββββββββββββββββββββββββββ
|
314 |
```
|
315 |
"""
|
316 |
st.code(data_display, language="")
|
317 |
|
|
|
|
|
|
|
318 |
prompt = f"""Human: Analyze the sensory input for a hyper-advanced AI humanoid:
|
319 |
Location: ({{touch_x:.1f}}, {{touch_y:.1f}})
|
320 |
Duration: {{touch_duration:.1f}}s, Intensity: {{touch_pressure:.2f}}
|
@@ -331,177 +321,78 @@ with col2:
|
|
331 |
Neural Response: {{neural_response:.2f}}
|
332 |
Provide a detailed, scientific, and creative description of the AI humanoid's experience and response to this sensory input."""
|
333 |
|
334 |
-
|
|
|
|
|
335 |
|
336 |
-
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.
|
337 |
|
338 |
-
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.
|
339 |
|
340 |
-
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.
|
341 |
|
342 |
-
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.
|
343 |
|
344 |
-
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.
|
345 |
|
346 |
{"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."}
|
347 |
|
348 |
-
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.
|
349 |
|
350 |
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.
|
|
|
351 |
|
352 |
-
|
353 |
-
|
354 |
-
|
355 |
-
|
356 |
-
|
357 |
-
|
358 |
-
|
359 |
-
|
360 |
-
|
361 |
-
|
362 |
-
|
363 |
-
|
364 |
-
|
365 |
-
|
366 |
-
|
367 |
-
|
368 |
-
|
369 |
-
|
370 |
-
|
371 |
-
|
372 |
-
|
373 |
-
|
374 |
-
|
375 |
-
|
376 |
-
|
377 |
-
|
378 |
-
|
379 |
-
|
380 |
-
|
381 |
-
|
382 |
-
|
383 |
-
|
384 |
-
|
385 |
-
|
386 |
-
|
387 |
-
|
388 |
-
|
389 |
-
|
390 |
-
|
391 |
-
|
392 |
-
"sensory_input": {
|
393 |
-
"location": (touch_x, touch_y),
|
394 |
-
"duration": touch_duration,
|
395 |
-
"intensity": touch_pressure,
|
396 |
-
"pressure": measured_pressure,
|
397 |
-
"temperature": measured_temp,
|
398 |
-
"texture": measured_texture,
|
399 |
-
"em_field": measured_em,
|
400 |
-
"quantum_state": quantum_state,
|
401 |
-
"pain": pain_level,
|
402 |
-
"pleasure": pleasure_level,
|
403 |
-
"tickle": tickle_level,
|
404 |
-
"itch": itch_level,
|
405 |
-
"proprioception": proprioception,
|
406 |
-
"synesthesia": synesthesia,
|
407 |
-
"neural_response": neural_response
|
408 |
-
},
|
409 |
-
"ai_state": {
|
410 |
-
"mood": st.session_state.autonomy.mood,
|
411 |
-
"energy": st.session_state.autonomy.energy,
|
412 |
-
"curiosity": st.session_state.autonomy.curiosity
|
413 |
-
},
|
414 |
-
"ai_response": {
|
415 |
-
"emotional_response": "Complex blend of curiosity and mild discomfort.",
|
416 |
-
"behavioral_response": [
|
417 |
-
"Shifts posture slightly",
|
418 |
-
"Intensifies visual focus on the point of contact",
|
419 |
-
"Vocalizes a soft, inquisitive sound",
|
420 |
-
"Extends a limb towards the source of sensation",
|
421 |
-
"Accelerates internal processors",
|
422 |
-
"Attempts to replicate or modify the sensation"
|
423 |
-
]
|
424 |
-
}
|
425 |
-
}
|
426 |
-
saved_file = save_interaction(interaction_data)
|
427 |
-
st.success(f"Interaction saved to {saved_file}")
|
428 |
-
|
429 |
-
# Add a section to display recent interactions
|
430 |
st.subheader("Recent Interactions")
|
431 |
interaction_files = sorted([f for f in os.listdir() if f.startswith("interaction_")], reverse=True)[:5]
|
432 |
for file in interaction_files:
|
433 |
with open(file, "r") as f:
|
434 |
data = json.load(f)
|
435 |
st.write(f"Interaction at {data['timestamp']}")
|
436 |
-
st.write(f"
|
437 |
st.write(f"AI Mood: {data['ai_state']['mood']:.2f}")
|
438 |
st.write(f"AI Energy: {data['ai_state']['energy']:.2f}")
|
439 |
st.write(f"AI Curiosity: {data['ai_state']['curiosity']:.2f}")
|
440 |
-
st.write("
|
441 |
-
for response in data['ai_response']['behavioral_response']:
|
442 |
-
st.write(f"- {response}")
|
443 |
st.write("---")
|
444 |
|
445 |
-
# Add a section for long-term learning and adaptation
|
446 |
-
st.subheader("Long-term Learning and Adaptation")
|
447 |
-
if len(interaction_files) > 0:
|
448 |
-
avg_mood = sum(json.load(open(f))['ai_state']['mood'] for f in interaction_files) / len(interaction_files)
|
449 |
-
avg_energy = sum(json.load(open(f))['ai_state']['energy'] for f in interaction_files) / len(interaction_files)
|
450 |
-
avg_curiosity = sum(json.load(open(f))['ai_state']['curiosity'] for f in interaction_files) / len(interaction_files)
|
451 |
-
|
452 |
-
st.write(f"Average Mood: {avg_mood:.2f}")
|
453 |
-
st.write(f"Average Energy: {avg_energy:.2f}")
|
454 |
-
st.write(f"Average Curiosity: {avg_curiosity:.2f}")
|
455 |
-
|
456 |
-
if avg_mood < 0.4:
|
457 |
-
st.write("The AI seems to be in a prolonged negative mood state. Consider providing more positive interactions.")
|
458 |
-
elif avg_mood > 0.7:
|
459 |
-
st.write("The AI is maintaining a positive mood. It may be more receptive to new experiences.")
|
460 |
-
|
461 |
-
if avg_energy < 0.3:
|
462 |
-
st.write("The AI's energy levels are consistently low. It may need a period of rest or low-intensity interactions.")
|
463 |
-
elif avg_energy > 0.8:
|
464 |
-
st.write("The AI is highly energetic. It may be capable of more complex or demanding tasks.")
|
465 |
-
|
466 |
-
if avg_curiosity < 0.5:
|
467 |
-
st.write("The AI's curiosity is waning. Consider introducing novel stimuli or experiences.")
|
468 |
-
elif avg_curiosity > 0.8:
|
469 |
-
st.write("The AI is showing high levels of curiosity. It may be primed for learning new concepts or skills.")
|
470 |
-
|
471 |
-
# Add a section for future predictions and recommendations
|
472 |
-
st.subheader("Future Predictions and Recommendations")
|
473 |
-
if len(interaction_files) > 0:
|
474 |
-
recent_interactions = [json.load(open(f)) for f in interaction_files[:3]]
|
475 |
-
mood_trend = [interaction['ai_state']['mood'] for interaction in recent_interactions]
|
476 |
-
energy_trend = [interaction['ai_state']['energy'] for interaction in recent_interactions]
|
477 |
-
curiosity_trend = [interaction['ai_state']['curiosity'] for interaction in recent_interactions]
|
478 |
-
|
479 |
-
if all(x < y for x, y in zip(mood_trend, mood_trend[1:])):
|
480 |
-
st.write("The AI's mood is on an upward trend. This might be a good time for more challenging interactions.")
|
481 |
-
elif all(x > y for x, y in zip(mood_trend, mood_trend[1:])):
|
482 |
-
st.write("The AI's mood is declining. Consider focusing on more enjoyable or relaxing experiences.")
|
483 |
-
|
484 |
-
if all(x < y for x, y in zip(energy_trend, energy_trend[1:])):
|
485 |
-
st.write("The AI's energy is increasing. It may be ready for more intensive tasks or interactions.")
|
486 |
-
elif all(x > y for x, y in zip(energy_trend, energy_trend[1:])):
|
487 |
-
st.write("The AI's energy is decreasing. Plan for lower-intensity activities in the near future.")
|
488 |
-
|
489 |
-
if all(x < y for x, y in zip(curiosity_trend, curiosity_trend[1:])):
|
490 |
-
st.write("The AI's curiosity is growing. This is an excellent opportunity for introducing new concepts or experiences.")
|
491 |
-
elif all(x > y for x, y in zip(curiosity_trend, curiosity_trend[1:])):
|
492 |
-
st.write("The AI's curiosity is diminishing. Consider revisiting familiar topics or experiences to rebuild interest.")
|
493 |
-
|
494 |
-
st.write("\nRecommendations for next interaction:")
|
495 |
-
if st.session_state.autonomy.mood < 0.4:
|
496 |
-
st.write("- Focus on positive, enjoyable experiences to improve mood")
|
497 |
-
if st.session_state.autonomy.energy < 0.3:
|
498 |
-
st.write("- Plan for a rest period or very low-intensity interaction")
|
499 |
-
if st.session_state.autonomy.curiosity > 0.8:""
|
500 |
-
st.write("- Introduce a completely new type of sensory input or cognitive challenge")
|
501 |
-
|
502 |
-
st.write("\nLong-term goals:")
|
503 |
-
st.write("- Maintain a balanced distribution of sensory inputs to ensure well-rounded development")
|
504 |
-
st.write("- Gradually increase the complexity of interactions to promote cognitive growth")
|
505 |
-
st.write("- Monitor for any persistent negative trends and adjust the interaction strategy accordingly")
|
506 |
-
|
507 |
# End of the script
|
|
|
8 |
import base64
|
9 |
from streamlit_drawable_canvas import st_canvas
|
10 |
import plotly.graph_objects as go
|
11 |
+
import json
|
12 |
+
from datetime import datetime
|
13 |
+
import os
|
14 |
|
15 |
# Set page config for a futuristic look
|
16 |
st.set_page_config(page_title="NeuraSense AI", page_icon="π§ ", layout="wide")
|
|
|
161 |
else:
|
162 |
return "Continue current activity"
|
163 |
|
164 |
+
# Function to save interactions
|
165 |
+
def save_interaction(interaction_data):
|
166 |
+
timestamp = datetime.now().strftime("%Y%m%d_%H%M%S")
|
167 |
+
filename = f"interaction_{timestamp}.json"
|
168 |
+
with open(filename, "w") as f:
|
169 |
+
json.dump(interaction_data, f, indent=4)
|
170 |
+
return filename
|
171 |
+
|
172 |
# Streamlit app
|
173 |
st.title("NeuraSense AI: Advanced Humanoid Techno-Sensory Simulation")
|
174 |
|
|
|
234 |
if 'autonomy' not in st.session_state:
|
235 |
st.session_state.autonomy = EnhancedAutonomy()
|
236 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
237 |
if canvas_result.json_data is not None:
|
238 |
objects = canvas_result.json_data["objects"]
|
239 |
if len(objects) > 0:
|
|
|
281 |
st.write(f"Duration: {touch_duration:.1f} s | Intensity: {touch_pressure:.2f}")
|
282 |
|
283 |
# Create a futuristic data display
|
284 |
+
data_display = f"""
|
285 |
```
|
286 |
βββββββββββββββββββββββββββββββββββββββββββββββ
|
287 |
+
β Pressure : {{measured_pressure:.2f}} β
|
288 |
+
β Temperature : {{measured_temp:.2f}}Β°C β
|
289 |
β Texture : {measured_texture} β
|
290 |
+
β EM Field : {{measured_em:.2f}} ΞΌT β
|
291 |
β Quantum State: {quantum_state:.2f} β
|
292 |
βββββββββββββββββββββββββββββββββββββββββββββββ€
|
293 |
+
β Pain Level : {{pain_level:.2f}} β
|
294 |
+
β Pleasure : {{pleasure_level:.2f}} β
|
295 |
+
β Tickle : {{tickle_level:.2f}} β
|
296 |
+
β Itch : {{itch_level:.2f}} β
|
297 |
+
β Proprioception: {{proprioception:.2f}} β
|
298 |
β Synesthesia : {synesthesia} β
|
299 |
+
β Neural Response: {{neural_response:.2f}} β
|
300 |
βββββββββββββββββββββββββββββββββββββββββββββββ
|
301 |
```
|
302 |
"""
|
303 |
st.code(data_display, language="")
|
304 |
|
305 |
+
"""
|
306 |
+
st.code(data_display, language="")
|
307 |
+
# Generate description
|
308 |
prompt = f"""Human: Analyze the sensory input for a hyper-advanced AI humanoid:
|
309 |
Location: ({{touch_x:.1f}}, {{touch_y:.1f}})
|
310 |
Duration: {{touch_duration:.1f}}s, Intensity: {{touch_pressure:.2f}}
|
|
|
321 |
Neural Response: {{neural_response:.2f}}
|
322 |
Provide a detailed, scientific, and creative description of the AI humanoid's experience and response to this sensory input."""
|
323 |
|
324 |
+
# You can use this prompt to generate a response from your AI model
|
325 |
+
# For demonstration, let's create a mock AI response
|
326 |
+
ai_response = f"""Based on the complex sensory input received, the hyper-advanced AI humanoid is experiencing a multifaceted neural response:
|
327 |
|
328 |
+
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.
|
329 |
|
330 |
+
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.
|
331 |
|
332 |
+
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.
|
333 |
|
334 |
+
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.
|
335 |
|
336 |
+
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.
|
337 |
|
338 |
{"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."}
|
339 |
|
340 |
+
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.
|
341 |
|
342 |
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.
|
343 |
+
"""
|
344 |
|
345 |
+
st.write("AI Response:")
|
346 |
+
st.write(ai_response)
|
347 |
+
|
348 |
+
# Update autonomy
|
349 |
+
sensory_input = {
|
350 |
+
'pain': pain_level,
|
351 |
+
'pleasure': pleasure_level,
|
352 |
+
'intensity': touch_pressure,
|
353 |
+
'duration': touch_duration,
|
354 |
+
'location': (touch_x, touch_y)
|
355 |
+
}
|
356 |
+
st.session_state.autonomy.update_state(sensory_input)
|
357 |
+
|
358 |
+
# Display autonomy state
|
359 |
+
st.write("### Autonomy State")
|
360 |
+
st.write(f"Mood: {st.session_state.autonomy.mood:.2f}")
|
361 |
+
st.write(f"Energy: {st.session_state.autonomy.energy:.2f}")
|
362 |
+
st.write(f"Curiosity: {st.session_state.autonomy.curiosity:.2f}")
|
363 |
+
|
364 |
+
# Display decision
|
365 |
+
decision = st.session_state.autonomy.decide_action()
|
366 |
+
st.write(f"Decision: {decision}")
|
367 |
+
|
368 |
+
# Save interaction
|
369 |
+
if st.button("Save Interaction"):
|
370 |
+
interaction_data = {
|
371 |
+
"timestamp": datetime.now().isoformat(),
|
372 |
+
"sensory_input": sensory_input,
|
373 |
+
"ai_state": {
|
374 |
+
"mood": st.session_state.autonomy.mood,
|
375 |
+
"energy": st.session_state.autonomy.energy,
|
376 |
+
"curiosity": st.session_state.autonomy.curiosity
|
377 |
+
},
|
378 |
+
"ai_response": ai_response,
|
379 |
+
"decision": decision
|
380 |
+
}
|
381 |
+
saved_file = save_interaction(interaction_data)
|
382 |
+
st.success(f"Interaction saved to {saved_file}")
|
383 |
+
|
384 |
+
# Display recent interactions
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
385 |
st.subheader("Recent Interactions")
|
386 |
interaction_files = sorted([f for f in os.listdir() if f.startswith("interaction_")], reverse=True)[:5]
|
387 |
for file in interaction_files:
|
388 |
with open(file, "r") as f:
|
389 |
data = json.load(f)
|
390 |
st.write(f"Interaction at {data['timestamp']}")
|
391 |
+
st.write(f"Location: {data['sensory_input']['location']}")
|
392 |
st.write(f"AI Mood: {data['ai_state']['mood']:.2f}")
|
393 |
st.write(f"AI Energy: {data['ai_state']['energy']:.2f}")
|
394 |
st.write(f"AI Curiosity: {data['ai_state']['curiosity']:.2f}")
|
395 |
+
st.write(f"Decision: {data['decision']}")
|
|
|
|
|
396 |
st.write("---")
|
397 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
398 |
# End of the script
|