-
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
Changes from 18 commits
89c7826
02b3217
4be41f0
92b4315
172179e
3b0d9bf
fb2cd61
ad7a58d
4f22c05
fed6b9f
7f5915b
824ff26
1ebb8ce
270dc4e
9949ef9
ed3d794
1d4d0a6
5adb7b1
474a0a0
624a434
fb9cbe0
318a61a
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,35 @@ | ||
.. vscode-ai-data-usage: | ||
|
||
============================= | ||
AI and Data Usage Information | ||
============================= | ||
|
||
.. contents:: On this page | ||
:local: | ||
:backlinks: none | ||
:depth: 1 | ||
|
||
The MongoDB Github Copilot Participant 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 MongoDB Github Copilot Participant is powered by `Github Copilot <https://github.com/features/copilot>`__. | ||
|
||
How Your Data is Used | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe 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 |
||
--------------------- | ||
|
||
When you use the MongoDB Github Copilot Participant, the following | ||
information is sent to MongoDB's backend and/or the third party AI | ||
Check failure on line 26 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. |
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 |
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> | ||
|
||
|
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.
There is a capital H in GitHub - we should correct throughout.
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.
Fixed!
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.
Thank you!