diff --git a/snooty.toml b/snooty.toml index 0e4a0203..da02b2a4 100644 --- a/snooty.toml +++ b/snooty.toml @@ -10,7 +10,8 @@ toc_landing_pages = [ "/playgrounds", "/crud-ops", "/playground-databases", - "/require-playgrounds" + "/require-playgrounds", + "/copilot" ] [constants] @@ -40,6 +41,7 @@ cifs = ":abbr:`CIFS (Common Internet File System)`" cps = ":abbr:`CPS (Cloud Provider Snapshots)`" cmk = ":abbr:`CMK (customer master key)`" compass = "MongoDB Compass" +copilot = "MongoDB GitHub Copilot Participant" data-lakes = "Data Lakes" data-lake = "Data Lake" datadog = "`Datadog `__" diff --git a/source/ai-data-usage.txt b/source/ai-data-usage.txt new file mode 100644 index 00000000..ffa58aeb --- /dev/null +++ b/source/ai-data-usage.txt @@ -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 +`__ for more +information about Gen AI in MongoDB products. + +Third Party Providers +--------------------- + +The |copilot| is powered by `GitHub 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 +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. diff --git a/source/copilot-query.txt b/source/copilot-query.txt new file mode 100644 index 00000000..bc942045 --- /dev/null +++ b/source/copilot-query.txt @@ -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 +`__. +Each document in the collection has the following structure: + +.. code-block:: javascript + :copyable: false + + { + _id: { + "$oid": "59b99db4cfa9a34dcd7885b6" + }, + name: "Kayden Washington", + email: "KW@email.com", + 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 +`__. +Each document in the collection has the following structure: + +.. code-block:: javascript + :copyable: false + + { + _id: { + "$oid": "59b99db4cfa9a34dcd7885b6" + }, + name: "Kayden Washington", + email: "KW@email.com", + 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 diff --git a/source/copilot.txt b/source/copilot.txt new file mode 100644 index 00000000..986dd512 --- /dev/null +++ b/source/copilot.txt @@ -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 +`__ 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 + AI & Data Usage + + diff --git a/source/images/copilot-agg-pipeline.png b/source/images/copilot-agg-pipeline.png new file mode 100644 index 00000000..3819dbf8 --- /dev/null +++ b/source/images/copilot-agg-pipeline.png @@ -0,0 +1,47 @@ + + + + + + + + + + + Copilot_user + + diff --git a/source/images/copilot-agg-pipeline2.png b/source/images/copilot-agg-pipeline2.png new file mode 100644 index 00000000..d81d6e84 --- /dev/null +++ b/source/images/copilot-agg-pipeline2.png @@ -0,0 +1,47 @@ + + + + + + + + + + + Copilot_user + + diff --git a/source/images/copilot-query.png b/source/images/copilot-query.png new file mode 100644 index 00000000..7c9a83d2 --- /dev/null +++ b/source/images/copilot-query.png @@ -0,0 +1,47 @@ + + + + + + + + + + + Copilot_user + + diff --git a/source/index.txt b/source/index.txt index 7d6fe6b2..ca5ac2b9 100644 --- a/source/index.txt +++ b/source/index.txt @@ -56,6 +56,7 @@ Get Started Connect Manage Data Explore with Playgrounds + GitHub Copilot Participant Create an Atlas Cluster with Terraform Reference Changelog