nx_companion_photo.nx source
↩ module page · 33 lines · 2181 B
1// nx_companion_photo.nx -- the capstone that makes the companion SHARE a grounded self-image and REMEMBER it,
2// unifying the visual arc with episodic memory. When the companion sends a photo: advance her visual arc (new
3// outfit/scene -- same person), compose the /gen/api/generate request for the existing NAS pipeline, AND append
4// an episodic memory ("I sent you a photo of me <current look, scene>") so what she shares and what she recalls
5// stay coherent turn to turn. The caller sends the returned request to the sovereign gen daemon; the memory is
6// already written. This is "integrated in her persona and env and all the things": one being who talks,
7// remembers, and shares images of herself grounded in our scenes, varying every time. license_tier: ORIGINAL
8import "nx_companion_render.nx"
9import "nx_companion_memory.nx"
10const K_MAGIC_4096: i64 = 4096
11const K_MAGIC_8192: i64 = 8192
12
13// companion_share_photo: advance arc -> gen request (into out_req) + episodic memory of the shared photo.
14// Returns the gen-request length; *step_out = the new arc step. speaker of the memory = the persona herself.
15func companion_share_photo_pfx(vpfx: *u8, mpfx: *u8, persona: *u8, session: *u8, ts: *u8, out_req: *u8, cap: i64, step_out: *i64) -> i64 {
16 let s: i64 = varc_advance_pfx(vpfx, persona)
17 if (step_out as i64) != 0 { step_out[0] = s }
18 let rl: i64 = render_gen_body_at_pfx(vpfx, persona, s, out_req, cap)
19 // human caption of the current look for the memory line
20 let capb: *u8 = sys_mmap(K_MAGIC_4096)
21 varc_caption_at_pfx(vpfx, persona, s, capb, K_MAGIC_4096)
22 let mt: *u8 = sys_mmap(K_MAGIC_8192)
23 var o: i64 = tr_cat(mt, 0, "I sent you a photo of me " as *u8)
24 var i: i64 = 0; while capb[i] != (0 as u8) { mt[o] = capb[i]; o = o + 1; i = i + 1 }
25 mt[o] = 0 as u8
26 mem_append_pfx(mpfx, persona, session, ts, persona, mt)
27 return rl
28}
29
30// production wrapper -- the persona's real visual + episodic stores
31func companion_share_photo(persona: *u8, session: *u8, ts: *u8, out_req: *u8, cap: i64, step_out: *i64) -> i64 {
32 return companion_share_photo_pfx(VID_PREFIX, EPI_PREFIX, persona, session, ts, out_req, cap, step_out)
33}