Create AichatRequest model for ActiveJob - #60257
#60257Create AichatRequest model for ActiveJob#60257sanchitmalhotra126 merged 3 commits intostagingcode-dot-org/code-dot-org:stagingfrom sanchit/aichat-activejob-modelcode-dot-org/code-dot-org:sanchit/aichat-activejob-modelCopy head branch name to clipboard
Conversation
| t.integer :user_id, null: false | ||
| t.json :model_customizations, null: false | ||
| t.json :stored_messages | ||
| t.text :new_message, null: false |
There was a problem hiding this comment.
In aichat_controller, 'newMessage' is a ChatMessage with fields role, chatMessageText, and status. Are we only storing the message text in this table?
If we are storing other fields (role and status): Would it be helpful to store as json as well? And maybe rename status as request_status below?
There was a problem hiding this comment.
Oh good catch! yeah this should probably be json
There was a problem hiding this comment.
Also, discussed offline - will rename status to execution_status
There was a problem hiding this comment.
Thanks for the name update!
| TEACHER: 'teacher', | ||
| ).freeze | ||
|
|
||
| AI_REQUEST_EXECUTION_STATUS = { |
There was a problem hiding this comment.
Are you naming as AI_REQUEST... instead of AICHAT_REQUEST... anticipating that these will also be used across AI projects?
There was a problem hiding this comment.
Yeah, that was my thought (and that AICHAT_REQUEST_EXECUTION_STATUS felt a bit too long 😄). Though we can also keep it AICHAT-specific if that's clearer.
|
Added |
cnbrenci
left a comment
There was a problem hiding this comment.
I believe we do already have work on the backlog for periodic cleanup / aging out of requests in this table. This will definitely be important to prioritize since we don't want the table to grow unbounded forever :) LGTM!
@cnbrenci yep, good callout! I'll add this specific table to the JIRA notes to make sure we clean this up too. |
Part 1 of moving the aichat chat completion request to an Active Job. This model will be used to store the inputs for the sagemaker request, the status of the job, and the output when completed (or appropriate failure status).
I've also included a list of execution status codes I'm thinking of using in
shared_constants. These aren't directly used in this PR, but will be in the job processing and front end request/polling implementation. Included here for reference on how the "status" column would be used. These are modeled after theRUBRIC_AI_EVALUATION_STATUScodes that are similarly used to track job status.Also note that because this model stores the user ID of the requestor, this table can also serve as a record of requests and responses from SageMaker (instead of storing this information in Cloudwatch). I also considered storing additional metadata like level ID, channel ID, etc, but opted to keep this table focused on the specific information necessary for the task. I figured if we wanted to look up a specific user, we could look up their full event history in the AichatEvents table.
Links
https://codedotorg.atlassian.net/browse/LABS-959
Testing story
Tested by creating models in the console and in ActiveJob code.