fixing up CreatePipelineStep
This commit is contained in:
parent
967aee09f5
commit
a874f94976
9 changed files with 30 additions and 15 deletions
|
|
@ -94,10 +94,11 @@ class Agent(ContinueBaseModel):
|
|||
self._step_depth -= 1
|
||||
|
||||
# Add observation to history
|
||||
self.history.get_current().observation = observation
|
||||
self.history.get_last_at_depth(
|
||||
self._step_depth, include_current=True).observation = observation
|
||||
|
||||
# Update its description
|
||||
step._set_description(await step.describe(ContinueSDK(self)))
|
||||
step._set_description(await step.describe(ContinueSDK(self).models))
|
||||
|
||||
# Call all subscribed callbacks
|
||||
await self.update_subscribers()
|
||||
|
|
|
|||
|
|
@ -27,6 +27,17 @@ class History(ContinueBaseModel):
|
|||
return None
|
||||
return self.timeline[self.current_index]
|
||||
|
||||
def get_last_at_depth(self, depth: int, include_current: bool = False) -> Union[HistoryNode, None]:
|
||||
i = self.current_index if include_current else self.current_index - 1
|
||||
while i >= 0:
|
||||
if self.timeline[i].depth == depth and type(self.timeline[i].step).__name__ != "ManualEditStep":
|
||||
return self.timeline[i]
|
||||
i -= 1
|
||||
return None
|
||||
|
||||
def get_last_at_same_depth(self) -> Union[HistoryNode, None]:
|
||||
return self.get_last_at_depth(self.get_current().depth)
|
||||
|
||||
def remove_current_and_substeps(self):
|
||||
self.timeline.pop(self.current_index)
|
||||
while self.get_current() is not None and self.get_current().depth > 0:
|
||||
|
|
@ -51,7 +62,7 @@ class History(ContinueBaseModel):
|
|||
self.current_index -= 1
|
||||
|
||||
def last_observation(self) -> Union[Observation, None]:
|
||||
state = self.get_current()
|
||||
state = self.get_last_at_same_depth()
|
||||
if state is None:
|
||||
return None
|
||||
return state.observation
|
||||
|
|
|
|||
|
|
@ -74,7 +74,7 @@ class ContinueSDK:
|
|||
|
||||
async def run(self, commands: List[str] | str, cwd: str = None):
|
||||
commands = commands if isinstance(commands, List) else [commands]
|
||||
return await self.run_step(ShellCommandsStep(commands=commands, cwd=cwd))
|
||||
return await self.run_step(ShellCommandsStep(cmds=commands, cwd=cwd))
|
||||
|
||||
async def edit_file(self, filename: str, prompt: str):
|
||||
filepath = await self._ensure_absolute_path(filename)
|
||||
|
|
|
|||
|
|
@ -38,7 +38,7 @@ class FileSystemEditStep(ReversibleStep):
|
|||
# Where and when should file saves happen?
|
||||
|
||||
|
||||
def ShellCommandsStep(Step):
|
||||
class ShellCommandsStep(Step):
|
||||
cmds: List[str]
|
||||
cwd: str | None = None
|
||||
name: str = "Run Shell Commands"
|
||||
|
|
|
|||
|
|
@ -1,4 +1,6 @@
|
|||
from textwrap import dedent
|
||||
|
||||
from ....core.observation import DictObservation
|
||||
from ....models.filesystem_edit import AddFile
|
||||
from ....core.main import Step
|
||||
from ....core.sdk import ContinueSDK
|
||||
|
|
@ -19,7 +21,7 @@ class SetupPipelineStep(Step):
|
|||
'python3 -m venv env',
|
||||
'source env/bin/activate',
|
||||
'pip install dlt',
|
||||
'dlt init {source_name} duckdb',
|
||||
f'dlt init {source_name} duckdb',
|
||||
'Y',
|
||||
'pip install -r requirements.txt'
|
||||
])
|
||||
|
|
@ -31,15 +33,15 @@ class SetupPipelineStep(Step):
|
|||
)
|
||||
|
||||
# wait for user to put API key in secrets.toml
|
||||
await sdk.ide.setFileOpen(".dlt/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`")
|
||||
return {"source_name": source_name}
|
||||
return DictObservation(values={"source_name": source_name})
|
||||
|
||||
|
||||
class ValidatePipelineStep(Step):
|
||||
|
||||
async def run(self, sdk: ContinueSDK):
|
||||
source_name = sdk.history.last_observation()["source_name"]
|
||||
source_name = sdk.history.last_observation().values["source_name"]
|
||||
filename = f'{source_name}.py'
|
||||
|
||||
# test that the API call works
|
||||
|
|
@ -68,7 +70,9 @@ class ValidatePipelineStep(Step):
|
|||
for row in rows:
|
||||
print(row)
|
||||
''')
|
||||
await sdk.apply_filesystem_edit(AddFile(filepath='query.py', content=tables_query_code))
|
||||
|
||||
query_filename = (await sdk.ide.getWorkspaceDirectory()) + "/query.py"
|
||||
await sdk.apply_filesystem_edit(AddFile(filepath=query_filename, content=tables_query_code))
|
||||
await sdk.run('env/bin/python3 query.py')
|
||||
|
||||
|
||||
|
|
|
|||
|
|
@ -340,7 +340,7 @@ class MessageStep(Step):
|
|||
return self.message
|
||||
|
||||
async def run(self, sdk: ContinueSDK) -> Coroutine[Observation, None, None]:
|
||||
pass
|
||||
return TextObservation(text=self.message)
|
||||
|
||||
|
||||
class EmptyStep(Step):
|
||||
|
|
|
|||
4
extension/package-lock.json
generated
4
extension/package-lock.json
generated
|
|
@ -1,12 +1,12 @@
|
|||
{
|
||||
"name": "continue",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.10",
|
||||
"lockfileVersion": 2,
|
||||
"requires": true,
|
||||
"packages": {
|
||||
"": {
|
||||
"name": "continue",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.10",
|
||||
"license": "Apache-2.0",
|
||||
"dependencies": {
|
||||
"@electron/rebuild": "^3.2.10",
|
||||
|
|
|
|||
|
|
@ -14,7 +14,7 @@
|
|||
"displayName": "Continue",
|
||||
"pricing": "Free",
|
||||
"description": "Refine code 10x faster",
|
||||
"version": "0.0.9",
|
||||
"version": "0.0.10",
|
||||
"publisher": "Continue",
|
||||
"engines": {
|
||||
"vscode": "^1.74.0"
|
||||
|
|
|
|||
|
|
@ -194,7 +194,6 @@ export function setupDebugPanel(
|
|||
async function connectWebsocket(url: string) {
|
||||
return new Promise((resolve, reject) => {
|
||||
const onMessage = (message: any) => {
|
||||
console.log("websocket message", message);
|
||||
panel.webview.postMessage({
|
||||
type: "websocketForwardingMessage",
|
||||
url,
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue