polishing dlt recipe
This commit is contained in:
parent
da4647f278
commit
5ce9085358
7 changed files with 40 additions and 11 deletions
|
|
@ -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
|
||||
|
||||
|
|
|
|||
|
|
@ -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
|
||||
|
|
|
|||
|
|
@ -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()
|
||||
|
|
|
|||
|
|
@ -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]:
|
||||
|
|
|
|||
|
|
@ -36,6 +36,8 @@ const MainDiv = styled.div<{ stepDepth: number; inFuture: boolean }>`
|
|||
animation: ${appear} 0.3s ease-in-out;
|
||||
/* padding-left: ${(props) => props.stepDepth * 20}px; */
|
||||
overflow: hidden;
|
||||
margin-left: 0px;
|
||||
margin-right: 0px;
|
||||
`;
|
||||
|
||||
const StepContainerDiv = styled.div<{ open: boolean }>`
|
||||
|
|
|
|||
|
|
@ -45,7 +45,7 @@ export const Pre = styled.pre`
|
|||
border-radius: ${defaultBorderRadius};
|
||||
padding: 8px;
|
||||
max-height: 150px;
|
||||
overflow: scroll;
|
||||
overflow-y: scroll;
|
||||
margin: 0;
|
||||
background-color: ${secondaryDark};
|
||||
border: none;
|
||||
|
|
|
|||
|
|
@ -66,11 +66,11 @@ function checkEnvExists() {
|
|||
getExtensionUri().fsPath,
|
||||
"scripts",
|
||||
"env",
|
||||
"bin"
|
||||
process.platform == "win32" ? "Scripts" : "bin"
|
||||
);
|
||||
return (
|
||||
fs.existsSync(envBinPath + "/activate") &&
|
||||
fs.existsSync(envBinPath + "/pip")
|
||||
fs.existsSync(path.join(envBinPath, "activate")) &&
|
||||
fs.existsSync(path.join(envBinPath, "pip"))
|
||||
);
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue