📝 docs page for migration

This commit is contained in:
Nate Sesti 2023-11-14 23:57:31 -08:00
parent 08116e5808
commit 35e08e5f9b
5 changed files with 94 additions and 15 deletions

View file

@ -0,0 +1,25 @@
# Continue Configuration File Formats
On November 15, 2023, we migrated to using JSON as the primary config file format. If you previously used Continue, we will have attempted to automatically translate your existing config.py into a config.json file. If this fails, we will fallback to a default config.json.
The JSON format provides stronger guiderails, making it easier to write a valid config, while still allowing Intellisense in VS Code.
If you need any help migrating, please reach out to us on Discord.
## Configuration as Code
For configuration that requires code, we now provide a simpler interface that works alongside config.json. In the same folder, `~/.continue`, create a file named `config.py` (the same name as before) and add a function called `modify_config`. This function should take a `ContinueConfig` object as its only argument, and return a `ContinueConfig` object. This allows you to modify the initial configuration object defined in your `config.json`. Here's an example that cuts the temperature in half:
```python
from continuedev.core.config import ContinueConfig
def modify_config(config: ContinueConfig) -> ContinueConfig:
config.completion_options.temperature /= 2
return config
```
To summarize, these are the steps taken to load your configuration:
1. Load `~/.continue/config.json`
2. Convert this into a `ContinueConfig` object
3. If `~/.continue/config.py` exists and has defined `modify_config` correctly, call `modify_config` with the `ContinueConfig` object to generate the final configuration

View file

@ -13,3 +13,58 @@ def modify_config(config: ContinueConfig) -> ContinueConfig:
return config
"""
default_config_json = """\
{
"models": [
{
"title": "GPT-4",
"provider": "openai-free-trial",
"model": "gpt-4"
},
{
"title": "GPT-3.5-Turbo",
"provider": "openai-free-trial",
"model": "gpt-3.5-turbo"
}
],
"model_roles": {
"default": "GPT-4",
"summarize": "GPT-3.5-Turbo"
},
"slash_commands": [
{
"name": "edit",
"description": "Edit highlighted code",
"step": "EditHighlightedCodeStep"
},
{
"name": "config",
"description": "Customize Continue",
"step": "OpenConfigStep"
},
{
"name": "comment",
"description": "Write comments for the highlighted code",
"step": "CommentCodeStep"
},
{
"name": "share",
"description": "Download and share this session",
"step": "ShareSessionStep"
},
{
"name": "cmd",
"description": "Generate a shell command",
"step": "GenerateShellCommandStep"
}
],
"custom_commands": [
{
"name": "test",
"prompt": "Write a comprehensive set of unit tests for the selected code. It should setup, run tests that check for correctness including important edge cases, and teardown. Ensure that the tests are complete and sophisticated. Give the tests just as chat output, don't edit any file.",
"description": "Write unit tests for highlighted code"
}
]
}
"""

View file

@ -15,4 +15,4 @@ class OpenConfigStep(Step):
)
async def run(self, sdk: ContinueSDK):
await sdk.ide.setFileOpen(getConfigFilePath())
await sdk.ide.setFileOpen(getConfigFilePath(json=True))

View file

@ -1,4 +1,4 @@
from ...core.main import Step
from ...core.main import SetStep, Step
from ...core.sdk import ContinueSDK
from ...libs.util.paths import getConfigFilePath
from ...models.filesystem import RangeInFile
@ -24,16 +24,9 @@ class SetupModelStep(Step):
hide: bool = True
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)
await sdk.ide.setFileOpen(getConfigFilePath(json=True))
yield SetStep(
description=MODEL_CLASS_TO_MESSAGE.get(
self.model_class, "Please finish setting up this model in `config.py`"
)
)

View file

@ -1,3 +1,4 @@
import os
import traceback
from typing import Dict, Optional
@ -5,6 +6,7 @@ from ..core.autopilot import Autopilot
from ..core.config import ContinueConfig
from ..core.context import ContextManager
from ..core.main import SessionState
from ..libs.constants.default_config import default_config_json
from ..libs.index.build_index import build_index
from ..libs.util.create_async_task import create_async_task
from ..libs.util.devdata import dev_data_logger
@ -74,7 +76,11 @@ class Window:
async def display_config_error(self):
if self._error_loading_config is not None:
await self.ide.setFileOpen(getConfigFilePath())
if not os.path.exists(getConfigFilePath(json=True)):
with open(getConfigFilePath(json=True), "w") as f:
f.write(default_config_json)
await self.ide.setFileOpen(getConfigFilePath(json=True))
await self.ide.showMessage(
f"""We found an error while loading your config.py. For now, Continue is falling back to the default configuration. If you need help solving this error, please reach out to us on Discord by clicking the question mark button in the bottom right.\n\n{self._error_loading_config}"""
)