Skip to content

Commit

Permalink
Add additional metadata fields to dreams.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreaminglucid committed Aug 29, 2023
1 parent f349869 commit 1849fbd
Show file tree
Hide file tree
Showing 2 changed files with 29 additions and 2 deletions.
17 changes: 16 additions & 1 deletion lucidserver/endpoints/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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),
}

Expand Down Expand Up @@ -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}")
Expand Down
14 changes: 13 additions & 1 deletion lucidserver/memories/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand All @@ -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")
Expand Down Expand Up @@ -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")
}
}

Expand Down Expand Up @@ -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
Expand Down

0 comments on commit 1849fbd

Please sign in to comment.