Skip to content

Commit

Permalink
fix: fix streaming output behavior
Browse files Browse the repository at this point in the history
  • Loading branch information
GavinGu07 committed Jun 20, 2024
1 parent 1298178 commit a9362e8
Show file tree
Hide file tree
Showing 4 changed files with 8 additions and 7 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -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,
Expand Down Expand Up @@ -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;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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");
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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<string, SampleData>(),
Expand Down

0 comments on commit a9362e8

Please sign in to comment.