2. What is GitHub Copilot
什么是GitHub Copilot?
GitHub Copilot is an AI pair programmer that helps you write code faster and with less work.
GitHub Copilot draws context from comments and code, and suggests individual lines and whole
functions instantly. GitHub Copilot is powered by OpenAI Codex, a new AI system created by
OpenAI. The GitHub Copilot technical preview is available as an extension for Visual Studio
Code, Neovim, and the JetBrains suite of IDEs.
GitHub Copilot是一个人工智能结对程序员,可以帮助你更快地编写代码,减少工作量。GitHub
Copilot从注释和代码中提取上下文,并立即建议个别行和整个函数。GitHub Copilot由OpenAI
Codex驱动,这是一个由OpenAI创建的新的人工智能系统。GitHub Copilot技术预览版可作为
Visual Studio Code、Neovim和JetBrains IDE套件的扩展。
3. How does GitHub Copilot work?
GitHub Copilot是如何工作的
OpenAI Codex was trained on publicly available source code and natural language, so it
understands both programming and human languages. The GitHub Copilot editor extension
sends your comments and code to the GitHub Copilot service, which then uses OpenAI Codex to
synthesize and suggest individual lines and whole functions.
OpenAI Codex是根据公开的源代码和自然语言进行训练的,所以它既能理解编程,也能理解人类
语言。GitHub Copilot编辑器扩展将您的评论和代码发送到GitHub Copilot服务,然后它使用
OpenAI Codex来合成和建议个别行和整个功能。
4. How good is GitHub
Copilot?GitHub Copilot有多
好?
We recently benchmarked against a set of Python functions that have good test coverage in open
source repos. We blanked out the function bodies and asked GitHub Copilot to fill them in. The
model got this right 43% of the time on the first try, and 57% of the time when allowed 10
attempts. And it’s getting smarter all the time.
我们最近对一组Python函数进行了基准测试,这些函数在开放源码仓库中有很好的测试覆盖率。我
们将函数主体留空,并要求GitHub Copilot将其填入。该模型在第一次尝试时有43%的时间是正确
的,而在允许10次尝试时有57%的时间是正确的。而且它还在不断地变得更聪明。
5. Does GitHub Copilot write
perfect code?
Github Copilot能写完美的代码吗
No. GitHub Copilot tries to understand your intent and to generate the best code it can, but
the code it suggests may not always work, or even make sense. While we are working
hard to make GitHub Copilot better, code suggested by GitHub Copilot should be carefully
tested, reviewed, and vetted, like any other code. As the developer, you are always in
charge.
GitHub Copilot 试图理解您的意图并生成它所能提供的最佳代码,但它所建议的代码不一定
有效,甚至没有意义。虽然我们正在努力使GitHub Copilot变得更好,但GitHub Copilot建议
的代码应该像其他代码一样被仔细测试、审查和审核。作为开发者,你始终是负责人。
6. How do I get the most out of GitHub
Copilot?
我怎样才能最大限度地利用GitHub
Copilot?
It works best when you divide your code into small functions, use meaningful
names for functions parameters, and write good docstrings and comments as
you go. It also seems to do best when it’s helping you navigate unfamiliar
libraries or frameworks.
当你把你的代码分成小的函数,为函数参数使用有意义的名字,并在使用过程
中写好文档和注释时,它的效果最好。当它帮助你浏览不熟悉的库或框架时,
它似乎也能发挥最大作用。
7. What context does GitHub Copilot use
to generate suggestions?
GitHub Copilot使用什么上下文环境来
生成建议代码?
GitHub Copilot uses the current file as context when making its suggestions.
It does not yet use other files in your project as inputs for synthesis. This
means that, for example, copy/pasting a type declaration into the file you’re
working on may improve suggestions from GitHub Copilot. This is something
we will improve in the future.
GitHub Copilot在提出建议代码时使用当前文件作为上下文。它还不使用你项
目中的其他文件作为合成的输入。这意味着,例如,将一个类型声明复制/粘贴
到你正在处理的文件中可能会改善GitHub Copilot的建议。这一点我们将在未
来加以改进。