diff options
| author | Nate Sesti <sestinj@gmail.com> | 2023-06-01 19:03:10 -0400 | 
|---|---|---|
| committer | Nate Sesti <sestinj@gmail.com> | 2023-06-01 19:03:10 -0400 | 
| commit | 5ce90853586fcfaa7d795e2593aaaecce4bbed49 (patch) | |
| tree | a685864b14c00a113bb3cfc4ed708ed6e4f7b3d3 /continuedev | |
| parent | da4647f2788a7b6d1e3b6ec76665052210311385 (diff) | |
| download | sncontinue-5ce90853586fcfaa7d795e2593aaaecce4bbed49.tar.gz sncontinue-5ce90853586fcfaa7d795e2593aaaecce4bbed49.tar.bz2 sncontinue-5ce90853586fcfaa7d795e2593aaaecce4bbed49.zip  | |
polishing dlt recipe
Diffstat (limited to 'continuedev')
| -rw-r--r-- | continuedev/src/continuedev/core/agent.py | 13 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/steps/core/core.py | 3 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/steps/draft/dlt.py | 24 | ||||
| -rw-r--r-- | continuedev/src/continuedev/libs/steps/main.py | 1 | 
4 files changed, 34 insertions, 7 deletions
diff --git a/continuedev/src/continuedev/core/agent.py b/continuedev/src/continuedev/core/agent.py index 0dba6122..cf5c9781 100644 --- a/continuedev/src/continuedev/core/agent.py +++ b/continuedev/src/continuedev/core/agent.py @@ -10,6 +10,7 @@ from ..models.main import ContinueBaseModel  from .main import Policy, History, FullState, Step, HistoryNode  from ..libs.steps.core.core import ReversibleStep, ManualEditStep, UserInputStep  from .sdk import ContinueSDK +import asyncio  class Agent(ContinueBaseModel): @@ -88,6 +89,9 @@ class Agent(ContinueBaseModel):          self.history.add_node(HistoryNode(              step=step, observation=None, depth=self._step_depth)) +        # Call all subscribed callbacks +        await self.update_subscribers() +          # Run step          self._step_depth += 1          observation = await step(ContinueSDK(self)) @@ -98,10 +102,11 @@ class Agent(ContinueBaseModel):              self._step_depth, include_current=True).observation = observation          # Update its description -        step._set_description(await step.describe(ContinueSDK(self).models)) - -        # Call all subscribed callbacks -        await self.update_subscribers() +        async def update_description(): +            step._set_description(await step.describe(ContinueSDK(self).models)) +            # Update subscribers with new description +            await self.update_subscribers() +        asyncio.create_task(update_description())          return observation diff --git a/continuedev/src/continuedev/libs/steps/core/core.py b/continuedev/src/continuedev/libs/steps/core/core.py index 1761cbfd..9a5d54f0 100644 --- a/continuedev/src/continuedev/libs/steps/core/core.py +++ b/continuedev/src/continuedev/libs/steps/core/core.py @@ -44,7 +44,8 @@ class ShellCommandsStep(Step):      name: str = "Run Shell Commands"      async def describe(self, models: Models) -> Coroutine[str, None, None]: -        return "\n".join(self.cmds) +        cmds_str = "\n".join(self.cmds) +        return (await models.gpt35()).complete(f"{cmds_str}\n\nSummarize what was done in these shell commands, using markdown bullet points:")      async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:          cwd = await sdk.ide.getWorkspaceDirectory() if self.cwd is None else self.cwd diff --git a/continuedev/src/continuedev/libs/steps/draft/dlt.py b/continuedev/src/continuedev/libs/steps/draft/dlt.py index 94ca2323..73762327 100644 --- a/continuedev/src/continuedev/libs/steps/draft/dlt.py +++ b/continuedev/src/continuedev/libs/steps/draft/dlt.py @@ -1,16 +1,27 @@  from textwrap import dedent +from ....core.sdk import Models +  from ....core.observation import DictObservation  from ....models.filesystem_edit import AddFile  from ....core.main import Step  from ....core.sdk import ContinueSDK  from ..core.core import WaitForUserInputStep +from ..main import MessageStep  class SetupPipelineStep(Step): +    hide: bool = True +    name: str = "Setup dlt Pipeline"      api_description: str  # e.g. "I want to load data from the weatherapi.com API" +    async def describe(self, models: Models): +        return dedent(f"""\ +        This step will create a new dlt pipeline that loads data from an API, as per your request: +        {self.api_description} +        """) +      async def run(self, sdk: ContinueSDK):          source_name = (await sdk.models.gpt35()).complete(              f"Write a snake_case name for the data source described by {self.api_description}: ").strip() @@ -34,12 +45,11 @@ class SetupPipelineStep(Step):          # wait for user to put API key in secrets.toml          await sdk.ide.setFileOpen(await sdk.ide.getWorkspaceDirectory() + "/.dlt/secrets.toml") -        await sdk.wait_for_user_confirmation("Please add the API key to the `secrets.toml` file and then press `Continue`") +        await sdk.wait_for_user_confirmation("If this service requires an API key, please add it to the `secrets.toml` file and then press `Continue`")          return DictObservation(values={"source_name": source_name})  class ValidatePipelineStep(Step): -      async def run(self, sdk: ContinueSDK):          source_name = sdk.history.last_observation().values["source_name"]          filename = f'{source_name}.py' @@ -77,9 +87,19 @@ class ValidatePipelineStep(Step):  class CreatePipelineStep(Step): +    hide: bool = True      async def run(self, sdk: ContinueSDK):          await sdk.run_step( +            MessageStep(message=dedent("""\ +                This recipe will walk you through the process of creating a dlt pipeline for your chosen data source. With the help of Continue, you will: +                - Create a Python virtual environment with dlt installed +                - Run `dlt init` to generate a pipeline template +                - Write the code to call the API +                - Add any required API keys to the `secrets.toml` file +                - Test that the API call works +                - Load the data into a local DuckDB instance +                - Write a query to view the data""")) >>              WaitForUserInputStep(prompt="What API do you want to load data from?") >>              SetupPipelineStep(api_description="WeatherAPI.com API") >>              ValidatePipelineStep() diff --git a/continuedev/src/continuedev/libs/steps/main.py b/continuedev/src/continuedev/libs/steps/main.py index 6a7f14c7..c70d5c2c 100644 --- a/continuedev/src/continuedev/libs/steps/main.py +++ b/continuedev/src/continuedev/libs/steps/main.py @@ -334,6 +334,7 @@ class SolveTracebackStep(Step):  class MessageStep(Step): +    name: str = "Message"      message: str      async def describe(self, models: Models) -> Coroutine[str, None, None]:  | 
