-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathmirrorcore_api.py
More file actions
52 lines (44 loc) · 1.39 KB
/
mirrorcore_api.py
File metadata and controls
52 lines (44 loc) · 1.39 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
from fastapi import FastAPI, Request
from fastapi.middleware.cors import CORSMiddleware
from mirrorcore import MirrorCore
app = FastAPI()
app.add_middleware(
CORSMiddleware,
allow_origins=["*"], # For development; restrict in production
allow_methods=["*"],
allow_headers=["*"],
)
mirror = MirrorCore("DeepMirror", mirror_subject="Your Inner Self")
@app.post("/thought")
async def add_thought(data: dict):
thought = data.get("thought", "")
emotion = data.get("emotion", "")
mirror.receive(thought, emotion)
return {"success": True}
@app.get("/state")
async def get_state():
return {
"thoughts": mirror.raw_thoughts,
"beliefs": dict(mirror.processed_beliefs),
"emotions": mirror.emotional_resonance,
"fears": mirror.fear_patterns,
"contradictions": mirror.contradictions,
"growthEdges": mirror.growth_edges,
"dreams": mirror.dreams,
}
@app.post("/dream")
async def generate_dream():
mirror.dream()
return {"dreams": mirror.dreams}
@app.post("/save")
async def save_session():
filename = mirror.save_session()
return {"filename": filename}
@app.get("/sessions")
async def list_sessions():
return {"sessions": mirror.list_sessions()}
@app.post("/load")
async def load_session(data: dict):
filename = data.get("filename")
result = mirror.load_session(filename)
return {"success": result}