feat(python-notebook-migration): add LLM client for notebook-to-workflow conversion - #5260
Conversation
Codecov Report❌ Patch coverage is
Additional details and impacted files@@ Coverage Diff @@
## main #5260 +/- ##
============================================
- Coverage 54.81% 54.64% -0.18%
+ Complexity 2958 2918 -40
============================================
Files 1115 1111 -4
Lines 43019 42919 -100
Branches 4633 4623 -10
============================================
- Hits 23580 23452 -128
- Misses 18053 18097 +44
+ Partials 1386 1370 -16
*This pull request uses carry forward flags. Click here to find out more. ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
|
/request-review @mengw15 |
Automated Reviewer SuggestionsBased on the
|
mengw15
left a comment
There was a problem hiding this comment.
A couple of cleanups on migration-prompts.ts
mengw15
left a comment
There was a problem hiding this comment.
Two more comments on migration-llm.ts
There was a problem hiding this comment.
Pull request overview
Adds a frontend notebook-migration LLM client that calls Texera’s LiteLLM proxy to convert Jupyter notebooks into Texera workflow JSON, alongside a prompt library and unit tests.
Changes:
- Introduces
NotebookMigrationLLMAngular service to run a 2-step LLM flow (workflow JSON + cell↔operator mapping) and assemble a Texera workflow payload. - Adds a prompt-constant library used to seed the LLM session with Texera/UDF documentation and conversion instructions.
- Adds Vitest unit tests for JSON parsing and deterministic workflow/mapping construction, and wires in
@ai-sdk/openai.
Reviewed changes
Copilot reviewed 4 out of 5 changed files in this pull request and generated 13 comments.
Show a summary per file
| File | Description |
|---|---|
| frontend/package.json | Adds @ai-sdk/openai dependency used by the new migration client. |
| frontend/yarn.lock | Locks the added @ai-sdk/openai dependency. |
| frontend/src/app/workspace/service/notebook-migration/migration-prompts.ts | Adds the prompt/documentation constants for notebook-to-workflow conversion. |
| frontend/src/app/workspace/service/notebook-migration/migration-llm.ts | Implements the notebook migration LLM session, prompting, parsing, and workflow/mapping assembly. |
| frontend/src/app/workspace/service/notebook-migration/migration-llm.spec.ts | Adds unit tests for parsing and conversion behavior with mocked LLM transport. |
💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.
mengw15
left a comment
There was a problem hiding this comment.
Left a follow-up note on Copilot's apiKey/JWT comment.
There was a problem hiding this comment.
LGTM. Every substantive point from prior rounds (both mine and Copilot's) is addressed in this iteration — a few highlights:
- JWT auth wired through
AuthService.getAccessToken()with a clear comment explaining the AI-SDK-Authorization-header / backend-master-key-substitution split. seedDocumentation()extracted and called at the start of eachconvertNotebookToWorkflow, so the same instance can convert multiple notebooks without cross-conversion context leakage.- The binary-attributeType follow-up resolved cleverly: intermediate UDFs (those that are an edge source) keep
binaryso rich objects round-trip via pickle, terminal UDFs default tostringso the result panel renders typed values. Better than just flipping the default.
| "private": true, | ||
| "dependencies": { | ||
| "@abacritt/angularx-social-login": "2.3.0", | ||
| "@ai-sdk/openai": "2.0.67", |
There was a problem hiding this comment.
Thanks for pointing this out, we missed it during the development and review phase. We should fix it and change the LICENSE file if it is necessary.
I am currently traveling and do not have reliable Internet connection, if anything requires an urgent fix please work with @mengw15 , otherwise I will fix it when I am back.
There was a problem hiding this comment.
I looked into it, the reason we didn't need to change LICENSE-binary even though we added a new dependency is because there's no consumer for this code in main right now (we're merging the whole tool incrementally across multiple PRs). The license checker diffs against what the production build actually bundles, and with no consumer the migration client is tree-shaken out, so @ai-sdk/openai never reaches the bundle. When the consumer is merged in #5273, it'll be bundled and we'll add it to LICENSE-binary then.
What changes were proposed in this PR?
Introduces the frontend LLM session class that converts a Jupyter notebook into a Texera workflow JSON plus a bidirectional cell to operator mapping, along with the prompt library it uses. Two files under
frontend/src/app/workspace/service/notebook-migration/, totalling ~700 lines (~410 of which is prompt text).migration-llm.ts— definesNotebookMigrationLLM, an@Injectableclass wrapping a Vercel AI SDK chat session against the LiteLLM proxy already exposed onmainat/api/chat/completion.initialize(modelType, apiKey)— builds an OpenAI-compatible chat client viacreateOpenAI({ baseURL: AppSettings.getApiEndpoint() }), seeds the message history with Texera documentation assystemmessages.verifyConnection()— does a 10-tokenpingcall to validate that the API key works against the configured model.convertNotebookToWorkflow(notebook)— extracts code cells (each tagged with a UUID inmetadata.uuid), sendsWORKFLOW_PROMPT+ the notebook to get a JSON of UDF operators / edges, then sendsMAPPING_PROMPTto get the cell↔operator mapping. Assembles a complete Texera workflow JSON (PythonUDFV2operators with stub input/output ports, links derived from the LLM's edge list, default settings) plus a bidirectionaloperator_to_cell/cell_to_operatormapping. Returns both as a JSON string.close()— clears the message history and the model reference.migration-prompts.ts— string constants used bymigration-llm.ts:TEXERA_OVERVIEW,TUPLE_DOCUMENTATION,TABLE_DOCUMENTATION,OPERATOR_DOCUMENTATION,UDF_INPUT_PORT_DOCUMENTATION,EXAMPLE_OF_GOOD_CONVERSION,VISUALIZER_DOCUMENTATION,EXAMPLE_OF_MULTIPLE_UDF_CONVERSION,WORKFLOW_PROMPT,MAPPING_PROMPT.Any related issues, documentation, discussions?
Closes #5259
Parent issue #4301
How was this PR tested?
No unit tests were included for these reasons:
migration-llm.tsis parsing a response.However I am open to writing tests based on review feedback.
Was this PR authored or co-authored using generative AI tooling?
Generated-by: Claude Code (Claude Opus 4.7)