start of syncing back
This commit is contained in:
parent
695abf458f
commit
a1a9c4fc01
5 changed files with 49 additions and 7 deletions
|
|
@ -40,17 +40,13 @@ class Autopilot(ContinueBaseModel):
|
|||
keep_untouched = (cached_property,)
|
||||
|
||||
def get_full_state(self) -> FullState:
|
||||
return FullState(history=self.history, active=self._active, user_input_queue=self._main_user_input_queue)
|
||||
return FullState(history=self.history, active=self._active, user_input_queue=self._main_user_input_queue, default_model=self.continue_sdk.config.default_model)
|
||||
|
||||
async def get_available_slash_commands(self) -> List[Dict]:
|
||||
return list(map(lambda x: {"name": x.name, "description": x.description}, self.continue_sdk.config.slash_commands)) or []
|
||||
|
||||
async def change_default_model(self):
|
||||
print("Changing default model")
|
||||
if self.continue_sdk.config.default_model == "gpt-4":
|
||||
self.continue_sdk.config.default_model == "gpt-3.5-turbo" # not quite correct
|
||||
else:
|
||||
self.continue_sdk.config.default_model == "gpt-4" # not quite correct
|
||||
self.continue_sdk.update_default_model()
|
||||
|
||||
async def clear_history(self):
|
||||
self.history = History.from_empty()
|
||||
|
|
|
|||
|
|
@ -86,3 +86,38 @@ def load_config(config_file: str) -> ContinueConfig:
|
|||
else:
|
||||
raise ValueError(f'Unknown config file extension: {ext}')
|
||||
return ContinueConfig(**config_dict)
|
||||
|
||||
def update_config(config_file: str):
|
||||
"""
|
||||
Update the config file with the current ContinueConfig object.
|
||||
"""
|
||||
if not os.path.exists(config_file):
|
||||
with open(config_file, 'w') as f:
|
||||
config_dict = { "default_model": "gpt-3.5-turbo" }
|
||||
json.dump(config_dict, f, indent=4)
|
||||
|
||||
_, ext = os.path.splitext(config_file)
|
||||
if ext == '.yaml':
|
||||
|
||||
with open(config_file, 'w') as f:
|
||||
config_dict = yaml.safe_load(f)
|
||||
|
||||
if config_dict["default_model"] == "gpt-4":
|
||||
config_dict["default_model"] = "gpt-3.5-turbo"
|
||||
else:
|
||||
config_dict["default_model"] = "gpt-4"
|
||||
|
||||
with open(config_file, 'w') as f:
|
||||
json.dump(config_dict, f, indent=4)
|
||||
|
||||
elif ext == '.json':
|
||||
with open(config_file, 'r') as f:
|
||||
config_dict = json.load(f)
|
||||
|
||||
if config_dict["default_model"] == "gpt-4":
|
||||
config_dict["default_model"] = "gpt-3.5-turbo"
|
||||
else:
|
||||
config_dict["default_model"] = "gpt-4"
|
||||
|
||||
with open(config_file, 'w') as f:
|
||||
json.dump(config_dict, f, indent=4)
|
||||
|
|
@ -114,6 +114,7 @@ class FullState(ContinueBaseModel):
|
|||
history: History
|
||||
active: bool
|
||||
user_input_queue: List[str]
|
||||
default_model: str
|
||||
|
||||
|
||||
class ContinueSDK:
|
||||
|
|
|
|||
|
|
@ -6,7 +6,7 @@ import os
|
|||
from ..steps.core.core import DefaultModelEditCodeStep
|
||||
from ..models.main import Range
|
||||
from .abstract_sdk import AbstractContinueSDK
|
||||
from .config import ContinueConfig, load_config
|
||||
from .config import ContinueConfig, load_config, update_config
|
||||
from ..models.filesystem_edit import FileEdit, FileSystemEdit, AddFile, DeleteFile, AddDirectory, DeleteDirectory
|
||||
from ..models.filesystem import RangeInFile
|
||||
from ..libs.llm.hf_inference_api import HuggingFaceInferenceAPI
|
||||
|
|
@ -170,6 +170,15 @@ class ContinueSDK(AbstractContinueSDK):
|
|||
else:
|
||||
return ContinueConfig()
|
||||
|
||||
def update_default_model(self):
|
||||
dir = self.ide.workspace_directory
|
||||
yaml_path = os.path.join(dir, '.continue', 'config.yaml')
|
||||
json_path = os.path.join(dir, '.continue', 'config.json')
|
||||
if os.path.exists(yaml_path):
|
||||
update_config(yaml_path)
|
||||
else:
|
||||
update_config(json_path)
|
||||
|
||||
def set_loading_message(self, message: str):
|
||||
# self.__autopilot.set_loading_message(message)
|
||||
raise NotImplementedError()
|
||||
|
|
|
|||
|
|
@ -230,6 +230,7 @@ function GUI(props: GUIProps) {
|
|||
console.log("CLIENT ON STATE UPDATE: ", client, client?.onStateUpdate);
|
||||
client?.onStateUpdate((state) => {
|
||||
// Scroll only if user is at very bottom of the window.
|
||||
setUsingFastModel(state.using_fast_model);
|
||||
const shouldScrollToBottom =
|
||||
topGuiDivRef.current &&
|
||||
topGuiDivRef.current?.offsetHeight - window.scrollY < 100;
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue