Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: aila instantiation includes option to specify a schema and categorisation approach #576

Open
wants to merge 21 commits into
base: main
Choose a base branch
from

Conversation

stefl
Copy link
Contributor

@stefl stefl commented Mar 4, 2025

Description

  • Continues on the move from Aila being specific to a lesson plan to supporting any kind of document
  • Allows us to pass in a schema that Aila should work with
  • Allows us to pass in an optional categoriser which would set up the document with initial values based on the user's first message(s)
  • Includes one categoriser plugin for Lesson Plans, which would not be used if not specified when instantiating the Aila instance. TBH I think we should be removing the categoriser anyway, but this keeps it in for now.

Copy link

vercel bot commented Mar 4, 2025

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Comments Updated (UTC)
oak-ai-lesson-assistant ✅ Ready (Inspect) Visit Preview 💬 Add feedback Mar 6, 2025 4:32pm

Copy link

github-actions bot commented Mar 4, 2025

Playwright test results

passed  17 passed
skipped  2 skipped

Details

report  Open report ↗︎
stats  19 tests across 16 suites
duration  2 minutes, 35 seconds
commit  460bb9c

Skipped tests

No persona › tests/auth.test.ts › authenticate through Clerk UI
No persona › tests/chat-performance.test.ts › Component renders during lesson chat › There are no unnecessary rerenders across left and right side of chat

@@ -218,26 +237,66 @@ export class AilaChat implements AilaChatService {
return applicableMessages;
}

// #TODO this is the other part of the initial lesson state setting logic
Copy link
Contributor Author

Choose a reason for hiding this comment

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

Addresses this TODO about making the initial categorisation step something pluggable / specific to the type of document we are trying to create

document: {
content: dbLessonPlan ?? {},
schema: LessonPlanSchema,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is the main starting point. We want to pass in a schema that we want to work with.

document: {
content: dbLessonPlan ?? {},
schema: LessonPlanSchema,
categorisationPlugin: (aila: AilaServices) =>
Copy link
Contributor Author

Choose a reason for hiding this comment

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

And an optional categorisation plugin

@stefl stefl changed the title feat: aila instantiation includes option to specify a schema and categorisation approach feat: aila instantiation includes option to specify a schema and categorisation approach (WIP) Mar 4, 2025
@stefl stefl changed the title feat: aila instantiation includes option to specify a schema and categorisation approach (WIP) feat: aila instantiation includes option to specify a schema and categorisation approach Mar 4, 2025
@stefl stefl requested a review from a team March 4, 2025 19:12
document: { content: {} },
document: {
content: {},
schema: LessonPlanSchema,
Copy link
Contributor Author

Choose a reason for hiding this comment

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

This is where we say what kind of document we want the Aila instance to deal with.

Copy link

sonarqubecloud bot commented Mar 4, 2025

Comment on lines +129 to +135
ailaInstance.document.content = {
...ailaInstance.document.content,
title: "Roman Britain",
subject: "history",
keyStage: "key-stage-2",
topic: "The Roman Empire",
};
Copy link
Collaborator

Choose a reason for hiding this comment

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

It would be useful to have a comment explaining this, as it seems to be overwriting the result of the test

Comment on lines +251 to +254
/**
* Ensures values are safe to use in enqueuePatch using Zod validation
* with a maximum recursion depth to prevent stack overflow
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is starting to feel too specific to live in the AilaChat module. Do we need a module relating to initial state?

}
}

return hasValidProperties ? result : undefined;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I think you can drop hasValidProperties by using Object.keys(result).length ? result : undefined

That also opens up more functional options to build the object like a map and filter - though that's a code style thing

@@ -260,7 +323,10 @@ export class AilaChat implements AilaChatService {
if (!warning) {
return;
}
await this.enqueue({ type: "prompt", message: warning });
// Optional "?" Necessary to avoid a "terminated" error
Copy link
Collaborator

Choose a reason for hiding this comment

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

This is new to me. Are you saying that this can be undefined?

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Yes I was surprised too. The instance detaches when it's removed, and so this no longer exists, or something like that? This is just reinserting a comment that should have been there to match the others. No code change


const log = aiLogger("aila");

class TestDocument {
Copy link
Collaborator

Choose a reason for hiding this comment

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

This file could do with a comment explaining what it does, as as far as I can tell it's defining a local class which isn't used in the codebase (yet?) and then testing it

Comment on lines +80 to +83
/**
* Get the appropriate plugin for the content
* Since we now only register one plugin, we just return the first one
*/
Copy link
Collaborator

Choose a reason for hiding this comment

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

If we're only using one plugin, and it only works if there is one plugin, should we just support one plugin?

A bit of an embarrassing question, but what actually is a plugin? I can't find where it's being applied in the calling code

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.

2 participants