You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I've modified the get_dream, get_dreams, and update_dream_analysis_and_image functions to nest the analysis and image fields inside the metadata dictionary. This will ensure that when dreams are fetched or updated, the analysis and image fields will be part of the metadata rather than being separate fields.
Here are the updated functions:
get_dream
defget_dream(dream_id):
log(f"Initiating retrieval of dream with id {dream_id}.", type="info")
dream=get_memory("dreams", dream_id)
ifdreamisNone:
log(f"Dream with id {dream_id} not found.", type="error")
returnNonemetadata=dream.get('metadata', {})
# Consolidate all metadata fields, including optional analysis and imagemetadata_fields= {
"title": metadata.get("title", ""),
"date": metadata.get("date", ""),
"entry": metadata.get("entry", ""),
"useremail": metadata.get("useremail", ""),
"analysis": metadata.get("analysis", None),
"image": metadata.get("image", None)
}
dream_data= {
"id": dream["id"],
"document": dream["document"],
"metadata": metadata_fields
}
log(f"Successfully retrieved dream with id {dream_id}: {dream_data}", type="info")
returndream_data
defupdate_dream_analysis_and_image(dream_id, analysis=None, image=None):
log(f"Initiating update for dream analysis and image for dream id {dream_id}.", type="info")
dream=get_dream(dream_id)
ifdreamisNone:
log(f"Dream with id {dream_id} not found.", type="error")
returnNonemetadata=dream.get("metadata")
ifmetadataisNone:
log(f"Metadata for dream with id {dream_id} not found.", type="error")
returnNoneifanalysis:
ifisinstance(analysis, str):
metadata["analysis"] =analysiselse:
log(f"Invalid analysis data for dream id {dream_id}.", type="error")
returnNoneifimage:
ifisinstance(image, str):
metadata["image"] =imageelse:
log(f"Invalid image data for dream id {dream_id}.", type="error")
returnNonetry:
update_memory("dreams", dream_id, metadata=metadata)
log("Dream analysis and image updated successfully.", type="info")
returndreamexceptExceptionase:
log(f"Failed to update dream id {dream_id}. Error: {str(e)}", type="error")
returnNone
In these updated functions, the analysis and image fields are now part of the metadata dictionary. This should align with your requirement to have these fields nested within metadata.
The text was updated successfully, but these errors were encountered:
I've modified the get_dream, get_dreams, and update_dream_analysis_and_image functions to nest the analysis and image fields inside the metadata dictionary. This will ensure that when dreams are fetched or updated, the analysis and image fields will be part of the metadata rather than being separate fields.
Here are the updated functions:
get_dream
get_dreams
update_dream_analysis_and_image
In these updated functions, the analysis and image fields are now part of the metadata dictionary. This should align with your requirement to have these fields nested within metadata.
The text was updated successfully, but these errors were encountered: