diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-06-02 00:57:57 -0400 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-06-02 00:57:57 -0400 | 
| commit | 769bf31da03f4c5d3145d885cff897109d63f246 (patch) | |
| tree | 4875085a14a9ddfae9c3c2741dd6cc0a7c73d286 /continuedev/src | |
| parent | 3ff98317831d80436b266b424a2613fcf1d7205c (diff) | |
| download | sncontinue-769bf31da03f4c5d3145d885cff897109d63f246.tar.gz sncontinue-769bf31da03f4c5d3145d885cff897109d63f246.tar.bz2 sncontinue-769bf31da03f4c5d3145d885cff897109d63f246.zip | |
agent -> autopilot
Diffstat (limited to 'continuedev/src')
| -rw-r--r-- | continuedev/src/continuedev/core/agent.py | 4 | ||||
| -rw-r--r-- | continuedev/src/continuedev/core/sdk.py | 18 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/util/copy_codebase.py | 16 | ||||
| -rw-r--r-- | continuedev/src/continuedev/server/ide.py | 16 | ||||
| -rw-r--r-- | continuedev/src/continuedev/server/notebook.py | 10 | ||||
| -rw-r--r-- | continuedev/src/continuedev/server/session_manager.py | 20 | 
6 files changed, 42 insertions, 42 deletions
| diff --git a/continuedev/src/continuedev/core/agent.py b/continuedev/src/continuedev/core/agent.py index 29c695af..6e920ab4 100644 --- a/continuedev/src/continuedev/core/agent.py +++ b/continuedev/src/continuedev/core/agent.py @@ -14,7 +14,7 @@ from .sdk import ContinueSDK  import asyncio -class Agent(ContinueBaseModel): +class Autopilot(ContinueBaseModel):      policy: Policy      ide: AbstractIdeProtocolServer      history: History = History.from_empty() @@ -116,7 +116,7 @@ class Agent(ContinueBaseModel):      async def run_from_step(self, step: "Step"):          # if self._active: -        #     raise RuntimeError("Agent is already running") +        #     raise RuntimeError("Autopilot is already running")          self._active = True          next_step = step diff --git a/continuedev/src/continuedev/core/sdk.py b/continuedev/src/continuedev/core/sdk.py index ce0c53fd..af7754cc 100644 --- a/continuedev/src/continuedev/core/sdk.py +++ b/continuedev/src/continuedev/core/sdk.py @@ -14,7 +14,7 @@ from ..libs.steps.core.core import *  from .env import get_env_var, make_sure_env_exists -class Agent: +class Autopilot:      pass @@ -43,17 +43,17 @@ class ContinueSDK:      ide: AbstractIdeProtocolServer      steps: ContinueSDKSteps      models: Models -    __agent: Agent +    __autopilot: Autopilot -    def __init__(self, agent: Agent): -        self.ide = agent.ide -        self.__agent = agent +    def __init__(self, autopilot: Autopilot): +        self.ide = autopilot.ide +        self.__autopilot = autopilot          self.steps = ContinueSDKSteps(self)          self.models = Models(self)      @property      def history(self) -> History: -        return self.__agent.history +        return self.__autopilot.history      async def _ensure_absolute_path(self, path: str) -> str:          if os.path.isabs(path): @@ -61,13 +61,13 @@ class ContinueSDK:          return os.path.join(await self.ide.getWorkspaceDirectory(), path)      async def run_step(self, step: Step) -> Coroutine[Observation, None, None]: -        return await self.__agent._run_singular_step(step) +        return await self.__autopilot._run_singular_step(step)      async def apply_filesystem_edit(self, edit: FileSystemEdit):          return await self.run_step(FileSystemEditStep(edit=edit))      async def wait_for_user_input(self) -> str: -        return await self.__agent.wait_for_user_input() +        return await self.__autopilot.wait_for_user_input()      async def wait_for_user_confirmation(self, prompt: str):          return await self.run_step(WaitForUserConfirmationStep(prompt=prompt)) @@ -136,5 +136,5 @@ class ContinueSDK:              return ContinueConfig()      def set_loading_message(self, message: str): -        # self.__agent.set_loading_message(message) +        # self.__autopilot.set_loading_message(message)          raise NotImplementedError() diff --git a/continuedev/src/continuedev/libs/util/copy_codebase.py b/continuedev/src/continuedev/libs/util/copy_codebase.py index ef1db72b..af957a34 100644 --- a/continuedev/src/continuedev/libs/util/copy_codebase.py +++ b/continuedev/src/continuedev/libs/util/copy_codebase.py @@ -5,7 +5,7 @@ from watchdog.observers import Observer  from watchdog.events import PatternMatchingEventHandler  from ..models.main import FileEdit, DeleteDirectory, DeleteFile, AddDirectory, AddFile, FileSystemEdit, Position, Range, RenameFile, RenameDirectory, SequentialFileSystemEdit  from ..models.filesystem import FileSystem -from ..libs.main import Agent +from ..libs.main import Autopilot  from ..libs.map_path import map_path  from ..libs.steps.main import ManualEditAction  import shutil @@ -65,15 +65,15 @@ def calculate_diff(filepath: str, original: str, updated: str) -> List[FileEdit]  # The whole usage of watchdog here should only be specific to RealFileSystem, you want to have a different "Observer" class for VirtualFileSystem, which would depend on being sent notifications  class CopyCodebaseEventHandler(PatternMatchingEventHandler): -    def __init__(self, ignore_directories: List[str], ignore_patterns: List[str], agent: Agent, orig_root: str, copy_root: str, filesystem: FileSystem): +    def __init__(self, ignore_directories: List[str], ignore_patterns: List[str], autopilot: Autopilot, orig_root: str, copy_root: str, filesystem: FileSystem):          super().__init__(ignore_directories=ignore_directories, ignore_patterns=ignore_patterns) -        self.agent = agent +        self.autopilot = autopilot          self.orig_root = orig_root          self.copy_root = copy_root          self.filesystem = filesystem -    # For now, we'll just make the update immediately, but eventually need to sync with agent. -    # It should be the agent that makes the update right? It's just another action, everything comes from a single stream. +    # For now, we'll just make the update immediately, but eventually need to sync with autopilot. +    # It should be the autopilot that makes the update right? It's just another action, everything comes from a single stream.      def _event_to_edit(self, event) -> Union[FileSystemEdit, None]:          # NOTE: You'll need to map paths to create both an action within the copy filesystem (the one you take) and one in the original fileystem (the one you'll record and allow the user to accept). Basically just need a converter built in to the FileSystemEdit class @@ -110,13 +110,13 @@ class CopyCodebaseEventHandler(PatternMatchingEventHandler):              return          edit = edit.with_mapped_paths(self.orig_root, self.copy_root)          action = ManualEditAction(edit) -        self.agent.act(action) +        self.autopilot.act(action) -def maintain_copy_workspace(agent: Agent, filesystem: FileSystem, orig_root: str, copy_root: str): +def maintain_copy_workspace(autopilot: Autopilot, filesystem: FileSystem, orig_root: str, copy_root: str):      observer = Observer()      event_handler = CopyCodebaseEventHandler( -        [".git"], [], agent, orig_root, copy_root, filesystem) +        [".git"], [], autopilot, orig_root, copy_root, filesystem)      observer.schedule(event_handler, orig_root, recursive=True)      observer.start()      try: diff --git a/continuedev/src/continuedev/server/ide.py b/continuedev/src/continuedev/server/ide.py index 50296841..32f0b3ba 100644 --- a/continuedev/src/continuedev/server/ide.py +++ b/continuedev/src/continuedev/server/ide.py @@ -125,7 +125,7 @@ class IdeProtocolServer(AbstractIdeProtocolServer):          pass      async def setFileOpen(self, filepath: str, open: bool = True): -        # Agent needs access to this. +        # Autopilot needs access to this.          await self._send_json("setFileOpen", {              "filepath": filepath,              "open": open @@ -147,12 +147,12 @@ class IdeProtocolServer(AbstractIdeProtocolServer):          responses = await asyncio.gather(*[              self._receive_json(ShowSuggestionResponse)              for i in range(len(suggestions)) -        ])  # WORKING ON THIS FLOW HERE. Fine now to just await for response, instead of doing something fancy with a "waiting" state on the agent. +        ])  # WORKING ON THIS FLOW HERE. Fine now to just await for response, instead of doing something fancy with a "waiting" state on the autopilot.          # Just need connect the suggestionId to the IDE (and the notebook)          return any([r.accepted for r in responses])      # ------------------------------- # -    # Here needs to pass message onto the Agent OR Agent just subscribes. +    # Here needs to pass message onto the Autopilot OR Autopilot just subscribes.      # This is where you might have triggers: plugins can subscribe to certian events      # like file changes, tracebacks, etc... @@ -160,12 +160,12 @@ class IdeProtocolServer(AbstractIdeProtocolServer):          pass      def onTraceback(self, traceback: Traceback): -        # Same as below, maybe not every agent? +        # Same as below, maybe not every autopilot?          for _, session in self.session_manager.sessions.items(): -            session.agent.handle_traceback(traceback) +            session.autopilot.handle_traceback(traceback)      def onFileSystemUpdate(self, update: FileSystemEdit): -        # Access to Agent (so SessionManager) +        # Access to Autopilot (so SessionManager)          pass      def onCloseNotebook(self, session_id: str): @@ -176,10 +176,10 @@ class IdeProtocolServer(AbstractIdeProtocolServer):          pass      def onFileEdits(self, edits: List[FileEditWithFullContents]): -        # Send the file edits to ALL agents. +        # Send the file edits to ALL autopilots.          # Maybe not ideal behavior          for _, session in self.session_manager.sessions.items(): -            session.agent.handle_manual_edits(edits) +            session.autopilot.handle_manual_edits(edits)      # Request information. Session doesn't matter.      async def getOpenFiles(self) -> List[str]: diff --git a/continuedev/src/continuedev/server/notebook.py b/continuedev/src/continuedev/server/notebook.py index 9ca510dd..8ebe2853 100644 --- a/continuedev/src/continuedev/server/notebook.py +++ b/continuedev/src/continuedev/server/notebook.py @@ -79,26 +79,26 @@ class NotebookProtocolServer(AbstractNotebookProtocolServer):              print(e)      async def send_state_update(self): -        state = self.session.agent.get_full_state().dict() +        state = self.session.autopilot.get_full_state().dict()          await self._send_json("state_update", {              "state": state          })      def on_main_input(self, input: str):          # Do something with user input -        asyncio.create_task(self.session.agent.accept_user_input(input)) +        asyncio.create_task(self.session.autopilot.accept_user_input(input))      def on_reverse_to_index(self, index: int):          # Reverse the history to the given index -        asyncio.create_task(self.session.agent.reverse_to_index(index)) +        asyncio.create_task(self.session.autopilot.reverse_to_index(index))      def on_step_user_input(self, input: str, index: int):          asyncio.create_task( -            self.session.agent.give_user_input(input, index)) +            self.session.autopilot.give_user_input(input, index))      def on_refinement_input(self, input: str, index: int):          asyncio.create_task( -            self.session.agent.accept_refinement_input(input, index)) +            self.session.autopilot.accept_refinement_input(input, index))  @router.websocket("/ws") diff --git a/continuedev/src/continuedev/server/session_manager.py b/continuedev/src/continuedev/server/session_manager.py index c5715034..5598e140 100644 --- a/continuedev/src/continuedev/server/session_manager.py +++ b/continuedev/src/continuedev/server/session_manager.py @@ -5,7 +5,7 @@ from uuid import uuid4  from ..models.filesystem_edit import FileEditWithFullContents  from ..core.policy import DemoPolicy  from ..core.main import FullState -from ..core.agent import Agent +from ..core.autopilot import Autopilot  from ..libs.steps.nate import ImplementAbstractMethodStep  from .ide_protocol import AbstractIdeProtocolServer  import asyncio @@ -15,16 +15,16 @@ nest_asyncio.apply()  class Session:      session_id: str -    agent: Agent +    autopilot: Autopilot      ws: Union[WebSocket, None] -    def __init__(self, session_id: str, agent: Agent): +    def __init__(self, session_id: str, autopilot: Autopilot):          self.session_id = session_id -        self.agent = agent +        self.autopilot = autopilot          self.ws = None -class DemoAgent(Agent): +class DemoAutopilot(Autopilot):      first_seen: bool = False      cumulative_edit_string = "" @@ -51,18 +51,18 @@ class SessionManager:          return self.sessions[session_id]      def new_session(self, ide: AbstractIdeProtocolServer) -> str: -        agent = DemoAgent(policy=DemoPolicy(), ide=ide) +        autopilot = DemoAutopilot(policy=DemoPolicy(), ide=ide)          session_id = str(uuid4()) -        session = Session(session_id=session_id, agent=agent) +        session = Session(session_id=session_id, autopilot=autopilot)          self.sessions[session_id] = session          async def on_update(state: FullState):              await session_manager.send_ws_data(session_id, "state_update", { -                "state": agent.get_full_state().dict() +                "state": autopilot.get_full_state().dict()              }) -        agent.on_update(on_update) -        asyncio.create_task(agent.run_policy()) +        autopilot.on_update(on_update) +        asyncio.create_task(autopilot.run_policy())          return session_id      def remove_session(self, session_id: str): | 
