Skip to content

Conversation

@SonicScrewdriver
Copy link
Contributor

@SonicScrewdriver SonicScrewdriver commented Dec 4, 2025

Summary:

This PR moves getAnswersFromWidget, injectWidgets, and a handful of helper functions to Perseus Core so that they are available for the Perseus service. We will be creating a new API endpoint to call these functions, so that we can support Khanmigo's move to keeping answerful data server-side.

It also created the new getPerseusAIData function, which will be used for the new API Endpoint.

I'm happy to take any direction on the name, as "getPromptJSON" didn't feel the most descriptive or correct to myself or the AI team. I don't feel like I've nailed the perfect name either, but it seemed clearer at least.

Issue: LEMS-3766

Test plan:

  • Tests pass
  • Tests pass upstream
  • Integration works upstream

…re for Server Side Scoring initiative

This PR moves getAnswersFromWidget, injectWidgets, and a handful of helper functions to Perseus Core so that they are available for the Perseus service. We will be creating a new API endpoint to call these functions, so that we can support Khanmigo's move to keeping answerful data server-side.

It also created the new getPerseusAIData function, which will be used for the new API Endpoint.

Issue: LEMS-3766

Test plan:
Tests pass
@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

🗄️ Schema Change: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

🛠️ Item Splitting: No Changes ✅

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

Size Change: +48 B (+0.01%)

Total Size: 499 kB

Filename Size Change
packages/perseus-core/dist/es/index.js 24.7 kB +2.1 kB (+9.31%) 🔍
packages/perseus/dist/es/index.js 200 kB -2.06 kB (-1.02%)
ℹ️ View Unchanged
Filename Size
packages/kas/dist/es/index.js 20.8 kB
packages/keypad-context/dist/es/index.js 1 kB
packages/kmath/dist/es/index.js 5.98 kB
packages/math-input/dist/es/index.js 99.2 kB
packages/math-input/dist/es/strings.js 1.61 kB
packages/perseus-core/dist/es/index.item-splitting.js 13.1 kB
packages/perseus-editor/dist/es/index.js 98.2 kB
packages/perseus-linter/dist/es/index.js 8.64 kB
packages/perseus-score/dist/es/index.js 9.2 kB
packages/perseus-utils/dist/es/index.js 403 B
packages/perseus/dist/es/strings.js 7.73 kB
packages/pure-markdown/dist/es/index.js 1.39 kB
packages/simple-markdown/dist/es/index.js 6.72 kB

compressed-size-action

@github-actions
Copy link
Contributor

github-actions bot commented Dec 4, 2025

npm Snapshot: Published

Good news!! We've packaged up the latest commit from this PR (fbcbdbd) and published it to npm. You
can install it using the tag PR3091.

Example:

pnpm add @khanacademy/perseus@PR3091

If you are working in Khan Academy's frontend, you can run the below command.

./dev/tools/bump_perseus_version.ts -t PR3091

If you are working in Khan Academy's webapp, you can run the below command.

./dev/tools/bump_perseus_version.js -t PR3091

expect(content).toEqual("Content with a radio\nchoice 1\nchoice 2");
});

it("should inject radio widget into the content with randomization note", () => {
Copy link
Contributor Author

@SonicScrewdriver SonicScrewdriver Dec 5, 2025

Choose a reason for hiding this comment

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

We could solve this randomization note eventually, but it would require us to pass in the shuffle seed data and translated strings - so we'll look into that at some point in the future.

… widget, after discovering we're missing a few others.
@@ -0,0 +1,629 @@
import {keys} from "@khanacademy/wonder-stuff-core";

import type {
Copy link
Contributor Author

Choose a reason for hiding this comment

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

These were directly moved from extract-perseus-data.

return context;
}

/**
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 new function for our AI to use.

@SonicScrewdriver SonicScrewdriver marked this pull request as ready for review December 5, 2025 19:33
Copy link
Contributor

@handeyeco handeyeco left a comment

Choose a reason for hiding this comment

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

My understanding is that this mostly just moving things which is good to me!

We added getPerseusAIData. Would it be worth adding a simple test for that? (Or maybe there is one and I didn't see it)

@SonicScrewdriver
Copy link
Contributor Author

My understanding is that this mostly just moving things which is good to me!

We added getPerseusAIData. Would it be worth adding a simple test for that? (Or maybe there is one and I didn't see it)

@handeyeco Yes! There's some tests in the new test file, but I think github likes to hide it until you explicitly expand it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Projects

None yet

Development

Successfully merging this pull request may close these issues.

3 participants