这是用户在 2024-4-16 12:46 为 https://continue.dev/docs/how-to-use-continue 保存的双语快照页面,由 沉浸式翻译 提供双语支持。了解如何保存?
Skip to main content
跳转到主要内容

🧑‍🎓 How to use Continue
🧑‍🎓 如何使用继续

info 提示

TL;DR: Using LLMs as you code can accelerate you if you leverage them in the right situations. However, they can also cause you to get lost and confused if you trust them when you should not. This page outlines when and where we think you should and should not use Continue.
TL;DR:在适当的情况下利用`LLMs`可以加速你的编码过程。然而,如果你在不应该信任它们的时候依赖它们,它们也可能导致你迷失和困惑。这个页面概述了我们认为你应该在哪里以及不应该使用继续的情况。

Introduction 引言

Continue will only be as helpful as the LLM you are using to power the edits and explanations. LLMs sometimes hallucinate, so it might make up a library or invent some syntax that does not exist. If something suggested is not working or seems odd to you, it’s best to double check with a Google search to make sure you are not falling into a rabbit hole.
继续使用只会与你用来驱动编辑和解释的 LLM 的能力一样有帮助。LLMs 有时会产生幻觉,因此可能会编造一个图书馆或发明一些不存在的语法。如果建议的内容不起作用或你觉得奇怪,最好用 Google 搜索进行双重检查,以确保你没有陷入误区。

As you use Continue more, you will learn when to trust it. A great way to get started is to just play with it and start to get a sense of what works and what does not. Continue always ask you to accept / reject any changes it suggests, so you can always undo if something goes wrong.
随着您更多地使用 Continue,您将学会何时信任它。开始的一个好方法就是尝试使用它,开始了解什么有效,什么无效。Continue 总是要求您接受或拒绝任何建议的更改,所以如果出现问题,你总是可以撤销。

If you are trying to use it for a new task and don’t have a sense of how much Continue can help you complete it, it can often be helpful to start like this:
如果你正在尝试将其用于新任务,但不确定“继续”可以帮助你完成多少任务,通常可以这样开始:

'Highlight' refers to the act of selecting a text range in a file and pressing 'cmd+shift+M' (Macos) or 'ctrl+shift+M' (Windows) to include it in the Continue chat message.
“高亮显示”指的是在文件中选择文本范围并按“cmd+shift+M”(Macos)或“ctrl+shift+M”(Windows)将其包含在“继续”聊天消息中的操作。

  1. Highlight the code section(s) that you don’t understand and type "tell me how this code works" in the input box
    高亮显示你不理解的代码部分,然后在输入框中键入“告诉我这段代码是如何工作的”。
  2. If the explanation seems reasonable, then, while still highlighting the code section(s), type "how would you change this code to [INSERT TASK]?"
    如果解释似乎合理,那么在仍然高亮代码部分的同时,键入“你将如何修改这段代码以[插入任务]?”
  3. If this explanation is also pretty good, then, while still highlighting the code section(s), type /edit [INSERT TASK]. If you like the suggested diff, use cmd+shift+enter to accept the changes.
    如果这个解释也相当不错,那么在仍然高亮代码部分的同时,键入 /edit [INSERT TASK] 。如果你喜欢建议的差异,使用 cmd+shift+enter 接受更改。
  4. If it does not work on first attempt, use cmd+shift+backspace to reject the changes and try again—often it will make a different suggestion each time
    如果第一次尝试不成功,请使用 cmd+shift+backspace 拒绝更改并再次尝试——通常每次都会提出不同的建议。
  5. If it is not giving you what you want after another attempt, reject and try again with more specific / clear instructions, articulating exactly what you want it to do and not to do
    如果再次尝试后仍未给您想要的结果,请拒绝并尝试提供更具体/清晰的指令,明确说明您希望它做什么和不做什么。
  6. If this still does not work, then you likely need to break down the task into smaller sub-tasks and ask the LLM to do each of those one at a time or just do it yourself manually
    如果这仍然不起作用,那么您可能需要将任务分解为较小的子任务,并要求LLM一次执行每个子任务,或者干脆自己手动完成。

Remember: You are responsible for all code that you ship, whether it was written by you or by an LLM that you directed. This means it is crucial that you review what the LLM writes. To make this easier, we provide natural language descriptions of the actions the LLM took in the Continue GUI.
请记住:无论代码是由您编写还是由您指示的LLM编写,您都要对所有发布的代码负责。这意味着您必须仔细审查LLM编写的代码。为了使此过程更轻松,我们在继续 GUI 中提供了LLM执行的操作的自然语言描述。

When to use Continue
在何时使用继续

Here are tasks that Continue excels at helping you complete:
这里有一些“继续”可以帮助你完成的任务:

Laborious edits 费力的编辑

Continue works well in situations where find and replace does not work (i.e. “/edit change all of these to be like that”)
在“查找和替换”无法工作的情况下,继续操作效果很好(即,“/编辑将这些全部更改为那样”)

Examples 示例

  • "/edit Use 'Union' instead of a vertical bar here"
    /编辑在这里使用'并集'代替竖线
  • “/edit Make this use more descriptive variable names”
    “/edit 请使用更具描述性的变量名称”

Writing files from scratch
从头开始写文件 ​​

Continue can help you get started building React components, Python scripts, Shell scripts, Makefiles, unit tests, etc.
Continue 可以帮助您开始构建 React 组件、Python 脚本、Shell 脚本、Makefile、单元测试等。

Examples 示例

  • “/edit write a python script to get posthog events"
    /edit 编写一个 Python 脚本来获取 Posthog 事件
  • “/edit add a react component for syntax highlighted code"
    /edit 添加一个用于高亮语法的 React 组件

Creating boilerplate from scratch
从头开始创建模版

Continue can go even further. For example, it can help build the scaffolding for a Python package, which includes a typer cli app to sort the arguments and print them back out.
Continue 还可以走得更远。例如,它可以帮助构建 Python 包的框架,其中包括一个 typer cli 应用来整理参数并将其打印出来。

Examples 示例

  • “/edit use this schema to write me a SQL query that gets recently churned users”
    使用此模式编写一个 SQL 查询,获取最近流失的用户
  • “/edit create a shell script to back up my home dir to /tmp/"
    创建一个 shell 脚本,将我的主目录备份到/tmp/

Fix highlighted code 修复高亮代码

After selecting the code section(s), try to refactor it with Continue (e.g “/edit change the function to work like this” or “/edit do this everywhere”)
选择代码段后,尝试使用“继续”进行重构(例如,“/edit 将函数改写为这样工作”或“/edit 在所有地方都这样做”)。

Examples 示例

  • “/edit migrate this digital ocean terraform file into one that works for GCP”
    “/edit 将这个数字海洋 terraform 文件迁移到适用于 GCP 的文件”。
  • “/edit rewrite this function to be async”
    “/edit 重写此函数以异步执行”。

Ask about highlighted code or an entire file
提问高亮的代码或整个文件

If you don't understand how some code works, highlight it and ask "how does this code work?"
如果你不懂某些代码如何工作,高亮它并提问“这段代码是如何工作的?”

Examples 示例

  • “where in the page should I be making this request to the backend?”
    “我应该在页面的哪个部分向后端发出这个请求?”
  • “how can I communicate between these iframes?”
    “如何在这些 IFrame 之间进行通信?”

Ask about errors 提问错误问题

Continue can also help explain errors / exceptions and offer possible solutions. When you come across an error / exception in your terminal, press cmd+shift+r (MacOS) / ctrl+shift+r (Windows). This will throw the stack trace into Continue and ask for it to explain the issue to you.
继续也可以帮助解释错误/异常并提供可能的解决方案。当您在终端遇到错误/异常时,按 cmd+shift+r (MacOS)/ ctrl+shift+r (Windows)。这会将堆栈跟踪扔进继续中,并请求它向您解释问题。

Figure out what shell command to run
查找要运行的 shell 命令

Instead of switching windows and getting distracted, you can ask things like "How do I find running process on port 8000?"
你不必切换窗口或分心,可以问诸如"如何查找在 8000 端口上运行的进程?"之类的问题。

Examples 示例

  • "what is the load_dotenv library name?"
    "load_dotenv库的名称是什么?"
  • "how do I find running process on port 8000?"
    如何在端口 8000 上查找运行的进程?

Ask single-turn open-ended questions
提出单轮开放式问题​

Instead of leaving your IDE, you can ask open-ended questions that you don't expect to turn into multi-turn conversations.
你不必离开你的集成开发环境,就可以提出一些开放式问题,而不需要期待它们变成多轮对话。

Examples 示例

  • “how can I set up a Prisma schema that cascades deletes?”
    如何设置 Prisma 模式以级联删除?
  • "what is the difference between dense and sparse embeddings?"
    密集嵌入和稀疏嵌入有什么区别?

Editing small existing files
编辑现有小文件

You can highlight an entire file and ask Continue to improve it as long as the file is not too large.
你可以高亮整个文件并询问继续改进它,只要文件不太大。

Examples 示例

  • “/edit here is a connector for postgres, now write one for kafka”
    在这里编辑是一个用于 Postgres 的连接器,现在为 Kafka 写一个
  • "/edit Rewrite this API call to grab all pages"
    编辑此 API 调用以获取所有页面

Using context from multiple other files
使用来自其他多个文件的上下文

Similar to how you would make changes manually, focus on one file at a time. But if there is key information in other files, highlight those sections of code too to be used as additional context
像手动修改一样,一次专注于一个文件。但如果其他文件中包含关键信息,请也高亮显示这些代码段,作为额外的上下文参考。

Tasks with a few steps
几步的任务

There are many more tasks that Continue can help you complete. Typically, these will be tasks that don't involve too many steps to complete.
Continue 可以帮助您完成更多任务。通常,这些任务不需要太多步骤即可完成。

Examples 示例

  • “/edit make an IAM policy that creates a user with read-only access to S3”
    /edit 创建一个 IAM 策略,该策略为 S3 设置只读访问权限的用户
  • “/edit change this plot into a bar chart in this dashboard component”
    /edit 将此仪表板组件中的图表更改为条形图

When to not use Continue
何时不使用Continue

Here are tasks that Continue is not helpful with today:
这里有一些 Continue 在今天无法帮助的任务:

Deep debugging 深度调试

If you are 20 minutes into debugging a complicated issue across many files, then Continue won’t be able to help you connect the dots yet. That said, Continue can provide ideas of what you might do at different points if you share what you have figured out along the way and ask for ideas of what to try.
如果你已经在多个文件中调试一个复杂问题的 20 分钟,那么 Continue 还不能帮你理清思路。话虽如此,如果你分享你一路上发现的内容并询问尝试什么想法,Continue 可以提供你在不同点可能做什么的想法。

Multi-file edits in parallel
并行编辑多个文件

At the moment, Continue can only edit one file at a time. If you figure out which files need to change, you can direct Continue to help you change them one at a time though.
目前,Continue 一次只能编辑一个文件。如果你确定哪些文件需要更改,你可以让 Continue 帮助你一次更改一个。

Using context of the entire file
利用整个文件的上下文

If files get too large, it can be difficult for Continue to fit them into the limited LLM context windows. Try to highlight the section of code that include the relevant context. It's rare that you need the entire file.
如果文件太大,Continue可能很难将它们适应有限的LLM上下文窗口。尝试突出显示包含相关上下文的代码部分。您很少需要整个文件。

Editing large files 编辑大文件

Similarly, if you try to edit too many lines at once, you might run into context window limits. It also will likely be very slow to apply the suggestions.
同样,如果你尝试一次编辑太多行,你可能会遇到上下文窗口限制。应用建议也可能会非常慢。

Highlighting really long lines
高亮显示很长的行 ​​

If you highlight very long lines (e.g. a complex SVG), you might also run into issues like those above.
如果你高亮显示非常长的行(例如,复杂的 SVG),你可能也会遇到上述问题。

Tasks with many steps
多步骤的任务

There are other tasks that Continue won't be able to take on entirely at once. However, typically, if you figure out how to break the task into sub-tasks, you can get help from Continue with those.
还有一些任务 Continue 无法一次性全部承担。然而,通常情况下,如果你能将任务分解成子任务,你就可以从 Continue 那里获得帮助。