Spaces:
Sleeping
Sleeping
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from motion_id import create_motion_id
|
| 3 |
+
from motion_memory import remember, recall
|
| 4 |
+
|
| 5 |
+
# Dummy agent function (replace with Orchestrator later)
|
| 6 |
+
def dummy_agent(message):
|
| 7 |
+
return f"Agent reply: {message}"
|
| 8 |
+
|
| 9 |
+
# Interface function
|
| 10 |
+
def interface(name, message):
|
| 11 |
+
# Get or create Motion ID
|
| 12 |
+
agent_id = create_motion_id(name)
|
| 13 |
+
|
| 14 |
+
# Get agent response
|
| 15 |
+
response = dummy_agent(message)
|
| 16 |
+
|
| 17 |
+
# Save memory
|
| 18 |
+
remember(agent_id, message, response)
|
| 19 |
+
|
| 20 |
+
# Show last 5 interactions
|
| 21 |
+
past = recall(agent_id)
|
| 22 |
+
past_str = "\n".join([f"Q: {p['message']} | A: {p['response']}" for p in past])
|
| 23 |
+
|
| 24 |
+
return f"Response: {response}\n\nMemory:\n{past_str}"
|
| 25 |
+
|
| 26 |
+
# Gradio app
|
| 27 |
+
gr.Interface(
|
| 28 |
+
fn=interface,
|
| 29 |
+
inputs=["text", "text"],
|
| 30 |
+
outputs="text",
|
| 31 |
+
title="Motion Memory MVP",
|
| 32 |
+
description="Agents remember past interactions for context."
|
| 33 |
+
).launch()
|