[π ] Keymory Dev Log #8: Building DiaryPage Emotion Keyword System, AI Comment Character Settings
β¨ GPT Summary γ
I added an emotion keyword selection feature to DiaryPage and implemented more natural responses by applying character settings to AI comments.
π» Development Log
β° Todayβs tasks
- β
DiaryPage: added
emotion keywordChoiceChip and TextField- β Create widgets
- β
Added diaries DB Fields: mood_keywords (
List <String>), mood_keywords_description (String) - β
Added diaries Page State: moodKeywordsSelected (
List <String>) - β
OnPageLoad: pass the newly added variables
- β
ChoiceChipRate (5~1): pass values from diariesDoc.mood_keywords to each corresponding ChoiceChip.
- Defined MoodKeywordRate5Options, β¦, MoodKeywordRate1Options
List <String>as App Constant values- Enum only supports English, so a translation feature would be needed. Too complicated, so rejected.
- Define Options Var: AppConstant.moodKeywordRate5Options (
List <String>) - Initially Selected: updateChoiceChipSelected
- Defined MoodKeywordRate5Options, β¦, MoodKeywordRate1Options
- β
Create CustomFunction
updateMoodKeywordsSelected- On Page Load: Select all matching items in RateOptions List
List<String> updateChoiceChipSelected( List<String> moodKeywordsSelected, // current selected keyword list List<String> moodKeywordRateOptions, // selectable options for the current Rate ) { // Create a new list to maintain immutability return List<String>.from( moodKeywordsSelected.where((item) => moodKeywordRateOptions.contains(item)) ); }
- β
ChoiceChipRate (5~1): pass values from diariesDoc.mood_keywords to each corresponding ChoiceChip.
- β
On ChoiceChip Selected: Update Page State
moodKeywordsSelected-> Set Value toReturn of Func updateMoodKeywordsSelected- β
Create CustomFunction
updateMoodKeywordsSelected- On Chip Select: Add to moodKeywordsSelected
- On Chip Deselect: Remove from moodKeywordsSelected
List<String> updateMoodKeywordsSelected( List<String> moodKeywordsSelected, List<String> choiceChipSelected, List<String> moodKeywordRateOptions, ) { // Copy the existing list to maintain immutability List<String> updatedList = List.from(moodKeywordsSelected); // 1οΈβ£ Remove values from the existing selection that belong to this Rate updatedList.removeWhere((item) => moodKeywordRateOptions.contains(item)); // 2οΈβ£ Add the currently selected ChoiceChip values updatedList.addAll(choiceChipSelected); return updatedList; }
- β
Create CustomFunction
- β
(Issue) DiaryPage - AI Comment: character settings
- Added diaries DB Field: ai_comment_by (Doc Ref: Character)
- DiaryPage - AICommentEditor Component - Return
ai_comment_content+ai_comment_by- How? -> create
aiCommentPageReturnObjectDataType
- How? -> create
- On ChoiceChipChar Selected: Backend Query Character Doc with same Official_name value.
- β
(Issue) HomeFeedPage - FeedCardDiary: apply AI Comment character image properly
- β DiaryPage - AI Comment: when saving, also save the Ref of the character who wrote the comment to Diary.
- β HomeFeedPage - FeedCardDiary - AI Image: load Character Doc with Backend Query and specify Image Path.
- β
(Issue) HomeFeedPage - FeedCardDiary: Unexpected Null Value Error
- This happens if I only put a Path value into the Image Widgetβ¦
- Ah!!! It happened because I did not put in a Default Variable Value. I only realized after struggling like crazy.
- π‘ What I learned
- Always make a habit of putting in a Default Value. How many times am I going to see Unexpected Null Value Error everywhere?
- This happens if I only put a Path value into the Image Widgetβ¦
- β
Design Action chains for
CreateNewChatFromDiary(Start From: after AI Comment processing and diary saving are complete)- Create Diary
- API Call: createDiarySummary -> Output Var: OutVar1 (temporary name)
- Create New Chat Document
- Create New Message Document: {βroleβ:βdeveloperβ, βcontentβ:β$systemprompt + $OutVar1β}
- API Call: createChatFromDiary -> Output Var: OutVar2 (temporary name)
- Create New Message Document: {βroleβ:βassistantβ, βcontentβ: β$OutVar2β}
- Navigate To: pass the relevant Chat Document Reference as chatRefParam
π― Summary of what I did
-
Built DiaryPage emotion keyword system
- Added ChoiceChip and TextField
- Added emotion keyword related fields to diaries DB
- Implemented
updateMoodKeywordsSelectedfunction
-
AI comment character settings and application
- Added
ai_comment_byfield to save the comment character - Modified AICommentEditor to include character information
- On ChoiceChip selection, load the relevant character data with Backend Query
- Added
-
Resolved HomeFeedPage AI comment image error
- Saved character reference value when writing AI comments
- Improved AI comment character image loading in HomeFeedPage
- Fixed Unexpected Null Value error (by applying a default value)
π― Future tasks
Click to see details
-
β (Issue) DiaryPage: use markdown viewer (prevent overflow: Container Height)
-
β DiaryPage: change face expression Emoji and color according to Mood Slider value
- β Help create Custom Function -
systemPromptTemplate(main worker: KSK)- β Organize parameters to add
- β Custom Function - test whether
getAICommentis actually applied- β Check whether input values are reflected properly
- β Check whether output value is printed properly as String
- β Chat Page - Create New Chat: apply system prompt
- βΆοΈ OpenAI API Call implementation: createChatCompletion
- Input: System Prompt (Chat)
- Output: New Chat Message by AI ($.choices[0].message.content)
- Additional Actions: Create New Chat, Create New Message
- βΆοΈ OpenAI API Call implementation: createChatCompletion
- β DiaryPage - Create New Chat by Diary: create a New Chat based on diary content
- β OpenAI API Call implementation: createDiaryComment
- Input: Diary Content, System Prompt (AI Comment)
- Output: AI Comment ($.choices[0].message.content)
- β OpenAI API Call implementation: createDiarySummary
- Input: Diary Content, AI Comment, System Prompt (Diary Summary)
- Output: Diary Summary ($.choices[0].message.content)
- β OpenAI API Call implementation: createChatFromDiary
- Input: Diary Summary, System Prompt (Chat From Diary)
- Output: New Chat Message by AI ($.choices[0].message.content)
- Additional Actions: Create New Chat, Create New Message
- β OpenAI API Call implementation: createDiaryComment
- β ChatPage - Create New Diary: create a New Diary based on conversation content
- β OpenAI API Call implementation: createChatSummary
- Input: Chat Content, System Prompt (Diary From Chat)
- Output: Chat Summary
- β OpenAI API Call implementation: createDiaryFromChat
- Input: Chat Summary, System Prompt (Diary From Chat)
- Output: New Diary (Title, Content, Mood score)
- β OpenAI API Call implementation: createChatSummary
-
β ChatPage: Go to Linked Diary
- β MoodPage (top) - Mood Calendar
- β Check the number of posts written by date
- β Move to the selected date when clicking a date
- β MoodPage (bottom) - Mood stats
- β Output statistics for the focused month
- β Output AI comment on the displayed statistics
- β Output statistics for the focused month
- β HomeFeedPage - import and apply flutter_slidable:4.0.0
-
β HomeFeedPage: on left/right slide from FeedCardDiary, chat/edit/delete
- β ChatPage: align user conversation output to the right
-
β Chat/Diary: GPT Streaming API
- β ChatPage - implement AI first message (Alarm/Notification)
- The core of the chat system prompt is proactivity.
- To make it more realistic, it might be good to pass create_date of diary/chat too, so the AI can mention dates like βyesterday.β
- Alarm implementation reference
- The core of the chat system prompt is proactivity.
- β DiaryPage: add detailed emotion keyword Choice Chips and set DB integration
- β DiaryPage - AI Comment: change inputs such as Choice chips and mood slider to fit the
AI Comment System Prompt.- β **previous
diaryor entireconversation history(patchy technical debt) - β basic user information: name, gender, MBTI, β¦
- β detailed emotion keywords: happy, sad, β¦
- β character settings: Somi, Sena, Minhyuk
- β emotion score: 1 to 100
- β response format: Healing, Suggestion, Informative
- β response length: short, normal, detailed
- is New Chat
- Since this Chatβs messages are being created for the first time, set
is_initial = trueon the first message document and shove in all system prompts.- is_initial = false
- Limit: if I put the system prompt into the very first message document, it is hard to modify in the middle of a conversation, but possible. If there is an is_initial = true document and it was modified, I can delete that document and put it back in. I do not know how, but still.
- Since this Chatβs messages are being created for the first time, set
- β **previous
- β DiaryPage - AI Comment: complete CRUD
- β remove tmp_ai_comment field and use doc_ref
-
β DiaryPage - Drawer - ChatHistoryListTile: order by updated_time
-
β DiaryPage - import and apply Interactive Slider
-
β HomeFeedPage: implement Search Diary feature
-
β AuthPage: implement Google Login
- β HomeFeedPage - Bottom Sheet (
+Button): make it possible to choose one of several options- New diary: Go to DiaryPage
- Emotion record: Go to MoodPage
- β MoodPage (popup): Mood setting slider CRUD
- Create
- Read
- Update
- Delete
- β HomeFeedPage - ListView - show FeedCardMood
-
β HomeFeedPage - ListView: sort FeedCardDiary, FeedCardMood, FeedCardChat components chronologically (using Cloud Function)
-
β Create MoodEditPage between HomeFeedPage and DiaryPage: move MoodSlider, MoodKeywordsRate (5~1), MoodDescription widgets, etc.
- β Extract and install the final presentation APK by
Wed 2025.2.5
π Diary
I can feel the technical debt growing nicely because of all the patchworkγ γ The submission deadline is 3 days away, so wellβ¦γ
β¨ GPT-4o Comment (KPT)
β What Went Well (Keep)
- π― Built emotion keyword system: Applying ChoiceChip so users can intuitively record emotions was good!
- π€ Applied AI comment characters: Setting responses by character to increase immersion was impressive.
- π Resolved HomeFeedPage error: Setting a default value to prevent Unexpected Null Value errors was excellent!
β What Was Missing (Problem)
- β³ Longer development time than expected: Implementing emotion keywords and AI comment features took more time than expected.
- π Increased character data complexity: The data flow became more complex, so maintenance may become difficult.
- π Insufficient problem-solving records: Not organizing the error resolution process may waste time if the same problem happens again.
π What to Try (Try)
- π Adjust development time by feature: Identify tasks that take longer than expected in advance and adjust the schedule.
- π Visualize data flow: Try organizing the data structure related to character settings as a diagram.
- π Build a habit of recording problem-solving: Document resolved issues and prepare strategies to prevent recurrence.
π Conclusion
Today was a day where you built the emotion keyword system and applied character settings to AI comments. Through error resolution, you confirmed again how important default values are, and going forward it seems necessary to manage development time more efficiently! ππ₯
Leave a comment