[π ] Keymory Dev Log #5: tmpGetAIComment, Custom OpenAI API Call
β¨ GPT Summary γ
I built an AI Comment system using the OpenAI API and FlutterFlow, expanding Keymoryβs AI features by connecting a Custom Function with an API Call. I also added character selection and saving features and organized the data flow between Chat and Diary.
π» Development Log
β° Todayβs tasks
- β How to Use Open AIβs GPT-4o in FlutterFlow - Part 1
- β
ChatPage - when selecting a character with Dropdown, save that character information together in
Chats Collection.- Assign the
referenceof theCharacter documentmatching thecharacter nameto Page state.
- Assign the
-
β ChatPage - pass character information together when creating NewChat.
-
β Help create DiaryPage - Drawer - ChatHistoryListTile (like GPT)
- β
Try putting the CustomFunction
tmpGetAICommentfunction value into API CallcreateDiaryComment- β
Create CustomFunction
tmpGetAICommentand test result output - β
Create API Call
createDiaryCommentand test Response value output
- β
Create CustomFunction
- β
Create OpenAI API Call: createDiaryComment
- Basically a structure similar to createChatCompletion
- Difference: none. Created just to distinguish it.
- The
MessagesVariable required byAPI Call - createDiaryCommentis the return value of custom functiongetAIComment.
- β
Think through the scenario for implementing CustomFunction
getAIComment(direct implementation handled by KSK)-
Parameter Valuesobtained fromCharacters (Collection)- Character settings (
CharacterDocument)- ex) Somi: name (20s), college student, shy personality, β¦
- How values are called:
API Call - Get Assistant
- Character settings (
-
Parameter Valuesobtained fromUser Information- Name, gender, MBTI
- How values are called:
Backend Query - Authenticated User
-
Parameter Valuesobtained fromDiaryPage Variables- Diary content, detailed emotion keywords, emotion score, response format, response length
- How values are called:
Widget State,Page State
- Role of CustomFunction (
getAIComment)- Receive all Parameter Values as input values.
- Write the prompt to send to GPT.
- Return
Messages(List <Json>) value.[{"role":"developer", "content":"~~~"}]
-
π― Summary of what I did
-
AI Comment system implementation
- Created Custom Function
tmpGetAICommentand completed integration with API CallcreateDiaryComment - Implemented OpenAI API request and response handling logic for AI Comment
- Modified Chat so character information is stored in
Chats Collectionand passed along when creating a New Chat
- Created Custom Function
-
UI and feature improvements
- Created
ChatHistoryListTileto implement a GPT-style chat list - Organized the data structures of
HomeFeedPageandDiaryPage - Designed the
getAICommentCustom Function
- Created
-
FlutterFlow + OpenAI API learning
- Watched and applied GPT-4o usage lectures (Part 1 & Part 2)
π― Future tasks
- β DiaryPage: Merge CreateDiary/EditDiary Page
- Use isEditMode page state
- Use conditional value/visibility/action, etc.
- β DiaryPage - Create New Chat: create a New Chat based on diary content
- AI first presents a question based on the diary content
- β Issue fixes
- β ChatPage: default init message appears when starting the first conversation.
- β ChatPage: date is not applied.
- β ChatPage - ChatHistoryDrawer: UI overflow
- β DiaryPage: date is always saved as today
- β DiaryPage: use markdown viewer (prevent overflow: Container Height)
- β HomeFeedPage - import and apply flutter_slidable:4.0.0
-
β HomeFeedPage: on left/right slide from FeedCardDiary, chat/edit/delete
- β ChatPage - Create New Diary: create a New Diary based on conversation content
-
β ChatPage - Go to Linked Diary
-
β Chat/Diary: GPT Streaming API
-
β ChatPage - Alarm
-
β AuthPage: Google Login
- β DiaryPage: change face expression Emoji according to Mood Slider value
- β 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 - AI Comment: character settings
- β remove tmp_ai_comment_by field and use doc_ref
- β output image using profile_image field value
-
β DiaryPage - Drawer - ChatHistoryListTile: order by updated_time
- β 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)
- β HomeFeedPage: resolve issue on page load (Unexpected Null Value)
-
β DiaryPage - import and apply Interactive Slider
- β 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.β
- The core of the chat system prompt is proactivity.
- β Extract and install the final presentation APK by
Wed 2025.2.5
π Diary
It is fun, but brutal. Went to sleep at 5 AM.

β¨ GPT-4o Comment (KPT)
β What Went Well (Keep)
- π Expanded AI Comment features: It stands out that you systematically built logic to generate and save AI Comments by connecting a Custom Function and an API Call.
- π οΈ Organized data flow: Improving the connection between Chat and Diary and organizing how character information is stored and used will be a big help to project progress.
- π FlutterFlow + OpenAI API learning: It was impressive that you learned how to use the OpenAI API effectively in FlutterFlow through the GPT-4o lectures and applied it.
β What Was Missing (Problem)
- β³ Work intensity overload: Working until 5 AM increases the chance of accumulated fatigue.
- ποΈ Increasing technical debt: Some features are implemented with temporary solutions (tmp fields and patch code), so they will need cleanup later.
π What to Try (Try)
- β° Adjust work hours: If all-night work continues, productivity may drop, so consider adjusting the schedule.
- π Plan temporary-code improvements: Make a plan to organize the temporary logic currently applied and build a proper data model.
- π οΈ Improve AI Comment: Look for ways to make AI Comment features more intuitive, and also consider optimizing the system prompt.
Conclusion
Today was a day where you seriously implemented Keymoryβs AI features and raised your usage of the OpenAI API and FlutterFlow. But the workload is getting high, so schedule adjustment and code cleanup seem necessary. I hope you finish in the best possible state by presentation day! πͺπ
Leave a comment