├── .devcontainer
└── devcontainer.json
├── .editorconfig
├── .github
├── CODE_OF_CONDUCT.md
├── CONTRIBUTING.md
├── SECURITY.md
└── SUPPORT.md
├── .gitignore
├── .vscode
├── extensions.json
└── settings.json
├── LICENSE
├── README.md
├── data
├── gh_wikipedia.txt
├── hybrid.csv
└── image.jpg
├── docs
└── images
│ ├── ai-foundry-endpoint.png
│ ├── clone-url.png
│ ├── codespaces.png
│ └── icon.png
├── package-lock.json
├── package.json
├── samples
├── 01-chat.ts
├── 02-json.ts
├── 03-stream.ts
├── 04-classifier.ts
├── 05-rag.ts
├── 06-summarizer.ts
├── 07-langchain.ts
├── 08-reasoning.ts
├── 09-llamaindex.ts
├── 10-ai-inference-sdk.ts
└── config.ts
└── tsconfig.json
/.devcontainer/devcontainer.json:
--------------------------------------------------------------------------------
1 | // For format details, see https://aka.ms/devcontainer.json. For config options, see the
2 | // README at: https://github.com/devcontainers/templates/tree/main/src/javascript-node
3 | {
4 | "name": "javascript",
5 |
6 | // Or use a Dockerfile or Docker Compose file. More info: https://containers.dev/guide/dockerfile
7 | "image": "mcr.microsoft.com/devcontainers/javascript-node:22-bookworm",
8 |
9 | // Features to add to the dev container. More info: https://containers.dev/features.
10 | "features": {},
11 |
12 | // Configure tool-specific properties.
13 | "customizations": {
14 | "vscode": {
15 | "extensions": [
16 | "ms-windows-ai-studio.windows-ai-studio",
17 | "EditorConfig.EditorConfig",
18 | "formulahendry.code-runner"
19 | ]
20 | }
21 | },
22 |
23 | "postCreateCommand": "npm install -g tsx; npm install",
24 |
25 | // Set minimal host requirements for the container.
26 | "hostRequirements": {
27 | "memory": "16gb"
28 | }
29 | }
30 |
--------------------------------------------------------------------------------
/.editorconfig:
--------------------------------------------------------------------------------
1 | # Editor configuration, see http://editorconfig.org
2 | root = true
3 |
4 | [*]
5 | charset = utf-8
6 | indent_style = space
7 | indent_size = 2
8 | insert_final_newline = true
9 | trim_trailing_whitespace = true
10 | end_of_line = lf
11 | max_line_length = 120
12 |
13 | [*.md]
14 | max_line_length = off
15 | trim_trailing_whitespace = false
16 |
--------------------------------------------------------------------------------
/.github/CODE_OF_CONDUCT.md:
--------------------------------------------------------------------------------
1 | # Microsoft Open Source Code of Conduct
2 |
3 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
4 |
5 | Resources:
6 |
7 | - [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/)
8 | - [Microsoft Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/)
9 | - Contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with questions or concerns
10 |
--------------------------------------------------------------------------------
/.github/CONTRIBUTING.md:
--------------------------------------------------------------------------------
1 | # Contributing
2 |
3 | This project welcomes contributions and suggestions. Most contributions require you to agree to a
4 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
5 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
6 |
7 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide
8 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
9 | provided by the bot. You will only need to do this once across all repos using our CLA.
10 |
11 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
12 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
13 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
14 |
15 | - [Code of Conduct](#coc)
16 | - [Issues and Bugs](#issue)
17 | - [Feature Requests](#feature)
18 | - [Submission Guidelines](#submit)
19 |
20 | ## Code of Conduct
21 |
22 | Help us keep this project open and inclusive. Please read and follow our [Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
23 |
24 | ## Found an Issue?
25 |
26 | If you find a bug in the source code or a mistake in the documentation, you can help us by
27 | [submitting an issue](#submit-issue) to the GitHub Repository. Even better, you can
28 | [submit a Pull Request](#submit-pr) with a fix.
29 |
30 | ## Want a Feature?
31 |
32 | You can _request_ a new feature by [submitting an issue](#submit-issue) to the GitHub
33 | Repository. If you would like to _implement_ a new feature, please submit an issue with
34 | a proposal for your work first, to be sure that we can use it.
35 |
36 | - **Small Features** can be crafted and directly [submitted as a Pull Request](#submit-pr).
37 |
38 | ## Submission Guidelines
39 |
40 | ### Submitting an Issue
41 |
42 | Before you submit an issue, search the archive, maybe your question was already answered.
43 |
44 | If your issue appears to be a bug, and hasn't been reported, open a new issue.
45 | Help us to maximize the effort we can spend fixing issues and adding new
46 | features, by not reporting duplicate issues. Providing the following information will increase the
47 | chances of your issue being dealt with quickly:
48 |
49 | - **Overview of the Issue** - if an error is being thrown a non-minified stack trace helps
50 | - **Version** - what version is affected (e.g. 0.1.2)
51 | - **Motivation for or Use Case** - explain what are you trying to do and why the current behavior is a bug for you
52 | - **Browsers and Operating System** - is this a problem with all browsers?
53 | - **Reproduce the Error** - provide a live example or a unambiguous set of steps
54 | - **Related Issues** - has a similar issue been reported before?
55 | - **Suggest a Fix** - if you can't fix the bug yourself, perhaps you can point to what might be
56 | causing the problem (line of code or commit)
57 |
58 | You can file new issues by providing the above information at the corresponding repository's issues link: https://github.com/microsoft/github-models-javascript-playground/issues/new].
59 |
60 | ### Submitting a Pull Request (PR)
61 |
62 | Before you submit your Pull Request (PR) consider the following guidelines:
63 |
64 | - Search the repository (https://github.com/microsoft/github-models-javascript-playground/pulls) for an open or closed PR
65 | that relates to your submission. You don't want to duplicate effort.
66 |
67 | - Make your changes in a new git fork:
68 |
69 | - Commit your changes using a descriptive commit message
70 | - Push your fork to GitHub:
71 | - In GitHub, create a pull request
72 | - If we suggest changes then:
73 |
74 | - Make the required updates.
75 | - Rebase your fork and force push to your GitHub repository (this will update your Pull Request):
76 |
77 | ```shell
78 | git rebase master -i
79 | git push -f
80 | ```
81 |
82 | That's it! Thank you for your contribution!
83 |
--------------------------------------------------------------------------------
/.github/SECURITY.md:
--------------------------------------------------------------------------------
1 |
2 |
3 | ## Security
4 |
5 | Microsoft takes the security of our software products and services seriously, which includes all source code repositories managed through our GitHub organizations, which include [Microsoft](https://github.com/microsoft), [Azure](https://github.com/Azure), [DotNet](https://github.com/dotnet), [AspNet](https://github.com/aspnet), [Xamarin](https://github.com/xamarin), and [our GitHub organizations](https://opensource.microsoft.com/).
6 |
7 | If you believe you have found a security vulnerability in any Microsoft-owned repository that meets [Microsoft's definition of a security vulnerability](https://aka.ms/opensource/security/definition), please report it to us as described below.
8 |
9 | ## Reporting Security Issues
10 |
11 | **Please do not report security vulnerabilities through public GitHub issues.**
12 |
13 | Instead, please report them to the Microsoft Security Response Center (MSRC) at [https://msrc.microsoft.com/create-report](https://aka.ms/opensource/security/create-report).
14 |
15 | If you prefer to submit without logging in, send email to [secure@microsoft.com](mailto:secure@microsoft.com). If possible, encrypt your message with our PGP key; please download it from the [Microsoft Security Response Center PGP Key page](https://aka.ms/opensource/security/pgpkey).
16 |
17 | You should receive a response within 24 hours. If for some reason you do not, please follow up via email to ensure we received your original message. Additional information can be found at [microsoft.com/msrc](https://aka.ms/opensource/security/msrc).
18 |
19 | Please include the requested information listed below (as much as you can provide) to help us better understand the nature and scope of the possible issue:
20 |
21 | - Type of issue (e.g. buffer overflow, SQL injection, cross-site scripting, etc.)
22 | - Full paths of source file(s) related to the manifestation of the issue
23 | - The location of the affected source code (tag/branch/commit or direct URL)
24 | - Any special configuration required to reproduce the issue
25 | - Step-by-step instructions to reproduce the issue
26 | - Proof-of-concept or exploit code (if possible)
27 | - Impact of the issue, including how an attacker might exploit the issue
28 |
29 | This information will help us triage your report more quickly.
30 |
31 | If you are reporting for a bug bounty, more complete reports can contribute to a higher bounty award. Please visit our [Microsoft Bug Bounty Program](https://aka.ms/opensource/security/bounty) page for more details about our active programs.
32 |
33 | ## Preferred Languages
34 |
35 | We prefer all communications to be in English.
36 |
37 | ## Policy
38 |
39 | Microsoft follows the principle of [Coordinated Vulnerability Disclosure](https://aka.ms/opensource/security/cvd).
40 |
41 |
42 |
--------------------------------------------------------------------------------
/.github/SUPPORT.md:
--------------------------------------------------------------------------------
1 | # Support
2 |
3 | ## How to file issues and get help
4 |
5 | This project uses GitHub Issues to track bugs and feature requests. Please search the existing
6 | issues before filing new issues to avoid duplicates. For new issues, file your bug or
7 | feature request as a new Issue.
8 |
9 | For help and questions about using this project, please use GitHub Issues and tag them with the
10 | **question** label.
11 |
12 | ## Microsoft Support Policy
13 |
14 | Support for this **PROJECT or PRODUCT** is limited to the resources listed above.
15 |
--------------------------------------------------------------------------------
/.gitignore:
--------------------------------------------------------------------------------
1 | node_modules/
2 | *.log
3 | *.tgz
4 | .DS_Store
5 | Thumbs.db
6 | .env
7 | .vectordb
8 | .env*
9 | dist/
10 | TODO
11 |
--------------------------------------------------------------------------------
/.vscode/extensions.json:
--------------------------------------------------------------------------------
1 | {
2 | "recommendations": [
3 | "formulahendry.code-runner",
4 | "ms-toolsai.jupyter",
5 | ]
6 | }
7 |
--------------------------------------------------------------------------------
/.vscode/settings.json:
--------------------------------------------------------------------------------
1 | {
2 | "code-runner.executorMap": {
3 | "typescript": "npx tsx",
4 | },
5 | "code-runner.clearPreviousOutput": true,
6 | "code-runner.saveFileBeforeRun": true,
7 | }
8 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | The MIT License (MIT)
2 |
3 | Copyright (c) Microsoft Corporation.
4 |
5 | Permission is hereby granted, free of charge, to any person obtaining a copy
6 | of this software and associated documentation files (the "Software"), to deal
7 | in the Software without restriction, including without limitation the rights
8 | to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
9 | copies of the Software, and to permit persons to whom the Software is
10 | furnished to do so, subject to the following conditions:
11 |
12 | The above copyright notice and this permission notice shall be included in all
13 | copies or substantial portions of the Software.
14 |
15 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
16 | IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
17 | FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
18 | AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
19 | LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
20 | OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
21 | SOFTWARE.
22 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 |
2 |
3 |

4 |
5 | # DeepSeek on Azure - JavaScript demos
6 |
7 | [](https://codespaces.new/Azure-Samples/deepseek-azure-javascript?hide_repo_select=true&ref=main&quickstart=true)
8 | 
9 | [](https://www.typescriptlang.org)
10 | [](LICENSE)
11 |
12 | ⭐ If you like this repo, star it on GitHub — it helps a lot!
13 |
14 | [Overview](#overview) • [Get started](#get-started) • [Run the samples](#run-the-samples) • [Next steps](#next-steps) • [Related samples](#related-samples)
15 |
16 |
17 |
18 | ## Overview
19 |
20 | DeepSeek-R1 model has been announced on [GitHub Models](https://github.blog/changelog/2025-01-29-deepseek-r1-is-now-available-in-github-models-public-preview/)
21 | as well as on [Azure AI Foundry](https://azure.microsoft.com/en-us/blog/deepseek-r1-is-now-available-on-azure-ai-foundry-and-github/), and
22 | the goal of this collection of samples is to demonstrate how to use it with JavaScript/TypeScript, using either the [OpenAI Node.js SDK](https://github.com/openai/openai-node), [LangChain.js](https://js.langchain.com/), [LlamaIndex.TS](https://ts.llamaindex.ai/) or [Azure AI Inference SDK](https://www.npmjs.com/package/@azure-rest/ai-inference).
23 |
24 | > [!TIP]
25 | > You can run any of these demos right in your browser for free using [GitHub Codespaces](https://github.com/features/codespaces) and [GitHub Models](https://github.com/marketplace/models)! ✨
26 |
27 | > [!NOTE]
28 | > The DeepSeek-R1 model focus is on complex reasoning tasks, and it is not designed for general conversation. It is best suited for tasks that require a deep understanding of the context and a complex reasoning process to provide an answer, like the `samples/08-reasoning.ts` example.
29 | > This also means that you may experience longer response times compared to other models, because it simulates a though process (englobed under the `` tag) before providing an actual answer.
30 |
31 | ## Get started
32 |
33 | There are multiple ways to get started with this project.
34 |
35 | The quickest way is to use [GitHub Codespaces](#use-github-codespaces) that provides a preconfigured environment for you, directly from your browser. Alternatively, you can [set up your local environment](#use-your-local-environment) following the instructions below.
36 |
37 |
38 | Use GitHub Codespaces
39 |
40 | You can run this project directly in your browser by using GitHub Codespaces, which will open a web-based VS Code:
41 |
42 | [](https://codespaces.new/Azure-Samples/deepseek-azure-javascript?hide_repo_select=true&ref&quickstart=true)
43 |
44 |
45 |
46 |
47 | Use a VSCode dev container
48 |
49 | A similar option to Codespaces is VS Code Dev Containers, that will open the project in your local VS Code instance using the [Dev Containers extension](https://marketplace.visualstudio.com/items?itemName=ms-vscode-remote.remote-containers).
50 |
51 | You will also need to have [Docker](https://www.docker.com/get-started/) installed on your machine to run the container.
52 |
53 | [](https://vscode.dev/redirect?url=vscode://ms-vscode-remote.remote-containers/cloneInVolume?url=https://github.com/Azure-Samples/deepseek-azure-javascript)
54 |
55 |
56 |
57 |
58 | Use your local environment
59 |
60 | You need to install following tools to work on your local machine:
61 |
62 | - [Node.js LTS](https://nodejs.org/en/download)
63 | - [Git](https://git-scm.com/downloads)
64 | - [Ollama](https://ollama.com/) _(optional)_ - For using the models locally
65 |
66 | Then you can get the project code:
67 |
68 | 1. [**Fork**](https://github.com/Azure-Samples/deepseek-azure-javascript/fork) the project to create your own copy of this repository.
69 | 2. On your forked repository, select the **Code** button, then the **Local** tab, and copy the URL of your forked repository.
70 |
71 | 
72 | 3. Open a terminal and run this command to clone the repo: `git clone `
73 | 4. Open the cloned project in your favorite IDE, then run this command in a terminal: `npm install`
74 |
75 |
76 |
77 | ## Run the samples
78 |
79 | In the [samples](./samples) folder of this repository, you'll find examples of how to use the DeepSeek-R1 models with different use cases and SDKs. You can run them by executing the following command in the terminal:
80 |
81 | ```bash
82 | npx tsx samples/
83 | ```
84 |
85 | Alternatively, you can open a sample file in the editor and run it directly by clicking the "Run" (▶️) button in the top right corner of the editor.
86 |
87 | The samples are configured by default to run using GitHub models, which should run without any additional configuration if you're using GitHub Codespaces. There are multiple ways to run the samples using either GitHub Models, Azure AI Foundry or even locally using Ollama. Open the `samples/config.ts` and change the default export to the desired configuration.
88 |
89 | ### Using GitHub Models
90 |
91 | To use GitHub Models, you need to have a [GitHub account](https://github.com/signup) and a [personal access token (PAT)](https://docs.github.com/authentication/keeping-your-account-and-data-secure/managing-your-personal-access-tokens#creating-a-fine-grained-personal-access-token).
92 |
93 | Once you have created you PAT, create a `.env` file in the root of the project and add the following content:
94 |
95 | ```env
96 | GITHUB_TOKEN=
97 | ```
98 |
99 | > [!TIP]
100 | > If you're using GitHub Codespaces, you can run the samples using GitHub Models without any additional configuration.
101 | > Codespaces already sets up the environment variables for you, and you don't need to create a PAT.
102 |
103 | Open the `samples/config.ts` file and update the default export:
104 |
105 | ```ts
106 | export default GITHUB_MODELS_CONFIG;
107 | ```
108 |
109 | ### Using Azure AI Foundry
110 |
111 | To use Azure AI Foundry, you need to have an [Azure account](https://azure.com/free). Then follow this [quickstart guide](https://learn.microsoft.com/azure/ai-studio/how-to/deploy-models-serverless?tabs=azure-ai-studio) to deploy a serverless endpoint with the model. When it's time to choose the model, select the `DeepSeek-R1` model in the catalog.
112 |
113 | Once your endpoint is deployed, you should be able to see your endpoint details and retrieve the URL and API key:
114 |
115 | 
116 |
117 | Then create a `.env` file in the root of the project and add the following content:
118 |
119 | ```env
120 | AZURE_AI_BASE_URL="https://..models.ai.azure.com/v1"
121 | AZURE_AI_API_KEY=""
122 | ```
123 |
124 | > [!TIP]
125 | > If you're copying the endpoint from the Azure AI Foundry portal, make sure to add the `/v1` at the end of the URL.
126 |
127 | Open the `samples/config.ts` file and update the default export:
128 |
129 | ```ts
130 | export default AZURE_AI_CONFIG;
131 | ```
132 |
133 | ### Using Ollama
134 |
135 | To use Ollama, you first need to use a [local dev environment](#use-your-local-environment) and install [Ollama](https://ollama.com/). Then, open a terminal and use the Ollama CLI to download the [DeepSeek-R1 model](https://ollama.com/library/deepseek-r1):
136 |
137 | ```bash
138 | ollama pull deepseek-r1:14b
139 | ```
140 |
141 | > [!TIP]
142 | > Different model sizes are [available](https://ollama.com/library/deepseek-r1), you can pick the one that fits your needs.
143 | > Larger models will provide better results but will require more resources to run. You can switch the model used by example by editing the `samples/config.ts` file.
144 |
145 | Once the model is downloaded, open the `samples/config.ts` file and update the default export:
146 |
147 | ```ts
148 | export default OLLAMA_CONFIG;
149 | ```
150 |
151 | ## Next steps
152 |
153 | Here are some additional resources to help you learn more and experiment with generative AI on Azure:
154 | - [How to use DeepSeek-R1 reasoning model](https://learn.microsoft.com/azure/ai-studio/how-to/deploy-models-deepseek?pivots=programming-language-javascript) (Microsoft Learn): a tutorial to learn how to use the DeepSeek-R1 reasoning model.
155 | - [Azure AI Foundry](https://ai.azure.com/) (Azure): a web portal to create, train, deploy and experiment with AI models.
156 | - [Generative AI with JavaScript](https://github.com/microsoft/generative-ai-with-javascript) (GitHub): code samples and resources to learn Generative AI with JavaScript.
157 | - [Fundamentals of Responsible Generative AI](https://learn.microsoft.com/training/modules/responsible-generative-ai/) (Microsoft Learn): a training module to learn about the responsible use of generative AI.
158 | - [Build a serverless AI chat with RAG using LangChain.js](https://techcommunity.microsoft.com/t5/apps-on-azure-blog/build-a-serverless-ai-chat-with-rag-using-langchain-js/ba-p/4111041) (GitHub): a next step code example to build an AI chatbot using Retrieval-Augmented Generation and LangChain.js.
159 |
160 | ## Related samples
161 |
162 | - [DeepSeek-R1 JavaScript starter](https://github.com/Azure-Samples/deepseek-js)
163 | - [DeepSeek-R1 on Azure with LangChain4j demo](https://github.com/Azure-Samples/DeepSeek-on-Azure-with-LangChain4j)
164 |
165 | ## Contributing
166 |
167 | This project welcomes contributions and suggestions. Most contributions require you to agree to a
168 | Contributor License Agreement (CLA) declaring that you have the right to, and actually do, grant us
169 | the rights to use your contribution. For details, visit https://cla.opensource.microsoft.com.
170 |
171 | When you submit a pull request, a CLA bot will automatically determine whether you need to provide
172 | a CLA and decorate the PR appropriately (e.g., status check, comment). Simply follow the instructions
173 | provided by the bot. You will only need to do this once across all repos using our CLA.
174 |
175 | This project has adopted the [Microsoft Open Source Code of Conduct](https://opensource.microsoft.com/codeofconduct/).
176 | For more information see the [Code of Conduct FAQ](https://opensource.microsoft.com/codeofconduct/faq/) or
177 | contact [opencode@microsoft.com](mailto:opencode@microsoft.com) with any additional questions or comments.
178 |
179 | ## Trademarks
180 |
181 | This project may contain trademarks or logos for projects, products, or services. Authorized use of Microsoft
182 | trademarks or logos is subject to and must follow
183 | [Microsoft's Trademark & Brand Guidelines](https://www.microsoft.com/en-us/legal/intellectualproperty/trademarks/usage/general).
184 | Use of Microsoft trademarks or logos in modified versions of this project must not cause confusion or imply Microsoft sponsorship.
185 | Any use of third-party trademarks or logos are subject to those third-party's policies.
186 |
--------------------------------------------------------------------------------
/data/gh_wikipedia.txt:
--------------------------------------------------------------------------------
1 | Not to be confused with Git or GitLab.
2 |
3 | GitHub () is a developer platform that allows developers to create, store, manage and share their code. It uses Git software, providing the distributed version control of access control, bug tracking, software feature requests, task management, continuous integration, and wikis for every project. Headquartered in California, it has been a subsidiary of Microsoft since 2018.
4 |
5 | It is commonly used to host open source software development projects. As of January 2023, GitHub reported having over 100 million developers and more than 420 million repositories, including at least 28 million public repositories. It is the world's largest source code host as of June 2023.
6 |
7 | About
8 | Founding
9 | The development of the GitHub platform began on October 19, 2007. The site was launched in April 2008 by Tom Preston-Werner, Chris Wanstrath, P. J. Hyett and Scott Chacon after it had been available for a few months as a beta release. Its name was chosen as a compound of Git and hub.
10 |
11 | Structure of the organization
12 | GitHub, Inc. was originally a flat organization with no middle managers, instead relying on self-management. Employees could choose to work on projects that interested them (open allocation), but the chief executive set salaries.
13 |
14 | In 2014, the company added a layer of middle management in response to serious harassment allegations against its senior leadership. As a result of the scandal, Tom Preston-Werner resigned from his position as CEO.
15 |
16 | Finance
17 | GitHub was a bootstrapped start-up business, which in its first years provided enough revenue to be funded solely by its three founders and start taking on employees.
18 |
19 | In July 2012, four years after the company was founded, Andreessen Horowitz invested $100 million in venture capital with a $750 million valuation.
20 |
21 | In July 2015 GitHub raised another $250 million (~$314 million in 2023) of venture capital in a series B round. The lead investor was Sequoia Capital, and other investors were Andreessen Horowitz, Thrive Capital, IVP (Institutional Venture Partners) and other venture capital funds. The round valued the company at approximately $15 billion.
22 |
23 | As of 2023, GitHub was estimated to generate $1 billion in revenue.
24 |
25 | History
26 | The GitHub service was developed by Chris Wanstrath, P. J. Hyett, Tom Preston-Werner, and Scott Chacon using Ruby on Rails, and started in February 2008. The company, GitHub, Inc., has existed as of 2007 and is located in San Francisco.
27 |
28 | On February 24, 2009, GitHub announced that within the first year of being online, GitHub had accumulated over 46,000 public repositories, 17,000 of which were formed in the previous month. At that time, about 6,200 repositories had been forked at least once, and 4,600 had been merged.
29 |
30 | That same year, the site was used by over 100,000 users, according to GitHub, and had grown to host 90,000 unique public repositories, 12,000 having been forked at least once, for a total of 135,000 repositories.
31 |
32 | In 2010, GitHub was hosting 1 million repositories. A year later, this number doubled. ReadWriteWeb reported that GitHub had surpassed SourceForge and Google Code in total number of commits for the period of January to May 2011. On January 16, 2013, GitHub passed the 3 million users mark and was then hosting more than 5 million repositories. By the end of the year, the number of repositories was twice as great, reaching 10 million repositories.
33 |
34 | In 2015, GitHub opened an office in Japan, its first outside of the U.S.
35 |
36 | On February 28, 2018, GitHub fell victim to the third-largest distributed denial-of-service (DDoS) attack in history, with incoming traffic reaching a peak of about 1.35 terabits per second.
37 |
38 | On June 19, 2018, GitHub expanded its GitHub Education by offering free education bundles to all schools.
39 |
40 | Acquisition by Microsoft
41 | From 2012, Microsoft became a significant user of GitHub, using it to host open-source projects and development tools such as .NET Core, Chakra Core, MSBuild, PowerShell, PowerToys, Visual Studio Code, Windows Calculator, Windows Terminal and the bulk of its product documentation (now to be found on Microsoft Docs).
42 |
43 | On June 4, 2018, Microsoft announced its intent to acquire GitHub for US$7.5 billion (~$8.96 billion in 2023). The deal closed on October 26, 2018. GitHub continued to operate independently as a community, platform and business. Under Microsoft, the service was led by Xamarin's Nat Friedman, reporting to Scott Guthrie, executive vice president of Microsoft Cloud and AI. Nat Friedman resigned November 3, 2021; he was replaced by Thomas Dohmke.
44 |
45 | There have been concerns from developers Kyle Simpson, JavaScript trainer and author, and Rafael Laguna, CEO at Open-Xchange over Microsoft's purchase, citing uneasiness over Microsoft's handling of previous acquisitions, such as Nokia's mobile business and Skype.
46 |
47 | This acquisition was in line with Microsoft's business strategy under CEO Satya Nadella, which has seen a larger focus on cloud computing services, alongside the development of and contributions to open-source software. Harvard Business Review argued that Microsoft was intending to acquire GitHub to get access to its user base, so it can be used as a loss leader to encourage the use of its other development products and services.
48 |
49 | Concerns over the sale bolstered interest in competitors: Bitbucket (owned by Atlassian), GitLab and SourceForge (owned by BIZX, LLC) reported that they had seen spikes in new users intending to migrate projects from GitHub to their respective services.
50 |
51 | In September 2019, GitHub acquired Semmle, a code analysis tool. In February 2020, GitHub launched in India under the name GitHub India Private Limited. In March 2020, GitHub announced that they were acquiring npm, a JavaScript packaging vendor, for an undisclosed sum of money. The deal was closed on April 15, 2020.
52 |
53 | In early July 2020, the GitHub Archive Program was established to archive its open-source code in perpetuity.
54 |
55 | Mascot
56 | GitHub's mascot is an anthropomorphized "octocat" with five octopus-like arms. The character was created by graphic designer Simon Oxley as clip art to sell on iStock, a website that enables designers to market royalty-free digital images. The illustration GitHub chose was a character that Oxley had named Octopuss. Since GitHub wanted Octopuss for their logo (a use that the iStock license disallows), they negotiated with Oxley to buy exclusive rights to the image.
57 |
58 | GitHub renamed Octopuss to Octocat, and trademarked the character along with the new name. Later, GitHub hired illustrator Cameron McEfee to adapt Octocat for different purposes on the website and promotional materials; McEfee and various GitHub users have since created hundreds of variations of the character, which are available on The Octodex.
59 |
60 | Services
61 | Projects on GitHub can be accessed and managed using the standard Git command-line interface; all standard Git commands work with it. GitHub also allows users to browse public repositories on the site. Multiple desktop clients and Git plugins are also available. In addition, the site provides social networking-like functions such as feeds, followers, wikis (using wiki software called Gollum), and a social network graph to display how developers work on their versions ("forks") of a repository and what fork (and branch within that fork) is newest.
62 |
63 | Anyone can browse and download public repositories, but only registered users can contribute content to repositories. With a registered user account, users can have discussions, manage repositories, submit contributions to others' repositories, and review changes to code. GitHub began offering limited private repositories at no cost in January 2019 (limited to three contributors per project). Previously, only public repositories were free. On April 14, 2020, GitHub made "all of the core GitHub features" free for everyone, including "private repositories with unlimited collaborators."
64 |
65 | The fundamental software that underpins GitHub is Git itself, written by Linus Torvalds, creator of Linux. The additional software that provides the GitHub user interface was written using Ruby on Rails and Erlang by GitHub, Inc. developers Wanstrath, Hyett, and Preston-Werner.
66 |
67 | Scope
68 | The primary purpose of GitHub is to facilitate the version control and issue tracking aspects of software development. Labels, milestones, responsibility assignment, and a search engine are available for issue tracking. For version control, Git (and, by extension, GitHub) allows pull requests to propose changes to the source code. Users who can review the proposed changes can see a diff between the requested changes and approve them. In Git terminology, this action is called "committing" and one instance of it is a "commit." A history of all commits is kept and can be viewed at a later time.
69 |
70 | In addition, GitHub supports the following formats and features:
71 |
72 | Documentation, including automatically rendered README files in a variety of Markdown-like file formats (see README § On GitHub)
73 | Wikis, with some repositories consisting solely of wiki content. These include curated lists of recommended software which have become known as awesome lists.
74 | GitHub Actions, which allows building continuous integration and continuous deployment pipelines for testing, releasing and deploying software without the use of third-party websites/platforms
75 | GitHub Codespaces, an online IDE providing users with a virtual machine intended to be a work environment to build and test code
76 | Graphs: pulse, contributors, commits, code frequency, punch card, network, members
77 | Integrations Directory
78 | Email notifications
79 | Discussions
80 | Option to subscribe someone to notifications by @ mentioning them.
81 | Emojis
82 | Nested task-lists within files
83 | Visualization of geospatial data
84 | 3D render files can be previewed using an integrated STL file viewer that displays the files on a "3D canvas." The viewer is powered by WebGL and Three.js.
85 | Support for previewing many common image formats, including Photoshop's PSD files
86 | PDF document viewer
87 | Security Alerts of known Common Vulnerabilities and Exposures in different packages
88 | GitHub's Terms of Service do not require public software projects hosted on GitHub to meet the Open Source Definition. The terms of service state, "By setting your repositories to be viewed publicly, you agree to allow others to view and fork your repositories."
89 |
90 | GitHub Enterprise
91 | GitHub Enterprise is a self-managed version of GitHub with similar functionality. It can be run on an organization's hardware or a cloud provider and has been available as of November 2011. In November 2020, source code for GitHub Enterprise Server was leaked online in an apparent protest against DMCA takedown of youtube-dl. According to GitHub, the source code came from GitHub accidentally sharing the code with Enterprise customers themselves, not from an attack on GitHub servers.
92 |
93 | GitHub Pages
94 | In 2008, GitHub introduced GitHub Pages, a static web hosting service for blogs, project documentation, and books. All GitHub Pages content is stored in a Git repository as files served to visitors verbatim or in Markdown format. GitHub is integrated with Jekyll static website and blog generator and GitHub continuous integration pipelines. Each time the content source is updated, Jekyll regenerates the website and automatically serves it via GitHub Pages infrastructure.
95 |
96 | Like the rest of GitHub, it includes free and paid service tiers. Websites generated through this service are hosted either as subdomains of the github.io domain or can be connected to custom domains bought through a third-party domain name registrar. GitHub Pages supports HTTPS encryption.
97 |
98 | Gist
99 | GitHub also operates a pastebin-style site called Gist, which is for code snippets, as opposed to GitHub proper, which is usually used for larger projects. Tom Preston-Werner débuted the feature at a Ruby conference in 2008.
100 |
101 | Gist builds on the traditional simple concept of a pastebin by adding version control for code snippets, easy forking, and TLS encryption for private pastes. Because each "gist" is its own Git repository, multiple code snippets can be contained in a single page, and they can be pushed and pulled using Git.
102 |
103 | Unregistered users could upload Gists until March 19, 2018, when uploading Gists was restricted to logged-in users, reportedly to mitigate spamming on the page of recent Gists.
104 |
105 | Gists' URLs use hexadecimal IDs, and edits to Gists are recorded in a revision history, which can show the text difference of thirty revisions per page with an option between a "split" and "unified" view. Like repositories, Gists can be forked, "starred", i.e., publicly bookmarked, and commented on. The count of revisions, stars, and forks is indicated on the gist page.
106 |
107 | Education program
108 | GitHub launched a new program called the GitHub Student Developer Pack to give students free access to more than a dozen popular development tools and services. GitHub partnered with Bitnami, Crowdflower, DigitalOcean, DNSimple, HackHands, Namecheap, Orchestrate, Screenhero, SendGrid, Stripe, Travis CI, and Unreal Engine to launch the program.
109 |
110 | In 2016, GitHub announced the launch of the GitHub Campus Experts program to train and encourage students to grow technology communities at their universities. The Campus Experts program is open to university students 18 years and older worldwide. GitHub Campus Experts are one of the primary ways that GitHub funds student-oriented events and communities, Campus Experts are given access to training, funding, and additional resources to run events and grow their communities. To become a Campus Expert, applicants must complete an online training course with multiple modules to develop community leadership skills.
111 |
112 | GitHub Marketplace service
113 | GitHub also provides some software as a service (SaaS) integrations for adding extra features to projects. Those services include:
114 |
115 | Waffle.io: project management for software teams, which allows users to automatically see pull requests, automated builds, reviews, and deployments across repositories.
116 | Rollbar: provides real-time debugging tools and full-stack exception reporting.
117 | Codebeat: automated code analysis for web and mobile developers.
118 | Travis CI: continuous integration service.
119 | GitLocalize: provides utilities to manage project translation and internationalisation.
120 | GitHub Sponsors
121 | GitHub Sponsors allows users to make monthly money donations to projects hosted on GitHub. The public beta was announced on May 23, 2019, and the project accepts waitlist registrations. The Verge said that GitHub Sponsors "works exactly like Patreon" because "developers can offer various funding tiers that come with different perks, and they'll receive recurring payments from supporters who want to access them and encourage their work" except with "zero fees to use the program." Furthermore, GitHub offers incentives for early adopters during the first year: it pledges to cover payment processing costs and match sponsorship payments up to $5,000 per developer. Furthermore, users can still use similar services like Patreon and Open Collective and link to their websites.
122 |
123 | GitHub Archive Program
124 | Main article: GitHub Archive Program
125 | In July 2020, GitHub stored a February archive of the site in an abandoned mountain mine in Svalbard, Norway, part of the Arctic World Archive and not far from the Svalbard Global Seed Vault. The archive contained the code of all active public repositories, as well as that of dormant but significant public repositories. The 21TB of data was stored on piqlFilm archival film reels as matrix (2D) barcode (Boxing barcode), and is expected to last 500–1,000 years.
126 |
127 | The GitHub Archive Program is also working with partners on Project Silica, in an attempt to store all public repositories for 10,000 years. It aims to write archives into the molecular structure of quartz glass platters, using a high-precision petahertz pulse laser, i.e. one that pulses a quadrillion (1,000,000,000,000,000) times per second.
128 |
129 | Controversies
130 | Harassment allegations
131 | In March 2014, GitHub programmer Julie Ann Horvath alleged that founder and CEO Tom Preston-Werner and his wife, Theresa, engaged in a pattern of harassment against her that led to her leaving the company. In April 2014, GitHub released a statement denying Horvath's allegations. However, following an internal investigation, GitHub confirmed the claims. GitHub's CEO Chris Wanstrath wrote on the company blog, "The investigation found Tom Preston-Werner in his capacity as GitHub's CEO acted inappropriately, including confrontational conduct, disregard of workplace complaints, insensitivity to the impact of his spouse's presence in the workplace, and failure to enforce an agreement that his spouse should not work in the office." Preston-Werner subsequently resigned from the company. The firm then announced it would implement new initiatives and trainings "to make sure employee concerns and conflicts are taken seriously and dealt with appropriately."
132 |
133 | Sanctions
134 | On July 25, 2019, a developer based in Iran wrote on Medium that GitHub had blocked his private repositories and prohibited access to GitHub pages. Soon after, GitHub confirmed that it was now blocking developers in Iran, Crimea, Cuba, North Korea, and Syria from accessing private repositories. However, GitHub reopened access to GitHub Pages days later, for public repositories regardless of location. It was also revealed that using GitHub while visiting sanctioned countries could result in similar actions occurring on a user's account. GitHub responded to complaints and the media through a spokesperson, saying:
135 |
136 | GitHub is subject to US trade control laws, and is committed to full compliance with applicable law. At the same time, GitHub's vision is to be the global platform for developer collaboration, no matter where developers reside. As a result, we take seriously our responsibility to examine government mandates thoroughly to be certain that users and customers are not impacted beyond what is required by law. This includes keeping public repositories services, including those for open source projects, available and accessible to support personal communications involving developers in sanctioned regions.
137 |
138 | Developers who feel that they should not have restrictions can appeal for the removal of said restrictions, including those who only travel to, and do not reside in, those countries. GitHub has forbidden the use of VPNs and IP proxies to access the site from sanctioned countries, as purchase history and IP addresses are how they flag users, among other sources.
139 |
140 | Censorship
141 | Main article: Censorship of GitHub
142 | On December 4, 2014, Russia blacklisted GitHub.com because GitHub initially refused to take down user-posted suicide manuals. After a day, Russia withdrew its block, and GitHub began blocking specific content and pages in Russia. On December 31, 2014, India blocked GitHub.com along with 31 other websites over pro-ISIS content posted by users; the block was lifted three days later. On October 8, 2016, Turkey blocked GitHub to prevent email leakage of a hacked account belonging to the country's energy minister.
143 |
144 | On March 26, 2015, a large-scale DDoS attack was launched against GitHub.com that lasted for just under five days. The attack, which appeared to originate from China, primarily targeted GitHub-hosted user content describing methods of circumventing Internet censorship.
145 |
146 | On April 19, 2020, Chinese police detained Chen Mei and Cai Wei (volunteers for Terminus 2049, a project hosted on GitHub), and accused them of "picking quarrels and provoking trouble." Cai and Chen archived news articles, interviews, and other materials published on Chinese media outlets and social media platforms that have been removed by censors in China.
147 |
148 | ICE contract
149 | See also: Microsoft and unions § United States
150 | GitHub has a $200,000 contract with U.S. Immigration and Customs Enforcement (ICE) for the use of their on-site product GitHub Enterprise Server. This contract was renewed in 2019, despite internal opposition from many GitHub employees. In an email sent to employees, later posted to the GitHub blog on October 9, 2019, CEO Nat Friedman stated, "The revenue from the purchase is less than $200,000 and not financially material for our company." He announced that GitHub had pledged to donate $500,000 to "nonprofit groups supporting immigrant communities targeted by the current administration." In response, at least 150 GitHub employees signed an open letter re-stating their opposition to the contract, and denouncing alleged human rights abuses by ICE. As of November 13, 2019, five workers had resigned over the contract.
151 |
152 | The ICE contract dispute came into focus again in June 2020 due to the company's decision to abandon "master/slave" branch terminology, spurred by the George Floyd protests and Black Lives Matter movement. Detractors of GitHub describe the branch renaming to be a form of performative activism and have urged GitHub to cancel their ICE contract instead. An open letter from members of the open source community was shared on GitHub in December 2019, demanding that the company drop its contract with ICE and provide more transparency into how they conduct business and partnerships. The letter has been signed by more than 700 people.
153 |
154 | Capitol riot comments and employee firing
155 | In January 2021, GitHub fired one of its employees after he expressed concern for colleagues following the January 6 United States Capitol attack, calling some of the rioters "Nazis". After an investigation, GitHub's COO said there were "significant errors of judgment and procedure" with the company's decision to fire the employee. As a result of the investigation, GitHub reached out to the employee, and the company's head of human resources resigned.
156 |
157 | Twitter source code leak
158 | In 2023, parts of the social media platform Twitter were uploaded onto GitHub. The leak was first reported by the New York Times and was part of a legal filing Twitter submitted to the United States District Court for the Northern District of California. Twitter claimed that the postings infringed on copyright property owned by them, and asked the court for information to identify the user who posted the source code to GitHub, under the username "FreeSpeechEnthusiast".
159 |
160 | Reception
161 | Linus Torvalds, the original developer of the Git software, has highly praised GitHub by stating "The hosting of github [sic] is excellent. They've done a good job on that. I think GitHub should be commended enormously for making open source project hosting so easy." However, he also sharply criticized the implementation of GitHub's merging interface, stating that "Git comes with a nice pull-request generation module, but GitHub instead decided to replace it with their own totally inferior version. As a result, I consider GitHub useless for these kinds of things. It's fine for hosting, but the pull requests and the online commit editing, are just pure garbage."
162 |
163 | See also
164 | Collaborative innovation network
165 | Collaborative intelligence
166 | Commons-based peer production
167 | Comparison of source code hosting facilities
168 | DevOps
169 | Gitea
170 | GitLab
171 | Codeberg
172 | Timeline of GitHub
173 | GitHub Copilot
174 | Replit
175 |
--------------------------------------------------------------------------------
/data/hybrid.csv:
--------------------------------------------------------------------------------
1 | vehicle,year,msrp,0-60 mph acceleration,mpg,class
2 | Prius (1st Gen),1997,24509.74,7.46,41.26,Compact
3 | Tino,2000,35354.97,8.2,54.1,Compact
4 | Prius (2nd Gen),2000,26832.25,7.97,45.23,Compact
5 | Insight,2000,18936.41,9.52,53.0,Two Seater
6 | Civic (1st Gen),2001,25833.38,7.04,47.04,Compact
7 | Insight,2001,19036.71,9.52,53.0,Two Seater
8 | Insight,2002,19137.01,9.71,53.0,Two Seater
9 | Alphard,2003,38084.77,8.33,40.46,Minivan
10 | Insight,2003,19137.01,9.52,53.0,Two Seater
11 | Civic,2003,14071.92,8.62,41.0,Compact
12 | Escape,2004,36676.1,10.32,31.99,SUV
13 | Insight,2004,19237.31,9.35,52.0,Two Seater
14 | Prius,2004,20355.64,9.9,46.0,Midsize
15 | Silverado 15 2WD,2004,30089.64,9.09,17.0,Pickup Truck
16 | Lexus RX400h,2005,58521.14,12.76,28.23,SUV
17 | Civic (2nd Gen),2005,26354.44,7.63,39.99,Compact
18 | Highlander,2005,29186.21,12.76,29.4,SUV
19 | Insight,2005,19387.76,9.71,52.0,Two Seater
20 | Civic,2005,18236.33,8.26,41.0,Compact
21 | Escape 2WD,2005,19322.56,9.52,29.0,SUV
22 | Accord,2005,16343.69,14.93,28.0,Midsize
23 | Silverado 15 2WD,2005,32647.26,11.11,17.0,Pickup Truck
24 | Mercury Mariner,2006,34772.4,8.98,32.93,SUV
25 | Camry,2006,29853.25,11.28,33.64,Midsize
26 | Lexus GS450h,2006,64547.56,18.65,33.4,Midsize
27 | Estima,2006,36012.7,9.26,47.04,Minivan
28 | Altima,2006,29524.75,13.29,32.93,Midsize
29 | Chevrolet Tahoe,2007,42924.35,10.91,22.35,SUV
30 | Kluger,2007,46229.48,12.76,25.87,SUV
31 | Lexus LS600h/hL,2007,118543.6,17.54,21.0,Midsize
32 | Tribute,2007,24823.83,11.28,31.75,SUV
33 | GMC Yukon,2007,57094.81,12.28,21.78,SUV
34 | Aura,2007,22110.87,10.87,27.0,Midsize
35 | Vue,2007,22938.33,10.75,26.0,SUV
36 | Silverado 15 2WD,2007,34653.23,11.49,17.0,Pickup Truck
37 | Crown,2008,62290.38,8.7,37.16,Midsize
38 | Cadillac Escalade,2008,78932.81,9.09,22.35,SUV
39 | F3DM,2008,23744.06,9.52,30.11,Midsize
40 | Altima,2008,18675.63,13.7,34.0,Midsize
41 | A5 BSG,2009,11849.43,7.87,35.28,Midsize
42 | Lexus RX450h,2009,46233.36,13.47,31.99,SUV
43 | ML450 Blue HV,2009,60519.83,12.6,23.99,SUV
44 | Prius (3rd Gen),2009,24641.18,9.6,47.98,Compact
45 | S400 Long,2009,96208.93,13.89,26.34,Large
46 | Mercury Milan,2009,30522.57,11.55,40.69,Midsize
47 | Lexus HS250h,2009,38478.15,11.55,54.1,Compact
48 | Avante/Elantra LPI,2009,21872.71,10.21,41.87,Compact
49 | ActiveHybrid X6,2009,97237.9,17.96,18.82,SUV
50 | SAI,2009,39172.44,11.55,54.1,Midsize
51 | Malibu,2009,24768.79,9.09,29.0,Midsize
52 | Vue,2009,26408.67,13.7,28.0,SUV
53 | Aspen HEV,2009,44903.77,13.51,21.0,SUV
54 | Durango,2009,41033.24,8.33,21.0,SUV
55 | Auris HSD,2010,35787.29,8.85,68.21,Compact
56 | CR-Z,2010,21435.54,9.24,37.0,Two Seater
57 | F3DM PHEV,2010,23124.59,9.24,30.15,Midsize
58 | Touareg,2010,64198.95,15.38,28.7,SUV
59 | Audi Q5,2010,37510.86,14.08,33.64,SUV
60 | Jeep Patriot,2010,17045.06,12.05,29.4,SUV
61 | Besturn B50 ,2010,14586.61,7.14,31.28,Midsize
62 | ActiveHybrid 7,2010,104300.43,20.41,22.11,Large
63 | Lincoln MKZ,2010,37036.64,11.15,37.63,Midsize
64 | Fit/Jazz,2010,16911.85,8.26,30.0,Compact
65 | Sonata,2010,28287.66,14.7,37.0,Midsize
66 | Cayenne S,2010,73183.47,14.71,26.11,SUV
67 | Insight,2010,19859.16,9.17,41.0,Compact
68 | Fuga Infiniti M35H,2010,70157.02,18.65,33.64,Midsize
69 | Chevrolet Volt,2010,42924.35,10.78,35.0,Compact
70 | Tribute 4WD,2010,27968.32,12.35,29.0,SUV
71 | Fusion FWD,2010,28033.51,11.49,39.0,Midsize
72 | HS 250h,2010,34753.53,11.76,35.0,Compact
73 | Mariner FWD,2010,30194.95,11.63,32.0,SUV
74 | RX 450h,2010,42812.54,13.89,30.0,SUV
75 | ML450 4natic,2010,55164.33,12.99,22.0,SUV
76 | Silverado 15 2WD,2010,38454.56,11.76,22.0,Pickup Truck
77 | S400,2010,88212.78,12.99,21.0,Large
78 | Aqua,2011,22850.87,9.35,50.0,Compact
79 | Lexus CT200h,2011,30082.16,9.71,42.0,Compact
80 | Civic (3rd Gen),2011,24999.59,9.6,44.36,Compact
81 | Prius alpha (V),2011,30588.35,10.0,72.92,Midsize
82 | 3008,2011,45101.54,11.36,61.16,Compact
83 | Fit Shuttle,2011,16394.36,7.52,58.8,Minivan
84 | Buick Regal,2011,27948.93,12.05,25.99,Midsize
85 | Prius V,2011,27272.28,9.51,32.93,Midsize
86 | Freed/Freed Spike,2011,27972.07,6.29,50.81,Minivan
87 | Optima K5,2011,26549.16,10.54,36.0,Midsize
88 | Escape FWD,2011,30661.34,12.35,32.0,SUV
89 | Insight,2011,18254.38,9.52,41.0,Compact
90 | MKZ FWD,2011,34748.52,11.49,39.0,Midsize
91 | CR-Z,2011,19402.8,12.2,37.0,Two Seater
92 | Sonata,2011,25872.07,11.9,36.0,Midsize
93 | Camry,2011,27130.82,13.89,33.0,Midsize
94 | Tribute 2WD,2011,26213.09,12.5,32.0,SUV
95 | Cayenne S,2011,67902.28,18.52,21.0,SUV
96 | Touareg,2011,50149.39,16.13,21.0,SUV
97 | ActiveHybrid 7i,2011,102605.66,18.18,20.0,Midsize
98 | Prius C,2012,19006.62,9.35,50.0,Compact
99 | Prius PHV,2012,32095.61,8.82,50.0,Midsize
100 | Ampera,2012,31739.55,11.11,37.0,Compact
101 | ActiveHybrid 5,2012,62180.23,16.67,26.0,Midsize
102 | Lexus GS450h,2012,59126.14,16.95,31.0,Midsize
103 | Insight,2012,18555.28,9.42,42.0,Compact
104 | Chevrolet Volt,2012,39261.96,11.11,37.0,Compact
105 | Camry LE,2012,26067.66,13.16,41.0,Midsize
106 | MKZ FWD,2012,34858.84,11.49,39.0,Midsize
107 | M35h,2012,53860.45,19.23,29.0,Midsize
108 | LaCrosse,2012,30049.52,11.36,29.0,Midsize
109 | ActiveHybrid 5,2012,61132.11,17.54,26.0,Midsize
110 | Panamera S,2012,95283.85,17.54,25.0,Large
111 | Yukon 1500,2012,52626.77,13.5,21.0,SUV
112 | Prius C,2013,19080.0,8.7,50.0,Compact
113 | Jetta,2013,24995.0,12.66,45.0,Compact
114 | Civic,2013,24360.0,10.2,44.0,Compact
115 | Prius,2013,24200.0,10.2,50.0,Midsize
116 | Fusion FWD,2013,27200.0,11.72,47.0,Midsize
117 | C-Max FWD,2013,25200.0,12.35,43.0,Large
118 | Insight,2013,18600.0,11.76,42.0,Compact
119 | Camry LE,2013,26140.0,13.51,41.0,Midsize
120 | Camry LXLE,2013,27670.0,13.33,40.0,Midsize
121 | Sonata,2013,25650.0,11.76,38.0,Midsize
122 | Optima,2013,25900.0,11.63,38.0,Midsize
123 | Sonata Limited,2013,30550.0,11.76,37.0,Midsize
124 | Optima EX,2013,31950.0,11.36,37.0,Midsize
125 | Malibu,2013,24985.0,11.49,29.0,Midsize
126 | LaCrosse,2013,31660.0,11.36,29.0,Midsize
127 | Regal,2013,29015.0,12.2,29.0,Midsize
128 | RX 450h,2013,46310.0,12.99,30.0,SUV
129 | Highlander 4WD,2013,40170.0,13.89,28.0,SUV
130 | Q5,2013,50900.0,14.71,26.0,SUV
131 | Cayenne S,2013,69850.0,16.39,21.0,SUV
132 | Touareg,2013,62575.0,16.13,21.0,SUV
133 | Escalade 2WD,2013,74425.0,11.63,21.0,SUV
134 | Tahoe 2WD,2013,53620.0,11.9,21.0,SUV
135 | Yukon 1500,2013,54145.0,11.88,21.0,SUV
136 | Yukon 1500,2013,61960.0,13.33,21.0,SUV
137 | MKZ FWD,2013,35925.0,14.03,45.0,Midsize
138 | CT 200h,2013,32050.0,10.31,42.0,Compact
139 | ES 300h,2013,39250.0,12.35,40.0,Midsize
140 | ILX,2013,28900.0,9.26,38.0,Compact
141 | ActiveHybrid 3,2013,49650.0,14.93,28.0,Compact
142 | Silverado 15 2WD,2013,41135.0,12.35,21.0,Pickup Truck
143 | Sierra 15 2WD,2013,41555.0,10.0,21.0,Pickup Truck
144 | GS 450h,2013,59450.0,16.67,31.0,Midsize
145 | M35h,2013,54750.0,19.61,29.0,Midsize
146 | E400,2013,55800.0,14.93,26.0,Midsize
147 | ActiveHybrid 5,2013,61400.0,12.99,26.0,Midsize
148 | ActiveHybrid 7L,2013,84300.0,18.18,25.0,Large
149 | Panamera S,2013,96150.0,18.52,25.0,Large
150 | S400,2013,92350.0,13.89,21.0,Large
151 | Prius Plug-in,2013,32000.0,9.17,50.0,Midsize
152 | C-Max Energi Plug-in,2013,32950.0,11.76,43.0,Midsize
153 | Fusion Energi Plug-in,2013,38700.0,11.76,43.0,Midsize
154 | Chevrolet Volt,2013,39145.0,11.11,37.0,Compact
155 |
--------------------------------------------------------------------------------
/data/image.jpg:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/deepseek-azure-javascript/c0f6825a80e6cc70ddf1a29784ff8db70fce1da8/data/image.jpg
--------------------------------------------------------------------------------
/docs/images/ai-foundry-endpoint.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/deepseek-azure-javascript/c0f6825a80e6cc70ddf1a29784ff8db70fce1da8/docs/images/ai-foundry-endpoint.png
--------------------------------------------------------------------------------
/docs/images/clone-url.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/deepseek-azure-javascript/c0f6825a80e6cc70ddf1a29784ff8db70fce1da8/docs/images/clone-url.png
--------------------------------------------------------------------------------
/docs/images/codespaces.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/deepseek-azure-javascript/c0f6825a80e6cc70ddf1a29784ff8db70fce1da8/docs/images/codespaces.png
--------------------------------------------------------------------------------
/docs/images/icon.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Azure-Samples/deepseek-azure-javascript/c0f6825a80e6cc70ddf1a29784ff8db70fce1da8/docs/images/icon.png
--------------------------------------------------------------------------------
/package.json:
--------------------------------------------------------------------------------
1 | {
2 | "name": "deepseek-azure-javascript",
3 | "version": "0.0.0",
4 | "description": "Demonstrate how to use DeepSeek-R1 models GitHub Models, Azure or Ollama",
5 | "private": true,
6 | "type": "module",
7 | "repository": {
8 | "type": "git",
9 | "url": "https://github.com/sinedied/deepseek-azure-javascript"
10 | },
11 | "scripts": {},
12 | "keywords": [
13 | "github-models",
14 | "azure",
15 | "openai",
16 | "langchain",
17 | "generative ai",
18 | "ai",
19 | "samples",
20 | "llm",
21 | "deepseek"
22 | ],
23 | "author": {
24 | "name": "Yohan Lasorsa",
25 | "url": "https://github.com/sinedied"
26 | },
27 | "homepage": "https://github.com/sinedied/deepseek-azure-javascript",
28 | "bugs": {
29 | "url": "https://github.com/sinedied/deepseek-azure-javascript/issues"
30 | },
31 | "license": "MIT",
32 | "dependencies": {
33 | "@azure-rest/ai-inference": "^1.0.0-beta.5",
34 | "@azure/core-auth": "^1.9.0",
35 | "@azure/core-sse": "^2.1.3",
36 | "@langchain/openai": "^0.4.2",
37 | "dotenv": "^16.4.7",
38 | "langchain": "^0.3.15",
39 | "llamaindex": "^0.8.31",
40 | "openai": "^4.52.7"
41 | },
42 | "devDependencies": {
43 | "tsx": "^4.19.2"
44 | },
45 | "engines": {
46 | "node": ">=20.0.0",
47 | "npm": ">=10.0.0"
48 | }
49 | }
50 |
--------------------------------------------------------------------------------
/samples/01-chat.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to use the OpenAI API to chat with the model.
2 |
3 | import { OpenAI } from "openai";
4 | import config from "./config.js";
5 |
6 | const openai = new OpenAI({ ...config });
7 |
8 | const chatCompletion = await openai.chat.completions.create({
9 | model: config.model,
10 | messages: [{ role: "user", content: "Say hello in French!" }],
11 | });
12 |
13 | console.log(chatCompletion.choices[0].message.content);
14 |
--------------------------------------------------------------------------------
/samples/02-json.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to use the OpenAI API to generate structured
2 | // JSON output to chat prompts.
3 |
4 | import { OpenAI } from "openai";
5 | import config from "./config.js";
6 |
7 | const openai = new OpenAI({ ...config });
8 |
9 | const chatCompletion = await openai.chat.completions.create({
10 | model: config.model,
11 | messages: [
12 | {
13 | role: "user",
14 | content: 'Say hello 5 different languages. Answer in JSON using { "": "" } format.',
15 | },
16 | ],
17 | response_format: {
18 | type: "json_object",
19 | },
20 | });
21 |
22 | console.log(chatCompletion.choices[0].message.content);
23 |
--------------------------------------------------------------------------------
/samples/03-stream.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to use the OpenAI API to stream the chat
2 | // response to the console, to provide a more interactive experience.
3 |
4 | import { OpenAI } from "openai";
5 | import config from "./config.js";
6 |
7 | const openai = new OpenAI({ ...config });
8 |
9 | const chunks = await openai.chat.completions.create({
10 | model: config.model,
11 | messages: [{ role: "user", content: "Say hello in pirate style, then tell a pirate joke." }],
12 | stream: true,
13 | });
14 |
15 | for await (const chunk of chunks) {
16 | process.stdout.write(chunk.choices[0]?.delta.content ?? "");
17 | }
18 |
--------------------------------------------------------------------------------
/samples/04-classifier.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to extract structured information from a
2 | // a given input text using a JSON schema.
3 |
4 | import { OpenAI } from "openai";
5 | import config from "./config.js";
6 |
7 | const openai = new OpenAI({ ...config });
8 |
9 | const systemPrompt = `You are a data extraction tool that extracts structured JSON information from the user input using this JSON schema:
10 |
11 | {
12 | // The sentiment of the text
13 | "sentiment": "positive" | "neutral" | "negative",
14 | // How aggressive the text is on a scale from 1 to 10
15 | "aggressiveness": 1-10,
16 | // The language the text is written in
17 | "language": "string"
18 | }`;
19 |
20 | const input = `Cet exemple est pas trop mal!`;
21 |
22 | const result = await openai.chat.completions.create({
23 | model: config.model,
24 | messages: [
25 | { role: "system", content: systemPrompt },
26 | { role: "user", content: input },
27 | ],
28 | response_format: {
29 | type: "json_object",
30 | },
31 | });
32 |
33 | console.log(result.choices[0].message.content);
34 |
--------------------------------------------------------------------------------
/samples/05-rag.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to use the Retrieval Augmented Generation (RAG)
2 | // to answer questions based on a hybrid car data set.
3 | // The code below reads the CSV file, searches for matches to the user question,
4 | // and then generates a response based on the information found.
5 |
6 | import fs from "node:fs";
7 | import { OpenAI } from "openai";
8 | import config from "./config.js";
9 |
10 | const systemPrompt = `Answers questions about cars based off a hybrid car data set.
11 | Use the sources to answer the questions, if there's no enough data in provided sources say that you don't know.
12 | Be brief and straight to the point.`;
13 |
14 | const question = `what's the fastest prius`;
15 |
16 | // Load CSV data as an array of objects
17 | const rows = fs.readFileSync("./data/hybrid.csv", "utf8").split("\n");
18 | const columns = rows[0].split(",");
19 |
20 | // Search the data using a very naive search
21 | const words = question
22 | .toLowerCase()
23 | .replaceAll(/[.?!()'":,]/g, "")
24 | .split(" ")
25 | .filter((word) => word.length > 2);
26 | const matches = rows.slice(1).filter((row) => words.some((word) => row.toLowerCase().includes(word)));
27 |
28 | // Format as a markdown table, since language models understand markdown
29 | const table =
30 | `| ${columns.join(" | ")} |\n` +
31 | `|${columns.map(() => "---").join(" | ")}|\n` +
32 | matches.map((row) => `| ${row.replaceAll(",", " | ")} |\n`).join("");
33 |
34 | console.log(`Found ${matches.length} matches:`);
35 | console.log(table);
36 |
37 | // Use the search results to generate a response
38 | const openai = new OpenAI({ ...config });
39 |
40 | const chunks = await openai.chat.completions.create({
41 | model: config.model,
42 | messages: [
43 | { role: "system", content: systemPrompt },
44 | { role: "user", content: `${question}\n\nSOURCES:\n${table}` },
45 | ],
46 | // Randomness of the completion (0: deterministic, 1: maximum randomness)
47 | temperature: 0.7,
48 | stream: true,
49 | });
50 |
51 | console.log(`Answer for "${question}":`);
52 |
53 | for await (const chunk of chunks) {
54 | process.stdout.write(chunk.choices[0]?.delta.content ?? "");
55 | }
56 |
--------------------------------------------------------------------------------
/samples/06-summarizer.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to summarize a large text.
2 | //
3 | // NOTE: This example requires more time to run, as the context size is very
4 | // large.
5 |
6 | import fs from "node:fs";
7 | import { OpenAI } from "openai";
8 | import config from "./config.js";
9 |
10 | const systemPrompt = `Rewrite this text into a very brief summary.`;
11 |
12 | // Load a large text
13 | const text = fs.readFileSync("./data/gh_wikipedia.txt", "utf8");
14 |
15 | const openai = new OpenAI({ ...config });
16 |
17 | const result = await openai.chat.completions.create({
18 | model: config.model,
19 | messages: [
20 | { role: "system", content: systemPrompt },
21 | { role: "user", content: text },
22 | ],
23 | });
24 | const summary = result.choices[0].message.content ?? "";
25 |
26 | console.log(`Original text: ${text.length} chars`);
27 | console.log(`Summarized text (${summary.length} chars):`);
28 | console.log(summary);
29 |
--------------------------------------------------------------------------------
/samples/07-langchain.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to use LangChain.js with DeepSeek models.
2 |
3 | import { ChatPromptTemplate } from "@langchain/core/prompts";
4 | import { ChatOpenAI } from "@langchain/openai";
5 | import config from "./config.js";
6 |
7 | const model = new ChatOpenAI({
8 | configuration: { ...config },
9 | });
10 |
11 | const response = await ChatPromptTemplate.fromMessages([["human", "{input}"]])
12 | .pipe(model)
13 | .invoke({ input: "Say hello!" });
14 |
15 | console.log(response.content);
16 |
--------------------------------------------------------------------------------
/samples/08-reasoning.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to use the reasoning capabilities of the
2 | // DeepSeek-R1 model to explain the magic behind a piece of code.
3 |
4 | import { OpenAI } from "openai";
5 | import config from "./config.js";
6 |
7 | const openai = new OpenAI({ ...config });
8 |
9 | const prompt = `
10 | float fast_inv_sqrt(float number) {
11 | long i;
12 | float x2, y;
13 | const float threehalfs = 1.5F;
14 |
15 | x2 = number * 0.5F;
16 | y = number;
17 | i = *(long*)&y; // evil floating point bit level hacking
18 | i = 0x5f3759df - ( i >> 1 ); // what the fuck?
19 | y = *(float*)&i;
20 | y = y * ( threehalfs - ( x2 * y * y ) ); // 1st iteration
21 | // y = y * ( threehalfs - ( x2 * y * y ) ); // 2nd iteration, this can be removed
22 |
23 | return y;
24 | }
25 |
26 | What is this code doing? Explain me the magic behind it.
27 | `;
28 |
29 | const chunks = await openai.chat.completions.create({
30 | model: config.model,
31 | messages: [{ role: "user", content: prompt }],
32 | stream: true,
33 | });
34 |
35 | for await (const chunk of chunks) {
36 | process.stdout.write(chunk.choices[0]?.delta.content ?? "");
37 | }
38 |
--------------------------------------------------------------------------------
/samples/09-llamaindex.ts:
--------------------------------------------------------------------------------
1 | import { OpenAI } from "llamaindex";
2 | import config from "./config.js";
3 |
4 | const response = await new OpenAI({ additionalSessionOptions: config }).chat({
5 | messages: [{ content: "Tell me a joke.", role: "user" }],
6 | });
7 | console.log(response.message.content);
8 |
--------------------------------------------------------------------------------
/samples/10-ai-inference-sdk.ts:
--------------------------------------------------------------------------------
1 | // This example demonstrates how to use Azure AI Inference SDK with DeepSeek models.
2 |
3 | import ModelClient, { isUnexpected } from "@azure-rest/ai-inference";
4 | import { AzureKeyCredential } from "@azure/core-auth";
5 | import config from "./config.js";
6 |
7 | const client = ModelClient(config.baseURL, new AzureKeyCredential(config.apiKey));
8 |
9 | const response = await client.path("/chat/completions").post({
10 | body: {
11 | messages: [{ role: "user", content: "Say hello in French" }],
12 | model: config.model,
13 | },
14 | });
15 |
16 | if (isUnexpected(response)) {
17 | throw response.body.error;
18 | }
19 |
20 | console.log(response.body.choices[0].message.content);
21 |
--------------------------------------------------------------------------------
/samples/config.ts:
--------------------------------------------------------------------------------
1 | // This file sets up the configuration for using DeepSeek models with different
2 | // providers.
3 |
4 | import process from "node:process";
5 | import "dotenv/config";
6 |
7 | // Configuration for using GitHub models
8 | const GITHUB_MODELS_CONFIG = {
9 | baseURL: "https://models.inference.ai.azure.com",
10 | apiKey: process.env.GITHUB_TOKEN,
11 | model: "DeepSeek-R1",
12 | };
13 |
14 | // Configuration for using Azure AI Foundry models
15 | export const AZURE_AI_CONFIG = {
16 | baseURL: process.env.AZURE_AI_BASE_URL,
17 | apiKey: process.env.AZURE_AI_API_KEY,
18 | model: "DeepSeek-R1",
19 | };
20 |
21 | // Configuration for using Ollama models
22 | export const OLLAMA_CONFIG = {
23 | baseURL: "http://localhost:11434/v1",
24 | apiKey: "__not_needed__",
25 | model: "deepseek-r1:14b",
26 | };
27 |
28 | // Set the configuration to use with all the examples
29 | export default GITHUB_MODELS_CONFIG;
30 | // export default AZURE_AI_CONFIG;
31 | // export default OLLAMA_CONFIG;
32 |
--------------------------------------------------------------------------------
/tsconfig.json:
--------------------------------------------------------------------------------
1 | {
2 | "compilerOptions": {
3 | "target": "esnext",
4 | "module": "nodenext",
5 | "moduleResolution": "nodenext",
6 | "lib": ["esnext"],
7 | "esModuleInterop": true,
8 | "strict": true,
9 | }
10 | }
11 |
--------------------------------------------------------------------------------