summaryrefslogtreecommitdiff
path: root/server/continuedev/plugins/steps/setup_model.py
blob: e7249594f7a2336b0dffeb9f2c5d9096f5e3f638 (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
from ...core.main import Step
from ...core.sdk import ContinueSDK
from ...libs.util.paths import getConfigFilePath
from ...models.filesystem import RangeInFile
from ...models.main import Range

MODEL_CLASS_TO_MESSAGE = {
    "Ollama": "To get started with Ollama, download the app from [ollama.ai](https://ollama.ai/). Once it is downloaded, be sure to pull at least one model and use its name in the model field in config.py (e.g. `model='codellama'`).",
    "LlamaCpp": "To get started with this model, clone the [`llama.cpp` repo](https://github.com/ggerganov/llama.cpp) and follow the instructions to set up the server [here](https://github.com/ggerganov/llama.cpp/blob/master/examples/server/README.md#build). Any of the parameters described in the README can be passed to the `llama_cpp_args` field in the `LlamaCpp` class in `config.py`."
}


class SetupModelStep(Step):
    model_class: str
    name: str = "Setup model in config.py"

    async def run(self, sdk: ContinueSDK):
        await sdk.ide.setFileOpen(getConfigFilePath())
        self.description = MODEL_CLASS_TO_MESSAGE.get(
            self.model_class, "Please finish setting up this model in `config.py`"
        )

        config_contents = await sdk.ide.readFile(getConfigFilePath())
        start = config_contents.find("default=") + len("default=")
        end = config_contents.find("saved=") - 1
        range = Range.from_indices(config_contents, start, end)
        range.end.line -= 1
        await sdk.ide.highlightCode(
            RangeInFile(filepath=getConfigFilePath(), range=range)
        )