summaryrefslogtreecommitdiff
path: root/docs/docs/concepts/sdk.md
blob: 21190aa8b043602e0ec8ebf41e0a893bde97f8e0 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
# SDK

**TODO: Better explain in one sentence what this is and what its purpose is**

:::info
The **Continue SDK** gives you all the tools you need to automate software development tasks in one convenient and standard location (e.g. open a directory, edit a file, call an LLM, etc), which you can use when defining how a step should work and composing them with other steps.
:::

## Details

- The ContinueSDK has a `run_step` method, which allows Steps to be composable
- The reason you want to run it with `run_step` instead of creating a Step and calling `step.run(...)` is so Continue can automatically keep track of the order of all steps run, and allow for reversibility, etc...
- The ContinueSDK also contains functions for very common steps, like `edit_file`, `add_file`, `run` (to run shell commands), and a few others
- `sdk.history` lets you access the history of past steps
- `sdk.llm` lets you use the Autopilot's language model like `sdk.llm.complete`
- `sdk.ide` lets you take any action within the connected IDE (this is where the IDE protocol is called)

## Properties

### `sdk.ide`

`sdk.ide` is an instance of the class `AbstractIdeProtocolServer`, which contains all the methods you might need to interact with the IDE. This includes things like reading, editing, saving, and opening files as well as getting the workspace directory, displaying suggestions, and more. The goal is to have an IDE agnostic way of interacting with IDEs, so that Steps are portable across VS Code, Sublime, Code, or any other editor you use.

### `sdk.models`

`sdk.models` is an instance of the `Models` class, containing many of the most commonly used LLMs or other foundation models. You can access a model (starcoder for example) like `starcoder = sdk.models.starcoder`. Right now, all of the models are `LLM`s, meaning that they offer the `complete` method, used like `bubble_sort_code = await starcoder.complete("# Write a bubble sort function below, in Python:\n")`.

### `sdk.history`

`sdk.history` is the `History` object that contains all information about previously run steps`. See the documentation page to learn more.

## Methods

### `run_step`

`run_step` is what allows Steps to be composable. While at the core, steps are run by calling `step.run(continue_sdk)`, using `sdk.run_step(step)` automatically fills in the `ContinueSDK` parameter, takes care of recording the step in history, and automatically updates the GUI.

The below methods are all just shorthand for very common steps.

### `apply_filesystem_edit`

`apply_filesystem_edit` takes a FileSystemEdit (subclasses include Add/DeleteFile/Directory and EditFile) and runs the `FileSystemEditStep`.

### `wait_for_user_input` and `wait_for_user_confirmation`

`wait_for_user_input` and `wait_for_user_confirmation` both run steps that will open a cell prompting the user for some input, in the former case asking for a text input, and in the latter case just asking for confirmation through a button click. We are considering allowing for more complex forms in the future, potentially even dynamically generated by LLMs, so please reach out if this would be useful.

### `run`

`run` will run either a single command or a list of shell commands.

### `edit_file`

`edit_file` takes a filename and prompt, then will use the EditCodeStep to apply the edits requested in natural language in the prompt to the file. The EditCodeStep uses StarCoder to do this; if you have reason to customize this functionality, you can define a custom step and call that.

### `add/delete_file/directory`

`add/delete_file/directory` do just that.

### `get_user_secret`

`get_user_secret` will retrieve a secret from the local .env file or, if it doesn't exist, prompt the user to enter the secret before moving on.