From 1849fbd02a26d399c6e4f805dd5aa0f6c9e1caea Mon Sep 17 00:00:00 2001 From: cp-james-harbeck Date: Tue, 29 Aug 2023 04:07:15 -0400 Subject: [PATCH] Add additional metadata fields to dreams. --- lucidserver/endpoints/main.py | 17 ++++++++++++++++- lucidserver/memories/main.py | 14 +++++++++++++- 2 files changed, 29 insertions(+), 2 deletions(-) diff --git a/lucidserver/endpoints/main.py b/lucidserver/endpoints/main.py index 2b856e2..7986985 100644 --- a/lucidserver/endpoints/main.py +++ b/lucidserver/endpoints/main.py @@ -67,6 +67,10 @@ def register_endpoints(app): "title": fields.Str(required=True), "date": fields.Str(required=True), "entry": fields.Str(required=True), + "symbols": fields.Str(), # Optional + "lucidity": fields.Int(), # Optional, scaler 1-5 + "characters": fields.Str(), # Optional + "emotions": fields.Str(), # Optional "id_token": fields.Str(required=True), } @@ -105,7 +109,18 @@ def create_dream_endpoint(args, userEmail): log(f"Received args: {args}", type="debug") log(f"Received userEmail: {userEmail}", type="debug") - dream_data = create_dream(args["title"], args["date"], args["entry"], userEmail) + # Pass along the newly added optional fields to `create_dream` function + dream_data = create_dream( + args["title"], + args["date"], + args["entry"], + userEmail, + None, # details, which you don't seem to use + args.get("symbols"), + args.get("lucidity"), + args.get("characters"), + args.get("emotions") + ) if dream_data is None or "id" not in dream_data: raise RuntimeError(f"Dream creation failed with data {args}") diff --git a/lucidserver/memories/main.py b/lucidserver/memories/main.py index bd3f23b..c8171ba 100644 --- a/lucidserver/memories/main.py +++ b/lucidserver/memories/main.py @@ -9,7 +9,7 @@ from lucidserver.actions import generate_dream_analysis, generate_dream_image, get_image_summary -def create_dream(title, date, entry, userEmail): +def create_dream(title, date, entry, userEmail, details=None, symbols=None, lucidity=None, characters=None, emotions=None): try: # Step 1: Initial log to confirm function entry log(f"Entering create_dream function with title: {title}, date: {date}, entry: {entry}, userEmail: {userEmail}", type="debug") @@ -20,6 +20,10 @@ def create_dream(title, date, entry, userEmail): "date": date, "entry": entry, "useremail": userEmail, + "symbols": symbols, + "lucidity": lucidity, + "characters": characters, + "emotions": emotions } # Log the constructed metadata log(f"Constructed metadata: {metadata}", type="debug") @@ -91,6 +95,10 @@ def get_dream(dream_id): "date": dream["metadata"]["date"], "entry": dream["metadata"]["entry"], "useremail": dream["metadata"]["useremail"], + "symbols": dream["metadata"].get("symbols"), + "lucidity": dream["metadata"].get("lucidity"), + "characters": dream["metadata"].get("characters"), + "emotions": dream["metadata"].get("emotions") } } @@ -127,6 +135,10 @@ def get_dreams(userEmail): "date": memory["metadata"]["date"], "entry": memory["metadata"]["entry"], "useremail": memory["metadata"]["useremail"], + "symbols": memory["metadata"].get("symbols"), + "lucidity": memory["metadata"].get("lucidity"), + "characters": memory["metadata"].get("characters"), + "emotions": memory["metadata"].get("emotions") # Newly added } } # Optionally, extract analysis and image from metadata if present