|
Download README.md from mongodb-eai/code-examples: direct link, hf CLI and curl.
- Browser
- Download file 4.19 kB
-
https://huggingface.co/datasets/mongodb-eai/code-examples/resolve/main/README.md
- Command line
-
hf download hf://datasets/mongodb-eai/code-examples/README.md
-
curl -L -H "Authorization: Bearer $HF_TOKEN" -o README.md https://huggingface.co/datasets/mongodb-eai/code-examples/resolve/main/README.md
4.19 kB
| task_categories: | |
| - text-generation | |
| language: | |
| - en | |
| tags: | |
| - code | |
| pretty_name: Code Examples | |
| size_categories: | |
| - 10K<n<100K | |
| license: apache-2.0 | |
| # MongoDB Code Examples | |
| This dataset contains code examples of using MongoDB technologies. These code examples come from the | |
| [MongoDB documentation](https://www.mongodb.com/docs/) and [developer blog](https://www.mongodb.com/developer/). | |
| The dataset is updated regularly to stay relatively up-to-date with the latest published content. | |
| ## Schema | |
| The dataset includes the code example text and useful metadata for working with the code examples. Every code example in the dataset includes the following: | |
| ```ts | |
| export interface CodeExampleDatasetEntry { | |
| /** | |
| Code example. | |
| */ | |
| text: string; | |
| /** | |
| Programming language of the code snippet. Programming language name in [Github Linguist list](https://github.com/github-linguist/linguist/blob/main/lib/linguist/languages.yml). | |
| */ | |
| programming_language?: string; | |
| /** | |
| URL of page that the code example came from. | |
| */ | |
| url: string; | |
| updated: Date; | |
| sourceName: string; | |
| /** | |
| Title of the page that the code example came from. | |
| */ | |
| page_title?: string; | |
| /** | |
| Natural language prompts that coudl be used to generate the code example. | |
| */ | |
| prompts: string[]; | |
| /** | |
| Tags for the code example | |
| */ | |
| tags?: string[]; | |
| /** | |
| Classification type of the code example. | |
| */ | |
| classification: "usage_example" | |
| | "api_reference" | |
| | "execution_output" | |
| | "error_message" | |
| | "example_data" | |
| | "cli_command" | |
| | "unknown"; | |
| /** | |
| Whether the code example should be used for training an LLM, | |
| as determined by an LLM classifier. | |
| */ | |
| useful_for_training?: boolean; | |
| /** | |
| Chain-of-thought reasoning for why the code example should be used for training an LLM. | |
| */ | |
| utility_reasoning?: string; | |
| } | |
| ``` | |
| The fields `prompts`, `classification`, `useful_for_training`, and `utility_reasoning` are all generated using an LLM. | |
| ## Example | |
| Code example: | |
| ```js | |
| { | |
| "_id": { | |
| "$oid": "67b78fe299fca174d2738543" | |
| }, | |
| "text": "const { MongoClient } = require(\"mongodb\");\n\n// Replace the placeholder with your connection string.\nconst uri = \"<connection string>\";\nconst client = new MongoClient(uri);\n\nasync function run() {\n try {\n const aggDB = client.db(\"agg_tutorials_db\");\n\n // Get a reference to relevant collections.\n // ... const someColl =\n // ... const anotherColl =\n\n // Delete any existing documents in collections.\n // ... await someColl.deleteMany({});\n\n // Insert sample data into the collection or collections.\n // ... const someData = [ ... ];\n\n // ... await someColl.insertMany(someData);\n\n // Create an empty pipeline array.\n const pipeline = [];\n\n // Add code to create pipeline stages.\n // ... pipeline.push({ ... })\n\n // Run the aggregation.\n // ... const aggregationResult = ...\n\n // Print the aggregation results.\n for await (const document of aggregationResult) {\n console.log(document);\n }\n } finally {\n await client.close();\n }\n}\n\nrun().catch(console.dir);\n", | |
| "programming_language": "javascript", | |
| "url": "https://mongodb.com/docs/drivers/node/current/aggregation-tutorials/", | |
| "updated": { | |
| "$date": "2025-02-20T20:26:09.470Z" | |
| }, | |
| "sourceName": "snooty-node", | |
| "page_title": "Aggregation Tutorials", | |
| "classification": "usage_example", | |
| "useful_for_training": true, | |
| "utility_reasoning": "The example shows how to set up a MongoDB client, create a database reference, and prepare for an aggregation pipeline in Node.js. It relates to the MongoDB Node.js driver.", | |
| "prompts": [ | |
| "How do I create an empty aggregation pipeline in MongoDB?", | |
| "How do I initialize an empty pipeline array in MongoDB?", | |
| "create an empty pipeline array mongodb" | |
| ], | |
| "tags": [ | |
| "docs", | |
| "driver", | |
| "node", | |
| "javascript" | |
| ], | |
| "transformAlgoHash": "6e668fb590c9ed4bb593a93bed1a4c40c99bfa7b13674022e0fbd1d364e96ec4" | |
| } | |
| ``` | |
| ## Source Code | |
| Source code may be found here: https://github.com/mongodb/chatbot/tree/EAI-870/packages/datasets/src/codeExampleDataset |