diff options
-rw-r--r-- | .github/workflows/main.yaml | 25 | ||||
-rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 50 | ||||
-rw-r--r-- | continuedev/src/continuedev/libs/llm/anthropic.py | 4 | ||||
-rw-r--r-- | cxf.py | 14 |
4 files changed, 60 insertions, 33 deletions
diff --git a/.github/workflows/main.yaml b/.github/workflows/main.yaml index 7787ddad..365f7b7d 100644 --- a/.github/workflows/main.yaml +++ b/.github/workflows/main.yaml @@ -107,19 +107,18 @@ jobs: run: | cd extension npm run package - npx vsce publish patch -p ${{ secrets.VSCE_TOKEN }} - - - name: Commit changes - run: | - git config --local user.email "action@github.com" - git config --local user.name "GitHub Action" - git commit -am "ci: 💚 Update package.json version [skip ci]" - - - name: Push changes - uses: ad-m/github-push-action@master - with: - github_token: ${{ secrets.GITHUB_TOKEN }} - branch: ${{ github.ref }} + # npx vsce publish patch -p ${{ secrets.VSCE_TOKEN }} + # - name: Commit changes + # run: | + # git config --local user.email "action@github.com" + # git config --local user.name "GitHub Action" + # git commit -am "ci: 💚 Update package.json version [skip ci]" + + # - name: Push changes + # uses: ad-m/github-push-action@master + # with: + # github_token: ${{ secrets.GITHUB_TOKEN }} + # branch: ${{ github.ref }} - name: Upload .vsix artifact uses: actions/upload-artifact@v2 diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py index 57e2c099..42cfbcb9 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -1,7 +1,7 @@ -from functools import cached_property import traceback -from typing import Coroutine, Dict, Literal, Union +from typing import Coroutine, Union import os +import importlib from ..plugins.steps.core.core import DefaultModelEditCodeStep from ..models.main import Range @@ -164,6 +164,52 @@ class ContinueSDK(AbstractContinueSDK): _last_valid_config: ContinueConfig = None def _load_config_dot_py(self) -> ContinueConfig: + # Read the file content + with open(os.path.expanduser('~/.continue/config.py')) as file: + config_content = file.read() + + def load_module(module_name: str, class_names: List[str]): + # from anthropic import AsyncAnthropic + module = importlib.import_module(module_name) + for class_name in class_names: + globals()[class_name] = getattr(module, class_name) + + while True: + # Execute the file content + locals_var = {} + try: + import importlib.util + spec = importlib.util.spec_from_file_location( + "config", "/Users/natesesti/.continue/config.py") + config = importlib.util.module_from_spec(spec) + spec.loader.exec_module(config) + + return config.config + # exec(config_content, globals(), locals_var) + # print("Done executing, ", locals_var) + # return locals_var['config'] + except ModuleNotFoundError as e: + print("ModuleNotFoundError") + print(e) + print(traceback.format_exception(e)) + formatted = traceback.format_exception(e) + line = formatted[-2].split("\n")[-2].strip().split() + # Parse the module name and class name from the error message + # Example: ModuleNotFoundError: No module named 'continuedev.src.continuedev.plugins.context_providers.google' + + # Get the module name + module_name = line[1] + # Get the class name + class_names = list(map(lambda x: x.replace(",", ""), filter(lambda x: x.strip() != "", line[3:]))) + + # Load the module + print( + f"Loading module {module_name} with class names {class_names}") + load_module(module_name, class_names) + except Exception as e: + print("Failed to execute config.py: ", e) + raise e + # Use importlib to load the config file config.py at the given path path = getConfigFilePath() diff --git a/continuedev/src/continuedev/libs/llm/anthropic.py b/continuedev/src/continuedev/libs/llm/anthropic.py index ec1b7e40..e6b88d03 100644 --- a/continuedev/src/continuedev/libs/llm/anthropic.py +++ b/continuedev/src/continuedev/libs/llm/anthropic.py @@ -17,10 +17,6 @@ class AnthropicLLM(LLM): class Config: arbitrary_types_allowed = True - def __init__(self, model: str, system_message: str = None): - self.model = model - self.system_message = system_message - async def start(self, *, api_key: Optional[str] = None, **kwargs): self._async_client = AsyncAnthropic(api_key=api_key) diff --git a/cxf.py b/cxf.py deleted file mode 100644 index b8610999..00000000 --- a/cxf.py +++ /dev/null @@ -1,14 +0,0 @@ -from cx_Freeze import setup, Executable - -setup( - name="Continue", - version="0.1", - description="Continue Server", - executables=[Executable("run.py")], - - options={ - "build_exe": { - "excludes": ["unnecessary_module"], - }, - }, -) |