-
Notifications
You must be signed in to change notification settings - Fork 0
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: add categoriser to fixtures in tests, fix streaming bugs (WIP) #323
base: fix/dropdown_sections
Are you sure you want to change the base?
Conversation
The latest updates on your projects. Learn more about Vercel for Git ↗︎
|
moderationAiClient, | ||
ragService: (aila: AilaServices) => new AilaRag({ aila }), | ||
chatCategoriser: (aila: AilaServices) => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pass in the categoriser at initialisation, in the same way we do with the other features
@@ -26,5 +26,7 @@ export const defaultConfig: Config = { | |||
userId: undefined, | |||
}, | |||
}); | |||
await createdAila.initialise(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ensure that the Aila instance is initialised
topic: "Basics and Advanced Techniques", | ||
}, | ||
}), | ||
chatCategoriser: () => |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A slight change to how we initialise the categoriser
packages/aila/src/core/Aila.ts
Outdated
@@ -123,15 +122,38 @@ export class Aila implements AilaServices { | |||
this._plugins = options.plugins; | |||
} | |||
|
|||
private checkInitialised() { | |||
if (!this._initialised) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
For our own sanity, throw an error if we try to use methods that rely on initialisation
if ( | ||
!sections.includes("title") || | ||
!sections.includes("subject") || | ||
!sections.includes("keyStage") |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We don't care about topic because it's optional
!sections.includes("subject") || | ||
!sections.includes("keyStage") | ||
) { | ||
await this._lesson.setUpInitialLessonPlan(this._chat.messages); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This was the bug that was causing repeated categorisations
await this.moderate(); | ||
await this.persistChat(); | ||
await this.persistGeneration("SUCCESS"); | ||
await Promise.all([ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
We can parallelise these
try { | ||
await this._chat.setupGeneration(); | ||
this.logStreamingStep("Setup generation complete"); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
In the absence of tracing, these help understand what's happening during streaming and how long each step is taking
@@ -87,4 +94,31 @@ export class OpenAIService implements LLMService { | |||
|
|||
return newStream.getReader(); | |||
} | |||
|
|||
async generateObject<T>({ |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
A new method that we can use for categorisation etc. that uses structured outputs
@@ -0,0 +1,10 @@ | |||
import type { LessonPlanKeys, LooseLessonPlan } from "../../protocol/schema"; | |||
|
|||
export const completedSections = ( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Helper to list the keys that have values on the lesson plan
content: "Respond to the user and help them edit the lesson plan", | ||
}; | ||
const nextStep = allSteps[0] ?? finalStep; | ||
const step = `${nextStep.title}\n\n${nextStep.content}`; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Reduces noisy logging during streaming
.nullable() | ||
.describe("The reasoning behind the categorisation"), | ||
keyStage: z | ||
.enum([...keyStages] as [string, ...string[]]) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
More tightly specify the valid options for categorisation
Quality Gate passedIssues Measures |
build: release candidate
build: release candidate
build: release candidate
build: release posthog hotfix
build: release candidate
Description
Waiting to merge the streaming UX PR before continuing on this