diff options
author | Nate Sesti <sestinj@gmail.com> | 2023-09-17 15:59:13 -0700 |
---|---|---|
committer | Nate Sesti <sestinj@gmail.com> | 2023-09-17 15:59:13 -0700 |
commit | 0b2a23a1d003c88a9f2f6c4b03117d815b1c456d (patch) | |
tree | 2989c85ed8f3f726cd241997c406a5b9b1cd59da | |
parent | c350c72b1d2f8e518296b4baf76d4318e7ceee2e (diff) | |
download | sncontinue-0b2a23a1d003c88a9f2f6c4b03117d815b1c456d.tar.gz sncontinue-0b2a23a1d003c88a9f2f6c4b03117d815b1c456d.tar.bz2 sncontinue-0b2a23a1d003c88a9f2f6c4b03117d815b1c456d.zip |
refactor: :recycle: from continuedev import run
-rw-r--r-- | continuedev/src/continuedev/__init__.py | 19 | ||||
-rw-r--r-- | continuedev/src/continuedev/headless/__init__.py | 15 | ||||
-rw-r--r-- | docs/docs/walkthroughs/headless-mode.md | 6 |
3 files changed, 22 insertions, 18 deletions
diff --git a/continuedev/src/continuedev/__init__.py b/continuedev/src/continuedev/__init__.py index e69de29b..1b4776a8 100644 --- a/continuedev/src/continuedev/__init__.py +++ b/continuedev/src/continuedev/__init__.py @@ -0,0 +1,19 @@ +import asyncio +from typing import Union + +from .core.config import ContinueConfig +from .core.main import Step +from .headless import start_headless_session + + +def run(step_or_config: Union[Step, ContinueConfig]): + if isinstance(step_or_config, ContinueConfig): + config = step_or_config + else: + config = ContinueConfig() + config.steps_on_startup = [step_or_config] + + loop = asyncio.get_event_loop() + loop.run_until_complete(start_headless_session(config=config)) + tasks = asyncio.all_tasks(loop) + loop.run_until_complete(asyncio.gather(*tasks)) diff --git a/continuedev/src/continuedev/headless/__init__.py b/continuedev/src/continuedev/headless/__init__.py index fb2c9768..2ecdcce6 100644 --- a/continuedev/src/continuedev/headless/__init__.py +++ b/continuedev/src/continuedev/headless/__init__.py @@ -1,10 +1,8 @@ -import asyncio from typing import Optional, Union import typer from ..core.config import ContinueConfig -from ..core.main import Step from ..server.session_manager import Session, session_manager from .headless_ide import LocalIdeProtocol @@ -20,16 +18,3 @@ async def start_headless_session( ide = LocalIdeProtocol() return await session_manager.new_session(ide, config=config) - - -def run(step_or_config: Union[Step, ContinueConfig]): - if isinstance(step_or_config, ContinueConfig): - config = step_or_config - else: - config = ContinueConfig() - config.steps_on_startup = [step_or_config] - - loop = asyncio.get_event_loop() - loop.run_until_complete(start_headless_session(config=config)) - tasks = asyncio.all_tasks(loop) - loop.run_until_complete(asyncio.gather(*tasks)) diff --git a/docs/docs/walkthroughs/headless-mode.md b/docs/docs/walkthroughs/headless-mode.md index 16252f1f..913bff78 100644 --- a/docs/docs/walkthroughs/headless-mode.md +++ b/docs/docs/walkthroughs/headless-mode.md @@ -5,7 +5,7 @@ To use headless mode: 1. `pip install continuedev` (using a virtual environment is recommended) -2. Import `continuedev` and call `run_step_headless` with the `Step` you would like to run +2. Import `continuedev` and call `run` with the `Step` you would like to run Example: @@ -19,7 +19,7 @@ def say_hello(name: str): and this function is imported and used in multiple places throughout your codebase. But the name parameter is new, and you need to change the function call everywhere it is used. You can use the script below to edit all usages of the function in your codebase: ```python -from continuedev.headless import run_step_headless +from continuedev import run from continuedev.models.main import Position, PositionInFile from continuedev.plugins.steps.refactor import RefactorReferencesStep @@ -30,7 +30,7 @@ step = RefactorReferencesStep( position=Position(line=0, character=5), ), ) -run_step_headless(step=step) +run(step) ``` Here we use Continue's built-in `RefactorReferencesStep`. By passing it the location (filepath and position) of the symbol (function, variable, etc.) that we want to update, Continue will automatically find all references to that symbol and prompt an LLM to make the edit requested in the `user_input` field. |