📝 updates to automigration and docs
This commit is contained in:
parent
b69a6dc271
commit
a707a5db0f
7 changed files with 140 additions and 31 deletions
|
|
@ -1,25 +0,0 @@
|
|||
# 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
|
||||
79
docs/docs/walkthroughs/config-file-migration.md
Normal file
79
docs/docs/walkthroughs/config-file-migration.md
Normal file
|
|
@ -0,0 +1,79 @@
|
|||
# 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. Below we share a list of changes that were made in case you need to manually migrate your config.
|
||||
|
||||
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
|
||||
|
||||
## List of Changes
|
||||
|
||||
### `completion_options`
|
||||
|
||||
The properties `top_p`, `top_k`, `temperature`, `presence_penalty`, and `frequency_penalty` have been moved into a single object called `completion_options`. It can be specified at the top level of the config or within a `models` object.
|
||||
|
||||
### `request_options`
|
||||
|
||||
The properties `timeout`, `verify_ssl`, `ca_bundle_path`, `proxy`, and `headers` have been moved into a single object called `request_options`, which can be specified for each `models` object.
|
||||
|
||||
### The `model` property
|
||||
|
||||
Instead of writing something like `Ollama(model="phind-codellama:34b", ...)`, where the `model` property was different depending on the provider and had to be exactly correct, we now offer a default set of models, including the following:
|
||||
|
||||
```python
|
||||
# OpenAI
|
||||
"gpt-3.5-turbo",
|
||||
"gpt-3.5-turbo-16k",
|
||||
"gpt-4",
|
||||
"gpt-3.5-turbo-0613",
|
||||
"gpt-4-32k",
|
||||
"gpt-4-1106-preview",
|
||||
# Open-Source
|
||||
"mistral-7b",
|
||||
"llama2-7b",
|
||||
"llama2-13b",
|
||||
"codellama-7b",
|
||||
"codellama-13b",
|
||||
"codellama-34b",
|
||||
"phind-codellama-34b",
|
||||
"wizardcoder-7b",
|
||||
"wizardcoder-13b",
|
||||
"wizardcoder-34b",
|
||||
"zephyr-7b",
|
||||
"codeup-13b",
|
||||
"deepseek-1b",
|
||||
"deepseek-7b",
|
||||
"deepseek-33b",
|
||||
# Anthropic
|
||||
"claude-2",
|
||||
# Google PaLM
|
||||
"chat-bison-001",
|
||||
```
|
||||
|
||||
If you want to use a model not listed here, you can still do that by specifying whichever value of `model` you need. But if there's something you think we should add as a default, let us know!
|
||||
|
||||
### Prompt template auto-detection
|
||||
|
||||
Based on the `model` property, we now attempt to [autodetect](https://github.com/continuedev/continue/blob/108e00c7db9cad110c5df53bdd0436b286b92466/server/continuedev/core/config_utils/shared.py#L38) the prompt template. If you want to be explicit, you can select one of our prompt template types (`"llama2", "alpaca", "zephyr", "phind", "anthropic", "chatml", "deepseek"`) or write a custom prompt template in `config.py`.
|
||||
|
||||
### `PromptTemplate`
|
||||
|
||||
If you were previously using the `PromptTemplate` class in your `config.py` to write a custom template, we have moved it from `continuedev.libs.llm.base` to `continuedev.models.llm`.
|
||||
|
|
@ -445,7 +445,8 @@
|
|||
"llama2-13b",
|
||||
"codellama-7b",
|
||||
"codellama-13b",
|
||||
"codellama-34b"
|
||||
"codellama-34b",
|
||||
"phind-codellama-34b"
|
||||
]
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -466,7 +466,20 @@ class ContinueConfig(BaseModel):
|
|||
@staticmethod
|
||||
def from_filepath(filepath: str, retry: bool = True) -> "ContinueConfig":
|
||||
if filepath.endswith(".json"):
|
||||
serialized_config = json.load(open(filepath))
|
||||
try:
|
||||
contents = open(filepath).read()
|
||||
if contents.strip() == "":
|
||||
raise ValueError("Empty config file")
|
||||
|
||||
serialized_config = json.loads(contents)
|
||||
|
||||
except ValueError as e:
|
||||
logger.warning(f"Found empty config.json at {filepath}: {e}")
|
||||
with open(filepath, "w") as f:
|
||||
f.write(default_config_json)
|
||||
|
||||
serialized_config = json.load(open(filepath))
|
||||
|
||||
initial_config = ContinueConfig.from_serialized_config(
|
||||
SerializedContinueConfig(**serialized_config)
|
||||
)
|
||||
|
|
@ -579,16 +592,47 @@ class ContinueConfig(BaseModel):
|
|||
self.models.edit,
|
||||
self.models.summarize,
|
||||
]
|
||||
titles = set()
|
||||
seen = set()
|
||||
models: List[LLM] = []
|
||||
for model in pre_models:
|
||||
if model is None or model.title in titles:
|
||||
if model is None or (model.title, model.model) in seen:
|
||||
# Remove duplicate models
|
||||
continue # : )
|
||||
|
||||
titles.add(model.title)
|
||||
seen.add((model.title, model.model))
|
||||
models.append(model)
|
||||
|
||||
completion_options_keys = [
|
||||
"temperature",
|
||||
"top_p",
|
||||
"top_k",
|
||||
"max_tokens",
|
||||
"presence_penalty",
|
||||
"frequency_penalty",
|
||||
]
|
||||
request_options_keys = [
|
||||
"timeout",
|
||||
"verify_ssl",
|
||||
"ca_bundle_path",
|
||||
"proxy",
|
||||
"headers",
|
||||
]
|
||||
for model in models:
|
||||
for key in completion_options_keys:
|
||||
if hasattr(model, key):
|
||||
setattr(model.completion_options, key, getattr(model, key))
|
||||
delattr(model, key)
|
||||
|
||||
for key in request_options_keys:
|
||||
if hasattr(model, key):
|
||||
setattr(model.request_options, key, getattr(model, key))
|
||||
delattr(model, key)
|
||||
|
||||
for key in completion_options_keys:
|
||||
if hasattr(self, key):
|
||||
setattr(self.completion_options, key, getattr(self, key))
|
||||
delattr(self, key)
|
||||
|
||||
BACKUP_TITLE = "LLM"
|
||||
|
||||
serialized_models = [
|
||||
|
|
|
|||
|
|
@ -48,6 +48,7 @@ class TogetherLLM(LLM):
|
|||
"llama2-13b": "togethercomputer/llama-2-13b-chat",
|
||||
"llama2-70b": "togethercomputer/llama-2-70b-chat",
|
||||
"mistral-7b": "mistralai/Mistral-7B-Instruct-v0.1",
|
||||
"phind-codellama-34b": "Phind/Phind-CodeLlama-34B-v2"
|
||||
}.get(self.model, self.model)
|
||||
return args
|
||||
|
||||
|
|
|
|||
|
|
@ -104,8 +104,9 @@ class Window:
|
|||
async def migrate_fn():
|
||||
if self.ide is not None:
|
||||
await self.ide.showMessage(
|
||||
"Continue has migrated to using a JSON config file (config.json). To learn more, visit [https://continue.dev/docs/config-file-migration](https://continue.dev/docs/config-file-migration)."
|
||||
"Continue has migrated to using a JSON config file (config.json). An auto-migration was attempted, but you may want to double check that the settings match your previous setup. To learn more, visit [https://continue.dev/docs/walkthroughs/config-file-migration](https://continue.dev/docs/walkthroughs/config-file-migration) or reach out on Discord."
|
||||
)
|
||||
await self.ide.setFileOpen(getConfigFilePath(json=True))
|
||||
|
||||
await migrate(
|
||||
"config_json_001",
|
||||
|
|
|
|||
|
|
@ -66,6 +66,14 @@ def test_load_old_config(config_filename):
|
|||
config = ContinueConfig.load_default()
|
||||
validate_continue_config(config)
|
||||
|
||||
if config_filename == "config_2.py":
|
||||
model = config.models.default
|
||||
assert model.completion_options.temperature == 0.1
|
||||
assert model.completion_options.top_p == 0.75
|
||||
assert model.completion_options.top_k == 40
|
||||
assert model.context_length == 16384
|
||||
assert model.request_options.timeout == 8000
|
||||
|
||||
|
||||
def validate_continue_config(config: ContinueConfig):
|
||||
ctx_provs = config.get_context_provider_descriptions()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue