diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-09-04 12:31:04 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-09-04 12:31:04 -0700 |
commit | d103263030ad52debe73bd131c71bbf17f545956 (patch) | |
tree | 135d2c16291e36972ef218f973cbcf311a199fe4 /continuedev/src | |
parent | 45d9bab5cea745573be7112d7130089c596c88fa (diff) | |
download | sncontinue-d103263030ad52debe73bd131c71bbf17f545956.tar.gz sncontinue-d103263030ad52debe73bd131c71bbf17f545956.tar.bz2 sncontinue-d103263030ad52debe73bd131c71bbf17f545956.zip |
fix: :bug: fix context length bug for /edit
Diffstat (limited to 'continuedev/src')
-rw-r--r-- | continuedev/src/continuedev/core/lsp.py | 10 | ||||
-rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 9 | ||||
-rw-r--r-- | continuedev/src/continuedev/plugins/steps/core/core.py | 4 | ||||
-rw-r--r-- | continuedev/src/continuedev/plugins/steps/on_traceback.py | 2 |
4 files changed, 18 insertions, 7 deletions
diff --git a/continuedev/src/continuedev/core/lsp.py b/continuedev/src/continuedev/core/lsp.py index 5c1f9989..0f4d5a86 100644 --- a/continuedev/src/continuedev/core/lsp.py +++ b/continuedev/src/continuedev/core/lsp.py @@ -5,12 +5,14 @@ import threading from typing import List, Optional from pydantic import BaseModel +from pylsp.python_lsp import PythonLSPServer, start_tcp_lang_server from ..libs.lspclient.json_rpc_endpoint import JsonRpcEndpoint from ..libs.lspclient.lsp_client import LspClient from ..libs.lspclient.lsp_endpoint import LspEndpoint from ..libs.lspclient.lsp_structs import Position as LspPosition from ..libs.lspclient.lsp_structs import SymbolInformation, TextDocumentIdentifier +from ..libs.util.logging import logger from ..models.filesystem import RangeInFile from ..models.main import Position, Range @@ -57,6 +59,14 @@ class SocketFileWrapper: def create_json_rpc_endpoint(use_subprocess: Optional[str] = None): if use_subprocess is None: + try: + threading.Thread( + target=start_tcp_lang_server, + args=("localhost", 8080, False, PythonLSPServer), + ).start() + except Exception as e: + logger.warning("Could not start TCP server: %s", e) + # Connect to the server s = socket.socket(socket.AF_INET, socket.SOCK_STREAM) s.connect(("localhost", 8080)) diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py index 7dca600d..b25d4566 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -3,7 +3,6 @@ import traceback from typing import Coroutine, List, Optional, Union from ..libs.llm import LLM -from ..libs.util.create_async_task import create_async_task from ..libs.util.logging import logger from ..libs.util.paths import getConfigFilePath from ..libs.util.telemetry import posthog_logger @@ -97,16 +96,16 @@ class ContinueSDK(AbstractContinueSDK): try: sdk.lsp = ContinueLSPClient( workspace_dir=sdk.ide.workspace_directory, - use_subprocess="python3.10 -m pylsp", + # use_subprocess="python3.10 -m pylsp", ) await sdk.lsp.start() except: logger.warning("Failed to start LSP client", exc_info=True) sdk.lsp = None - create_async_task( - start_lsp(), on_error=lambda e: logger.error("Failed to setup LSP: %s", e) - ) + # create_async_task( + # start_lsp(), on_error=lambda e: logger.error("Failed to setup LSP: %s", e) + # ) # When the config is loaded, setup posthog logger posthog_logger.setup(sdk.ide.unique_id, sdk.config.allow_anonymous_telemetry) diff --git a/continuedev/src/continuedev/plugins/steps/core/core.py b/continuedev/src/continuedev/plugins/steps/core/core.py index 740c75bc..ba67c932 100644 --- a/continuedev/src/continuedev/plugins/steps/core/core.py +++ b/continuedev/src/continuedev/plugins/steps/core/core.py @@ -635,7 +635,9 @@ Please output the code to be inserted at the cursor in order to fulfill the user messages = rendered generator = model_to_use.stream_chat( - messages, temperature=sdk.config.temperature, max_tokens=max_tokens + messages, + temperature=sdk.config.temperature, + max_tokens=min(max_tokens, model_to_use.context_length // 2), ) posthog_logger.capture_event( diff --git a/continuedev/src/continuedev/plugins/steps/on_traceback.py b/continuedev/src/continuedev/plugins/steps/on_traceback.py index 13d7aa38..078309d0 100644 --- a/continuedev/src/continuedev/plugins/steps/on_traceback.py +++ b/continuedev/src/continuedev/plugins/steps/on_traceback.py @@ -51,7 +51,7 @@ class DefaultOnTracebackStep(Step): # And this function is where you can get arbitrarily fancy about adding context async def run(self, sdk: ContinueSDK): - if get_python_traceback(self.output) is not None: + if get_python_traceback(self.output) is not None and sdk.lsp is not None: await sdk.run_step(SolvePythonTracebackStep(output=self.output)) return |