-
Notifications
You must be signed in to change notification settings - Fork 35
DOCSP 43493 VSCode Copilot /query functionality #92
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
Merged
Merged
Changes from all commits
Commits
Show all changes
22 commits
Select commit
Hold shift + click to select a range
89c7826
DOCSP-43493 adding copilot page
ltran-mdb2 02b3217
DOCSP-43493 adding copilot page
ltran-mdb2 4be41f0
DOCSP-43493 adding copilot page
ltran-mdb2 92b4315
DOCSP-43493 adding /query example
ltran-mdb2 172179e
DOCSP-43493 adding /query example
ltran-mdb2 3b0d9bf
DOCSP-43493 adding ai and data usage
ltran-mdb2 fb2cd61
DOCSP-43493 adding ai and data usage
ltran-mdb2 ad7a58d
DOCSP-43493 adding ai and data usage
ltran-mdb2 4f22c05
DOCSP-43493 adding ai and data usage
ltran-mdb2 fed6b9f
DOCSP-43493 using sample database
ltran-mdb2 7f5915b
DOCSP-43493 using sample database
ltran-mdb2 824ff26
DOCSP-43493 tech edits
ltran-mdb2 1ebb8ce
DOCSP-43493 adding agg pipeline example
ltran-mdb2 270dc4e
DOCSP-43493 adding agg pipeline example
ltran-mdb2 9949ef9
DOCSP-43493 updating snooty.toml
ltran-mdb2 ed3d794
DOCSP-43493 *
ltran-mdb2 1d4d0a6
DOCSP-43493 adding query 1 image
ltran-mdb2 5adb7b1
DOCSP-43493 adding screenshots
ltran-mdb2 474a0a0
DOCSP-43493 Melissa comments
ltran-mdb2 624a434
DOCSP-43493 Melissa comments
ltran-mdb2 fb9cbe0
DOCSP-43493 Melissa comments
ltran-mdb2 318a61a
Merge branch 'master' into DOCSP-43493
ltran-mdb2 File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
.. vscode-ai-data-usage: | ||
|
||
============================= | ||
AI and Data Usage Information | ||
============================= | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
|
||
The |copilot| is powered by Generative AI (Gen AI), and may give | ||
inaccurate responses. See our `Generative AI FAQ | ||
<https://dochub.mongodb.org/core/faq-ai-features>`__ for more | ||
information about Gen AI in MongoDB products. | ||
|
||
Third Party Providers | ||
--------------------- | ||
|
||
The |copilot| is powered by `GitHub Copilot | ||
<https://github.com/features/copilot>`__. | ||
|
||
How Your Data is Used | ||
--------------------- | ||
|
||
When you use the |copilot| , the following information is sent to | ||
MongoDB's backend, the MongoDB Docs Chatbot, and/or the third party AI | ||
Check failure on line 27 in source/ai-data-usage.txt
|
||
provider: | ||
|
||
- The full text of your natural language prompt. | ||
- The schema of the collection you are using, | ||
including database name, collection name, field names, and types. | ||
|
||
The information that is sent will not be shared with any other third | ||
parties or stored by the AI provider. We do not send database | ||
connection strings, credentials, or rows/documents from your databases. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,141 @@ | ||
.. _vsce-copilot-query: | ||
|
||
============== | ||
/query Command | ||
============== | ||
|
||
.. default-domain:: mongodb | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
:class: singlecol | ||
|
||
The ``/query`` command assists in generating queries from a natural | ||
language against a connected MongoDB cluster. The |copilot| provides | ||
underlying schema information of the relevant collections to GitHub | ||
Copilot to generate a response. If you do not specify a collection in | ||
your prompt, the chat prompts you to select a relevant collection. | ||
|
||
When the LLM generates a query, you can open the query in a playground | ||
file or run the query directly in your collection. | ||
|
||
Examples | ||
~~~~~~~~ | ||
|
||
Generate a Query | ||
```````````````` | ||
|
||
Consider the ``users`` collection in the `Mflix Sample Database | ||
<https://www.mongodb.com/docs/atlas/sample-data/sample-mflix/#sample_mflix.users>`__. | ||
Each document in the collection has the following structure: | ||
|
||
.. code-block:: javascript | ||
:copyable: false | ||
|
||
{ | ||
_id: { | ||
"$oid": "59b99db4cfa9a34dcd7885b6" | ||
}, | ||
name: "Kayden Washington", | ||
email: "[email protected]", | ||
password: "11222021" | ||
} | ||
|
||
Once you connect to the deployment that contains the ``users`` | ||
collection, you can ask the GitHub Copilot chat to generate a query that | ||
finds the document in the ``users`` collection that has the ``name`` | ||
value of ``Kayden Washington``. | ||
|
||
.. code-block:: javascript | ||
:copyable: false | ||
|
||
@MongoDB /query In the sample_mflix database, find a document in the | ||
users collection with the name of Kayden Washington. | ||
|
||
The GitHub Copilot Chat uses the |copilot| to | ||
generate the following query using knowledge of your database schema: | ||
|
||
.. code-block:: javascript | ||
|
||
use(`sample_mflix`); | ||
db.getCollection('users').findOne({ name: 'Kayden Washington' }); | ||
|
||
Once the |copilot| generates the query, you can choose to run the query | ||
directly or open the query in a playground. | ||
|
||
.. figure:: /images/copilot-query.png | ||
:figwidth: 700px | ||
:alt: Screenshot of copilot generating a query | ||
|
||
Build an Aggregation Pipeline | ||
````````````````````````````` | ||
|
||
You can also use the |copilot| to build aggregation pipelines. Consider | ||
the ``users`` collection in the `Mflix Sample Database | ||
<https://www.mongodb.com/docs/atlas/sample-data/sample-mflix/#sample_mflix.users>`__. | ||
Each document in the collection has the following structure: | ||
|
||
.. code-block:: javascript | ||
:copyable: false | ||
|
||
{ | ||
_id: { | ||
"$oid": "59b99db4cfa9a34dcd7885b6" | ||
}, | ||
name: "Kayden Washington", | ||
email: "[email protected]", | ||
password: "11222021" | ||
} | ||
|
||
Once you connect to the deployment that contains the ``users`` | ||
collection, you can ask the GitHub Copilot chat to generate an aggregation pipeline. | ||
|
||
.. code-block:: javascript | ||
:copyable: false | ||
|
||
@MongoDB /query Generate an aggregation pipeline on the users | ||
collection that first sorts documents alphabetically by name and then | ||
removes the password field from each document. | ||
|
||
The |copilot| generates the following aggregation pipeline: | ||
|
||
.. code-block:: javascript | ||
|
||
use('sample_mflix'); | ||
db.getCollection('users').aggregate([ | ||
{ $sort: { name: 1 } }, | ||
{ $project: { password: 0 } } | ||
]); | ||
|
||
Once the |copilot| generates the query, you can choose to run the pipeline | ||
directly or open the pipeline in a playground. | ||
|
||
.. figure:: /images/copilot-agg-pipeline.png | ||
:figwidth: 700px | ||
:alt: Screenshot of copilot generating an aggregation pipeline | ||
|
||
You can also iteratively build on your aggregation pipeline: | ||
|
||
.. code-block:: javascript | ||
:copyable: false | ||
|
||
@MongoDB /query Add a stage to my pipeline that adds a username field | ||
to each document containing the user's email without the | ||
email domain. | ||
|
||
The |copilot| returns the following aggregation pipeline: | ||
|
||
.. code-block:: javascript | ||
|
||
use('sample_mflix'); | ||
db.getCollection('users').aggregate([ | ||
{ $sort: { name: 1 } }, | ||
{ $project: { password: 0 } }, | ||
{ $addFields: { username: { $arrayElemAt: [{ $split: ["$email", "@"] }, 0] } } } | ||
]); | ||
|
||
.. figure:: /images/copilot-agg-pipeline2.png | ||
:figwidth: 700px | ||
:alt: Screenshot of copilot iteratively building on an aggregation pipeline |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,41 @@ | ||
.. _vsce-copilot: | ||
|
||
================================== | ||
|copilot| | ||
================================== | ||
|
||
.. default-domain:: mongodb | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
:class: singlecol | ||
|
||
|vsce-full| includes the |copilot| to assist in using `GitHub Copilot | ||
<https://github.com/features/copilot>`__ with your MongoDB deployments. | ||
Through GitHub Copilot's chat feature, users with |vsce| can interact | ||
with their MongoDB clusters and generate code with MongoDB | ||
domain-specific knowledge on top of GitHub Copilot's LLM. The |copilot| | ||
can also answer questions about your database collection schema and | ||
provide links to specific MongoDB documentation. | ||
|
||
The |copilot| includes MongoDB-specific | ||
commands to assist in interacting with your deployment. | ||
|
||
Commands | ||
-------- | ||
|
||
/query | ||
~~~~~~ | ||
|
||
The ``/query`` command assists in generating queries from a natural | ||
language against a connected MongoDB cluster. | ||
|
||
.. toctree:: | ||
:titlesonly: | ||
|
||
/query </copilot-query> | ||
AI & Data Usage </ai-data-usage> | ||
|
||
|
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'd like us to make sure to run this answer by Product legal if we haven't yet. This contains what we normally include but because we get so many questions from customers it's just good to be sure we have covered our bases here. We've been primarily working with Rachael McClure - let me know if you need any assistance in getting a check here. cc @GaurabAryal