Convert to iso format after creating a dict of the whole memory#1174
Convert to iso format after creating a dict of the whole memory#1174
Conversation
WalkthroughThe changes in this pull request modify the Changes
Possibly related PRs
Poem
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? 🪧 TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (Invoked using PR comments)
Other keywords and placeholders
CodeRabbit Configuration File (
|
There was a problem hiding this comment.
Actionable comments posted: 0
🧹 Outside diff range and nitpick comments (4)
backend/models/memory.py (4)
Line range hint
199-203: Critical: Potential data loss in events serializationThe current implementation only preserves the
starttimestamp of events while discarding other important event properties (title, description, duration). This appears to be unintentional and could break API consumers expecting complete event details.Consider this fix to preserve all event properties while ensuring ISO format for dates:
- memory_dict['structured']['events'] = [event['start'].isoformat() for event in memory_dict['structured']['events']] + memory_dict['structured']['events'] = [ + {**event, 'start': event['start'].isoformat()} + for event in memory_dict['structured']['events'] + ]
Line range hint
242-243: Consider more descriptive enum valuesThe enum values could be more descriptive to better convey their purpose.
Consider this enhancement:
class WorkflowMemorySource(str, Enum): - audio = 'audio_transcript' - other = 'other_text' + audio_transcript = 'audio_transcript' # From transcribed audio recordings + text_input = 'text_input' # From direct text input or other sources
Line range hint
246-259: Add field descriptions for consistencyOther models in the file use Field with descriptions. Consider adding descriptions to maintain consistency.
Example enhancement:
class WorkflowCreateMemory(BaseModel): - started_at: Optional[datetime] = None - finished_at: Optional[datetime] = None - text: str - text_source: WorkflowMemorySource = WorkflowMemorySource.audio - geolocation: Optional[Geolocation] = None + started_at: Optional[datetime] = Field(None, description="When the workflow memory creation started") + finished_at: Optional[datetime] = Field(None, description="When the workflow memory creation completed") + text: str = Field(description="The main content of the workflow memory") + text_source: WorkflowMemorySource = Field( + default=WorkflowMemorySource.audio, + description="Source type of the workflow memory content" + ) + geolocation: Optional[Geolocation] = Field(None, description="Location information if available")
Line range hint
261-262: Consider enhancing get_transcript methodThe current implementation simply returns the text field. Consider adding timestamp handling for consistency with other memory types.
Example enhancement:
def get_transcript(self, include_timestamps: bool) -> str: - return self.text + if not include_timestamps: + return self.text + + timestamp = self.started_at.strftime("%H:%M:%S") if self.started_at else "00:00:00" + return f"[{timestamp}] {self.text}"
|
lgtm @mdmohsin7 🚀 |
Summary by CodeRabbit
New Features
Bug Fixes