Skip to content

Conversation

@sourishkrout
Copy link

@sourishkrout sourishkrout commented Dec 6, 2025

As discussed, this PR introduces runnable code blocks that replay VCR.py cassettes (cached HTTP) directly. In it's current implementation it works with both request/streaming Anthropic responses. There's ground work to add other SDK's API responses but it's not complete. Check out the short video demo below.

I've addressed almost all relevant review feedback in #331.

While there's a bun run lint:cassettes --strict mode now that alerts for missing cassettes, it's not default yet. The idea is to make strict default and further close the gap to @teamdandelion's goals here #331 (review) in a separate effort. The presence of a cassette per code-block currently toggles if a run button is shown, which is why there's no "pending state" on every code block's run button yet until VCR cassettes are ubiquitous.

PS: Heads up, I had to upgrade to latest bun v1.3.3 which just released DecompressionStream support last week.

Pending items:

  • Upstream the mirascope-ui components.
  • Sync latest examples with mirascope repo
  • Figure out how to display format tool example
  • Fix context prompts & tools
  • Make this PR mergeable short-term before working on a run button everywhere rollout
  • Add tracking event in AnalyticsCodeBlock for running code
  • Nuking RunnableContext.tsx and pyodide worker files. If this PR is squashed, I'd rather remove them in a separate PR to leave a record in the git history.

Video

replay.mp4

Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
…s done

Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
… display it

Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
@sourishkrout
Copy link
Author

Based on my notes, this is ready for review, @willbakst & @teamdandelion.

I assume https://github.com/Mirascope/ui remains relevant. Once we've got a thumbs on the review, I'll upstream the relevant code-block and run-button components and remove anything unused from the AI UI SDK.

Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
Copy link
Collaborator

@teamdandelion teamdandelion left a comment

Choose a reason for hiding this comment

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

Some general comments. A little unclear on what the scope is now. Going to ask you about it offline

Comment on lines 50 to 55
"content/docs/mirascope/v2/examples/**/*.{yaml,py}": [
"bun scripts/validate-cassettes.ts"
],
"cassettes/**/*.{yaml,py}": [
"bun scripts/validate-cassettes.ts"
],
Copy link
Collaborator

Choose a reason for hiding this comment

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

Is there a reason to prefer invoking directly vs bun run lint:cassettes? I feel like bun run lint:cassetes is more dry. Also is there a reason we have bun [script] here vs bun run [script] above?

Copy link
Author

Choose a reason for hiding this comment

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

🙈! I didn't even see that the run was missing. Definitely a mistake. I'm surprised this works.

Thanks for the catch!

}

// Default glob pattern validation (runs if no targetFile or targetFile is not a .py file)
const defaultGlobPattern = "content/docs/mirascope/v2/examples/**/*.py";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I notice we're hardcoding this in a few places, feels like a bit of a smell. Wonder if it might make sense to pull these all out of the commands and provide them as args in package.json

@@ -0,0 +1,123 @@
"use client";
Copy link
Collaborator

Choose a reason for hiding this comment

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

I don't feel super strongly about this, but I notice once again we're pulling in all of the ai-elements even thoujgh I don't think we'll use them all (and some are redundant w. our own components like code-block)

Copy link
Author

Choose a reason for hiding this comment

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

I'll remove the excess components from this branch. Originally planned to do this as part of upstreaming into mirascope-ui which I understand now will no longer be required.

Comment on lines +18 to +24
import type {
WorkerRequest,
WorkerResponse,
WorkerStreamEvent,
} from "@/src/workers/pyodide-worker-types";

const DEFAULT_PYODIDE_URL = `https://cdn.jsdelivr.net/pyodide/v${version}/full/`;
Copy link
Collaborator

Choose a reason for hiding this comment

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

I thought we were moving away from the pyodide based approach? Do we use this code or are we bringing it in eagerly?

Copy link
Author

Choose a reason for hiding this comment

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

Correct. As per the description, I want to make sure a potential git-squash won't deprive the history of Pyodide/WASM should they become relevant again.

Signed-off-by: Sebastian (Tiedtke) Huckleberry <[email protected]>
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