Skip to content

Commit

Permalink
Add setting option to dream metadata.
Browse files Browse the repository at this point in the history
  • Loading branch information
dreaminglucid committed Aug 30, 2023
1 parent 1849fbd commit f31df63
Show file tree
Hide file tree
Showing 2 changed files with 15 additions and 9 deletions.
9 changes: 5 additions & 4 deletions lucidserver/endpoints/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -71,6 +71,7 @@ def register_endpoints(app):
"lucidity": fields.Int(), # Optional, scaler 1-5
"characters": fields.Str(), # Optional
"emotions": fields.Str(), # Optional
"setting": fields.Str(),
"id_token": fields.Str(required=True),
}

Expand All @@ -92,7 +93,7 @@ def register_endpoints(app):
"query": fields.Str(required=True),
}

# Placeholder for user's image style preferences
# Placeholder for user's image style preferences
user_style_preferences = {}

# Placeholder for user's image style preferences
Expand All @@ -115,13 +116,13 @@ def create_dream_endpoint(args, userEmail):
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")
args.get("emotions"),
args.get("setting")
)

if dream_data is None or "id" not in dream_data:
raise RuntimeError(f"Dream creation failed with data {args}")

Expand Down
15 changes: 10 additions & 5 deletions 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, details=None, symbols=None, lucidity=None, characters=None, emotions=None):
def create_dream(title, date, entry, userEmail, symbols=None, lucidity=None, characters=None, emotions=None, setting=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 @@ -23,7 +23,8 @@ def create_dream(title, date, entry, userEmail, details=None, symbols=None, luci
"symbols": symbols,
"lucidity": lucidity,
"characters": characters,
"emotions": emotions
"emotions": emotions,
"setting": setting
}
# Log the constructed metadata
log(f"Constructed metadata: {metadata}", type="debug")
Expand Down Expand Up @@ -98,7 +99,8 @@ def get_dream(dream_id):
"symbols": dream["metadata"].get("symbols"),
"lucidity": dream["metadata"].get("lucidity"),
"characters": dream["metadata"].get("characters"),
"emotions": dream["metadata"].get("emotions")
"emotions": dream["metadata"].get("emotions"),
"setting": dream["metadata"].get("setting")
}
}

Expand Down Expand Up @@ -138,7 +140,8 @@ def get_dreams(userEmail):
"symbols": memory["metadata"].get("symbols"),
"lucidity": memory["metadata"].get("lucidity"),
"characters": memory["metadata"].get("characters"),
"emotions": memory["metadata"].get("emotions") # Newly added
"emotions": memory["metadata"].get("emotions"),
"setting": memory["metadata"].get("setting")
}
}
# Optionally, extract analysis and image from metadata if present
Expand Down Expand Up @@ -287,13 +290,15 @@ def update_dream_analysis_and_image(dream_id, analysis=None, image=None):
def search_dreams(keyword, user_email):
log(f"Searching dreams for keyword: {keyword} and user email: {user_email}.", type="info")
search_results = search_memory("dreams", keyword, n_results=100)

# Adding new fields like symbols, lucidity, characters, emotions to the metadata dictionary
dreams = [
{
"id": memory["id"],
"document": memory["document"],
"metadata": {
key: memory["metadata"][key]
for key in ["date", "title", "entry", "analysis"]
for key in ["date", "title", "entry", "analysis", "symbols", "lucidity", "characters", "emotions", "setting"]
if key in memory["metadata"]
},
}
Expand Down

0 comments on commit f31df63

Please sign in to comment.