Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

fix(chat): string #11505

Merged
merged 9 commits into from
May 17, 2024
Merged
Show file tree
Hide file tree
Changes from 5 commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Jump to
Jump to file
Failed to load files.
Diff view
Diff view
2 changes: 1 addition & 1 deletion packages/vscode-extension/package.nls.json
Original file line number Diff line number Diff line change
Expand Up @@ -468,7 +468,7 @@
"teamstoolkit.chatParticipants.nextStep.whatsNext": "What should I do next?",
"teamstoolkit.chatParticipants.create.sample": "Scaffold this sample",
"teamstoolkit.chatParticipants.create.template": "Create this template",
"teamstoolkit.chatParticipants.create.tooGeneric": "Your app description is too generic. To find relevant templates or samples, give specific details of your app's capabilities or technologies.\n\nE.g. Instead of saying 'create a chat bot', you could specify 'create a chat bot that answers FAQs for customer support.'",
"teamstoolkit.chatParticipants.create.tooGeneric": "Your app description is too generic. To find relevant templates or samples, give specific details of your app's capabilities or technologies.\n\nE.g. Instead of saying 'create a bot', you could specify 'create a bot template' or 'create a notification bot that sends user about stock updates'.",
tecton marked this conversation as resolved.
Show resolved Hide resolved
"teamstoolkit.chatParticipants.create.oneMatched": "We've found 1 project that matches your description. Take a look at it below.\n\n",
"teamstoolkit.chatParticipants.create.multipleMatched": "We've found %d projects that match your description. Take a look at them below.\n",
"teamstoolkit.chatParticipants.create.noMatched": "I cannot find any matching templates or samples. Refine your app description or explore other templates.",
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -45,8 +45,11 @@ export async function matchProject(
if (!request.prompt.includes("template")) {
// also search in samples
matchedProjects.push(...(await matchSamples(request, token, telemetryMetadata)));
matchedProjects.sort((a, b) => b.score - a.score);
} else {
matchedProjects.sort((a, b) => b.score - a.score);
matchedProjects.splice(2);
}
matchedProjects.sort((a, b) => b.score - a.score);
const result: ProjectMetadata[] = [];
const matchedProjectIds = new Set<string>();
for (const { id, score } of matchedProjects) {
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -282,7 +282,7 @@ describe("chat create command", () => {
chai.assert.isTrue(showFileTreeStub.notCalled);
chai.assert.isTrue(
response.markdown.calledOnceWith(
"Your app description is too generic. To find relevant templates or samples, give specific details of your app's capabilities or technologies.\n\nE.g. Instead of saying 'create a chat bot', you could specify 'create a chat bot that answers FAQs for customer support.'"
"Your app description is too generic. To find relevant templates or samples, give specific details of your app's capabilities or technologies.\n\nE.g. Instead of saying 'create a bot', you could specify 'create a bot template' or 'create a notification bot that sends user about stock updates'."
tecton marked this conversation as resolved.
Show resolved Hide resolved
)
);
});
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,47 @@ describe("chat create helper", () => {
chai.assert.strictEqual(result.length, 1);
chai.assert.strictEqual(result[0].id, "test1");
});

it("has matched template project", async () => {
const chatTelemetryDataMock = sandbox.createStubInstance(telemetry.ChatTelemetryData);
sandbox.stub(chatTelemetryDataMock, "properties").get(function getterFn() {
return undefined;
});
sandbox.stub(chatTelemetryDataMock, "measurements").get(function getterFn() {
return undefined;
});
sandbox.stub(sampleProvider, "SampleCollection").get(function getterFn() {
return {
samples: [
{
id: "test1",
title: "test1",
fullDescription: "test1",
},
],
};
});
chatTelemetryDataMock.chatMessages = [];
sandbox
.stub(telemetry.ChatTelemetryData, "createByParticipant")
.returns(chatTelemetryDataMock);
const sendTelemetryEventStub = sandbox.stub(ExtTelemetry, "sendTelemetryEvent");
sandbox
.stub(util, "getCopilotResponseAsString")
.onFirstCall()
.resolves('{"app":[{"id": "bot", "score": 1.0}]}')
.onSecondCall()
.resolves('{"app":[{"id": "test2", "score": 0.5}]}');

const token = new CancellationToken();
const result = await helper.matchProject(
{ prompt: "test template" } as vscode.ChatRequest,
token,
chatTelemetryDataMock
);
chai.assert.strictEqual(result.length, 1);
chai.assert.strictEqual(result[0].id, "bot");
});
});

describe("showFileTree()", () => {
Expand Down