zyratlo commented on code in PR #8910:
URL: https://github.com/apache/texera/pull/8910#discussion_r4330335986


##########
frontend/src/app/workspace/service/notebook-migration/migration-llm.spec.ts:
##########
@@ -316,6 +331,74 @@ describe("NotebookMigrationLLM", () => {
     });
   });
 
+  describe("Python prompts", () => {
+    const workflowResponse = JSON.stringify({ code: { UDF1: "# UDF1" }, edges: 
[], outputs: {} });
+    const documentation = [
+      TEXERA_OVERVIEW,
+      TUPLE_DOCUMENTATION,
+      TABLE_DOCUMENTATION,
+      OPERATOR_DOCUMENTATION,
+      EXAMPLE_OF_GOOD_CONVERSION,
+      VISUALIZER_DOCUMENTATION,
+      UDF_INPUT_PORT_DOCUMENTATION,
+      EXAMPLE_OF_MULTIPLE_UDF_CONVERSION,
+    ];
+
+    function contentsFor(role: string): string[] {
+      return (callModelSpy.mock.calls[0][0] as { role: string; content: string 
}[])
+        .filter(message => message.role === role)
+        .map(message => message.content);
+    }

Review Comment:
   The tests are correct. Every model call receives the same shared `messages` 
array, so the first call's argument already holds the mapping prompt when the 
test reads it. Added a comment on the helper saying so. Added a comment in 
[55f56c8](https://github.com/apache/texera/pull/8910/commits/55f56c89942e529be47869c9582c290dae833375)
 so that this is cleared up



##########
frontend/src/app/workspace/service/notebook-migration/migration-llm.spec.ts:
##########
@@ -316,6 +331,74 @@ describe("NotebookMigrationLLM", () => {
     });
   });
 
+  describe("Python prompts", () => {
+    const workflowResponse = JSON.stringify({ code: { UDF1: "# UDF1" }, edges: 
[], outputs: {} });
+    const documentation = [
+      TEXERA_OVERVIEW,
+      TUPLE_DOCUMENTATION,
+      TABLE_DOCUMENTATION,
+      OPERATOR_DOCUMENTATION,
+      EXAMPLE_OF_GOOD_CONVERSION,
+      VISUALIZER_DOCUMENTATION,
+      UDF_INPUT_PORT_DOCUMENTATION,
+      EXAMPLE_OF_MULTIPLE_UDF_CONVERSION,
+    ];
+
+    function contentsFor(role: string): string[] {
+      return (callModelSpy.mock.calls[0][0] as { role: string; content: string 
}[])
+        .filter(message => message.role === role)
+        .map(message => message.content);
+    }
+
+    it("sends the notebook prelude and prompts unchanged", async () => {
+      mockResponses(workflowResponse, JSON.stringify({ UDF1: ["CELL1"] }));
+
+      await makeLLM().convertNotebookToWorkflow({ cells: [codeCell("CELL1", 
"print(1)")] });
+
+      expect(contentsFor("system")).toEqual(documentation);
+      const [workflowPrompt, mappingPrompt] = contentsFor("user");
+      expect(workflowPrompt.startsWith(`${WORKFLOW_PROMPT}\n`)).toBe(true);
+      expect(mappingPrompt).toBe(MAPPING_PROMPT);

Review Comment:
   The tests are correct. Every model call receives the same shared `messages` 
array, so the first call's argument already holds the mapping prompt when the 
test reads it. Added a comment on the helper saying so. Added a comment in 
[55f56c8](https://github.com/apache/texera/pull/8910/commits/55f56c89942e529be47869c9582c290dae833375)
 so that this is cleared up



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: [email protected]

For queries about this service, please contact Infrastructure at:
[email protected]

Reply via email to