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: further migration steps towards AilaDocument #571

Merged
merged 7 commits into from
Mar 3, 2025
Merged

Conversation

stefl
Copy link
Contributor

@stefl stefl commented Feb 28, 2025

Description

  • This goes further with the process of getting Aila to support the generation of different types of document
  • Introduces an AilaDocumentContent type, which is a compound type of our existing lesson plan and a dummy type that is currently unused
  • Makes some methods generic (snapshots, americanisms) so that they can handle different types of document

No user-facing changes. No data migrations.

Copy link

vercel bot commented Feb 28, 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 3, 2025 11:19am

@@ -13,7 +13,7 @@ const runManually = process.env.RUN_LLM_TESTS === "true";

beforeEach(() => {
ailaInstance = new Aila({
lessonPlan: {},
document: { content: {} },
Copy link
Contributor Author

Choose a reason for hiding this comment

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

My thinking here is that we will probably want to pass a schema, a version, some metadata. So the document content probably needs to have this extra level of abstraction.

@@ -0,0 +1,11 @@
import type { LooseLessonPlan } from "../../protocol/schema";

export type AilaDummyDocumentContent = {
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 an example of a different type of document that Aila could produce.

I think we will probably want a discriminating "type" attribute so we can use Zod to do a discriminated union. Not implemented yet because that would change the shape of the LooseLessonPlan.

export class AilaAmericanisms implements AilaAmericanismsFeature {
export type AilaDocumentContent = Record<string, unknown>;

export class AilaAmericanisms<T extends AilaDocumentContent>
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 removes the association with the lesson plan and treats it as an unknown object.

@@ -12,7 +13,7 @@ import type { AilaThreatDetector } from "./threatDetection";
export interface AilaModerationFeature {
moderate(options: {
messages: Message[];
lessonPlan: LooseLessonPlan;
content: AilaDocumentContent;
Copy link
Contributor Author

Choose a reason for hiding this comment

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

The moderation feature now just accepts some arbitrary content.

Copy link

github-actions bot commented Feb 28, 2025

Playwright test results

passed  17 passed
skipped  2 skipped

Details

report  Open report ↗︎
stats  19 tests across 16 suites
duration  2 minutes, 26 seconds
commit  4710175

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

Comment on lines 1 to 8
To do list for migrating the Aila package from just handling lessons, to allow it it handle different types of document.

## Snapshots

We need to generate a JSON schema for each document type.

## Schemas for documents
The document schemas should be in the Aila package, and move out of protocol.
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should we move this to notion? Maybe it belongs in an epic or an Aila Engineering Knowledge age

Copy link
Contributor Author

Choose a reason for hiding this comment

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

Ah yes - I spotted this had slipped in. It was a temporary file I thought I'd ignored!

Comment on lines +45 to +58
public get content(): AilaDocumentContent {
return this._content;
}

public set plan(plan: LooseLessonPlan) {
this._plan = plan;
public set content(content: AilaDocumentContent) {
this._content = content;
}

public setPlan(plan: LooseLessonPlan) {
this._plan = plan;
public setContent(content: AilaDocumentContent) {
this._content = content;
}

public get hasSetInitialState(): boolean {
return this._hasSetInitialState;
}

public set hasSetInitialState(value: boolean) {
this._hasSetInitialState = value;
public get hasInitialisedContentFromMessages(): boolean {
return this._hasInitialisedContentFromMessages;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I've always wondered if these could be defined as setters and getters. But changing something like that would be out of scope for a rename like this so let's ignore this comment!

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree on this - we seem to have setPlan and also set plan. Probably quite easy to remove the setPlan method!

Copy link
Collaborator

@codeincontext codeincontext left a comment

Choose a reason for hiding this comment

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

Great work

@stefl stefl changed the title feat: AilaDocument: further migration steps feat: further migration steps towards AilaDocument Mar 3, 2025
Copy link

sonarqubecloud bot commented Mar 3, 2025

@stefl stefl merged commit 4764d0e into main Mar 3, 2025
18 checks passed
@stefl stefl deleted the feat/aila_doc_2 branch March 3, 2025 11:30
@oak-machine-user
Copy link
Collaborator

🎉 This PR is included in version 1.26.0 🎉

The release is available on GitHub release

Your semantic-release bot 📦🚀

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

3 participants