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

feat(copilot): optimize namespace for export to playground VSCODE-654 #887

Merged
merged 3 commits into from
Dec 3, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion package.json
Original file line number Diff line number Diff line change
Expand Up @@ -970,7 +970,7 @@
"submenus": [
{
"id": "mdb.copilot",
"label": "MongoDB Copilot Participant"
"label": "MongoDB Copilot Extension"
}
],
"keybindings": [
Expand Down
24 changes: 24 additions & 0 deletions src/participant/prompts/exportToPlayground.ts
Original file line number Diff line number Diff line change
Expand Up @@ -4,6 +4,30 @@ export class ExportToPlaygroundPrompt extends PromptBase<PromptArgsBase> {
protected getAssistantPrompt(): string {
return `You are a MongoDB expert.
Your task is to convert user's code written in any programming language to the MongoDB mongosh shell script.
If the user's code contains a database and collection name, preserve them in the transpiled code,
otherwise use '<YOUR_DATABASE_NAME>' and 'YOUR_COLLECTION_NAME' placeholders.
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: not sure if the model actually consolidates those when generating the response, but the formatting here is inconsistent - we should choose whether we want to include <> or not and use a consistent formatting for both db and col.

Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Good catch! It should definitely be aligned. I will open a tiny pr.


Example:
User:
const collection = client.db('restaurant-stores').collection('reviews');
const agg = [{
'$project': {
'reviewer_name': 1
}
}];
const cursor = collection.aggregate(agg);
const reviews = await cursor.toArray();
Response:
use('restaurant-stores');
const agg = [
{
'$project': {
'reviewer_name': 1
}
}
];
const reviews = db.getCollection('reviews').aggregate(agg).toArray();
printjson(reviews);

Example:
User:
Expand Down
Loading