diff --git a/packages/vscode-extension/src/officeChat/common/skills/codeGenerator.ts b/packages/vscode-extension/src/officeChat/common/skills/codeGenerator.ts index a6b62b68ef..baf6dfd8c1 100644 --- a/packages/vscode-extension/src/officeChat/common/skills/codeGenerator.ts +++ b/packages/vscode-extension/src/officeChat/common/skills/codeGenerator.ts @@ -98,8 +98,7 @@ export class CodeGenerator implements ISkill { } } - // Always generate the breakdown - { + if (!spec.appendix.codeTaskBreakdown || !spec.appendix.codeExplanation) { const t0 = performance.now(); const breakdownResult = await this.userAskBreakdownAsync( token, @@ -134,6 +133,11 @@ export class CodeGenerator implements ISkill { } spec.appendix.codeTaskBreakdown = breakdownResult.funcs; spec.appendix.codeExplanation = breakdownResult.spec; + response.markdown(` +${spec.appendix.codeExplanation + .substring(spec.appendix.codeExplanation.indexOf("1.")) + .replace(/\b\d+\./g, (match) => `\n${match}`)} +`); } if (!spec.appendix.telemetryData.measurements[MeasurementCodeGenAttemptCount]) { spec.appendix.telemetryData.measurements[MeasurementCodeGenAttemptCount] = 0; diff --git a/packages/vscode-extension/src/officeChat/common/skills/printer.ts b/packages/vscode-extension/src/officeChat/common/skills/printer.ts index a92276173f..aad86d0346 100644 --- a/packages/vscode-extension/src/officeChat/common/skills/printer.ts +++ b/packages/vscode-extension/src/officeChat/common/skills/printer.ts @@ -35,9 +35,6 @@ export class Printer implements ISkill { spec: Spec ): Promise<{ result: ExecutionResultEnum; spec: Spec }> { const template = ` -${spec.appendix.codeExplanation - .substring(spec.appendix.codeExplanation.indexOf("1.")) - .replace(/\b\d+\./g, (match) => `\n${match}`)}\n ${localize("teamstoolkit.chatParticipants.officeAddIn.printer.outputTemplate.codeIntro")}\n \`\`\`typescript ${spec.appendix.codeSnippet} diff --git a/packages/vscode-extension/test/officeChat/common/skills/codeGenerator.test.ts b/packages/vscode-extension/test/officeChat/common/skills/codeGenerator.test.ts index c03e95f69d..45a7d8a8af 100644 --- a/packages/vscode-extension/test/officeChat/common/skills/codeGenerator.test.ts +++ b/packages/vscode-extension/test/officeChat/common/skills/codeGenerator.test.ts @@ -802,7 +802,7 @@ describe("codeGenerator", () => { }); sandbox.stub(codeGenerator, "userAskBreakdownAsync").resolves({ - spec: "some host", + spec: "some host 1. point 1. 2. point 2.", funcs: ["some data"], }); sandbox.stub(codeGenerator, "generateCode").resolves("code sample"); diff --git a/packages/vscode-extension/test/officeChat/common/skills/printer.test.ts b/packages/vscode-extension/test/officeChat/common/skills/printer.test.ts index 2446b14393..5ffa637c38 100644 --- a/packages/vscode-extension/test/officeChat/common/skills/printer.test.ts +++ b/packages/vscode-extension/test/officeChat/common/skills/printer.test.ts @@ -26,7 +26,7 @@ describe("printer", () => { spec.appendix = { host: "some host", codeSnippet: "some code", - codeExplanation: "some explanation 1. point 1.", + codeExplanation: "some explanation", codeTaskBreakdown: ["task1", "task2"], codeSample: "", apiDeclarationsReference: new Map(),