Skip to content

Add aichat to allthethings#52538

Merged
ebeastlake merged 27 commits into
stagingfrom
task/initial-chat-levels
Jul 20, 2023
Merged

Add aichat to allthethings#52538
ebeastlake merged 27 commits into
stagingfrom
task/initial-chat-levels

Conversation

@ebeastlake

@ebeastlake ebeastlake commented Jun 29, 2023

Copy link
Copy Markdown
Contributor

Adds a placeholder level for Aichat to /s/allthethings using the new Lab2 framework (I think 😄). S/o to Molly, Brendan, and Sanchit for their work there!

aichat_allthethings.mov

I welcome a close look at the boilerplate because this is my first time adding a new app type.

Links

Jira ticket: https://codedotorg.atlassian.net/browse/SL-940

Testing story

Tested locally; see Quicktime movie above.

Deployment strategy

Follow-up work

Privacy

Security

Caching

PR Checklist:

  • Tests provide adequate coverage
  • Privacy and Security impacts have been assessed
  • Code is well-commented
  • New features are translatable or updates will not break translations
  • Relevant documentation has been added or updated
  • User impact is well-understood and desirable
  • Pull Request is labeled appropriately
  • Follow-up work items (including potential tech debt) are tracked and linked

@ebeastlake ebeastlake requested a review from a team as a code owner June 29, 2023 20:04
elsif @type_class == Music
@game = Game.music
elsif @type_class == Aichat
@game = Aichat.music

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be @game = Game.aichat.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch; I have no idea how I renamed it so badly!

Comment thread dashboard/app/models/game.rb Outdated
end

def self.aichat
@@game_music ||= find_by_name('Aichat')

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This should probably be @@game_aichat ||= find_by_name('Aichat')

Comment thread apps/src/aichat/Aichat.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should be able to simplify this a fair bit, and hopefully not depend on the legacy studioApp.

Comment thread apps/src/aichat/AichatView.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We should also be able to simplify this file, and not rely on legacy components such as StudioAppWrapper.

@breville

breville commented Jul 2, 2023

Copy link
Copy Markdown
Member

It would be great for @molly-moen and @sanchitmalhotra126 to take a look at this too, to suggest which new parts of our framework this code might be able to use.

@sanchitmalhotra126

Copy link
Copy Markdown
Contributor

It would be great for @molly-moen and @sanchitmalhotra126 to take a look at this too, to suggest which new parts of our framework this code might be able to use.

For sure, it would be great to use the new lab framework here! (this would also be a great test of how easy or hard it is to onboard a new lab to the new framework). I think all the dashboard changes are good as-is (adding a new game type, etc). For the front end, we should just need:

  • levels-aichat-main.js (JS entrypoint): this can be modeled after levels-music-main.js, which wraps the lab view in all the new lab framework components. This essentially replaces studioApp, project.js, etc. This also means we don't need the various loadAichat, Aichat.js boilerplate classes
  • AichatView: the React view that renders the actual AI Chat experience. It seems like currently this view is just stubbed out so this can be super small, but it shouldn't need to include StudioAppWrapper or any of the other common classes. AichatView can also be a functional component (and preferably typescript too!)

@breville actually has some cool stuff in the works here which would create a single common entrypoint for all "Lab2" (lab lab) labs, so we potentially wouldn't even need a separate levels-aichat-main.js entrypoint.

@ebeastlake ebeastlake force-pushed the task/initial-chat-levels branch from fea5397 to e8e2c20 Compare July 7, 2023 06:19
@ebeastlake ebeastlake force-pushed the task/initial-chat-levels branch from ad086c0 to 07e1d33 Compare July 11, 2023 17:50
Comment thread apps/src/aichat/Aichat.tsx Outdated
*/

const Aichat: React.FunctionComponent<AichatProps> = ({children}) => {
// Leave a margin to the left and the right of the video, to the edges

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You probably won't need this layout stuff which is designed for a video which needs to maintain its aspect ratio while also filling the screen as much as possible. A simple flex layout should be enough for your app to take up the whole page in a few panels.

@ebeastlake ebeastlake changed the title [DO NOT MERGE] Add chat to allthethings Add aichat to allthethings Jul 11, 2023
import ProjectContainer from '@cdo/apps/lab2/projects/ProjectContainer';
import ProgressContainer from '@cdo/apps/lab2/progress/ProgressContainer';
import AichatView from '@cdo/apps/aichat/AichatView';
import {logError} from '@cdo/apps/music/utils/MusicMetrics';

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@sanchitmalhotra126 Can you confirm that the desired approach is to create an AichatMetrics version of

here?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Actually I've removed MusicMetrics in this PR: #52714, in favor of a global Lab2MetricsReporter singleton that any lab can use directly, so we shouldn't need a specific AichatMetrics.

Comment thread apps/src/lab2/views/Lab2.tsx Outdated
},
{
name: 'aichat',
usesChannel: false,

@ebeastlake ebeastlake Jul 11, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Can someone clarify the meaning of these values? usesChannel indicates a project is channel-backed, yes? I'm not sure about backgroundMode.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

usesChannel means that the level is project/channel-backed.

backgroundMode is a new concept that indicates whether the level is removed from the DOM when not active. For Music Lab, we don't yet support this removal from the DOM due to our Blockly usage not yet supporting a full teardown and subsequent recreation, and so we just make it invisible. For standalone videos, we do support removal from the DOM. You can pick based on your lab's capabilities, but it seems most likely you'd want to aim for false for this value.

# index_levels_on_name (name)
#

# TODO: Update this level to account for the params we actually need.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Callout: I did not do much work to customize this, but I assume that's all right to be future work.

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

We don't want to lock ourselves into a schema that requires a migration to address, but it's probably the contents of serialized_attrs that we might want to adjust, and those can be changed without a migration since they all serialize to the same database field.

Comment thread apps/webpack.js
Comment on lines +126 to +131
'@cdo/aichat/locale': path.resolve(
__dirname,
'src',
'aichat',
'locale-do-not-import.js'
),

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I'm actually curious whether this is needed.

@ebeastlake ebeastlake Jul 12, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I get a webpack error without it, but I am happy to dig in more.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so long as we have lab-specific locale files, we will need these specific aliases.

Comment thread dashboard/app/helpers/levels_helper.rb Outdated
elsif @level.is_a? Blockly
blockly_options
elsif @level.is_a?(Weblab) || @level.is_a?(Fish) || @level.is_a?(Ailab) || @level.is_a?(Javalab)
elsif @level.is_a?(Weblab) || @level.is_a?(Fish) || @level.is_a?(Ailab) || @level.is_a?(Javalab) || @level.is_a?(Aichat)

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Is this needed since this is a Lab2 app?

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think so, thanks! I should also be able to remove the non_blockly_puzzle_level_options method from the Aichat model.

options.freeze
end

def uses_lab2?

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

since uses_lab2 is true, we don't need a bunch of the boilerplate anymore. Everything gets loaded via levels-lab2-main, so you don't need the aichat version of that file, along with a bunch of other logic, you can see where I removed some of this for music in this PR. It would also be worth merging the latest changes into this branch, it doesn't look like you have the changes from that linked pr here.

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Here's what I removed so far: 90cb706

@@ -0,0 +1,12 @@
import appMain from '@cdo/apps/appMain';

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I don't think we need this anymore either!

},
{
"seeding_key": {
"level.key": "AI Chat Test Level",

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

are we missing this file from this PR? I tried to pull and seed locally and it can't find the level.

@ebeastlake ebeastlake Jul 17, 2023

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Added dashboard/config/scripts/levels/AI Chat Test Level.level and confirmed seeding that level succeeds locally.

Comment thread apps/src/aichat/levels.js Outdated

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@molly-moen @breville double checking - do we still need this file? I know we currently do have one for music, but it seems like since we don't call appMain(), these levels files are not referenced anywhere.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Hmm we may be able to delete it then! I may have missed that in my clean up

Comment thread apps/webpack.js
Comment on lines +126 to +131
'@cdo/aichat/locale': path.resolve(
__dirname,
'src',
'aichat',
'locale-do-not-import.js'
),

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think so long as we have lab-specific locale files, we will need these specific aliases.

@ebeastlake

Copy link
Copy Markdown
Contributor Author

@sanchitmalhotra126 I was assuming there would be outstanding work here to include the new MetricsReporter but it looks like there isn't because the file that originally used the Music version of the reporter is no longer needed and the reporting functionality is built into the Lab2 framework (see original comment here). Does that sound right?

@sanchitmalhotra126

Copy link
Copy Markdown
Contributor

@sanchitmalhotra126 I was assuming there would be outstanding work here to include the new MetricsReporter but it looks like there isn't because the file that originally used the Music version of the reporter is no longer needed and the reporting functionality is built into the Lab2 framework (see original comment here). Does that sound right?

Yep correct! This was replaced with a top-level Lab2MetricsReporter whose reporting functions can be called directly from lab code when needed.

@molly-moen molly-moen left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 thanks for incorporating all the lab2 stuff as it was hot off the presses!

@sanchitmalhotra126 sanchitmalhotra126 left a comment

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🎉 awesome! Very cool to see a new app onboarded onto the Lab2 framework so quickly, and thanks for bearing with our updates!

Comment thread apps/src/lab2/types.ts
Comment on lines +112 to +113
// TODO: Add AichatLevelData.

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Note that if AichatLevelData extends ProjectLevelData, it would probably be better to define the type within the aichat directory (like MusicLevelData, defined in music/types), so that the lab-specific level data definition can be closer to the lab that's using it

Copy link
Copy Markdown
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the feedback! I'll call this out in Slack for the fast-follow PRs, but I didn't move the comment for now, because I'm eager to get this into staging.

@ebeastlake ebeastlake merged commit 0e458f8 into staging Jul 20, 2023
@ebeastlake ebeastlake deleted the task/initial-chat-levels branch July 20, 2023 16:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

4 participants