Skip to content

Commit

Permalink
feat: add run mode
Browse files Browse the repository at this point in the history
  • Loading branch information
adeprez committed Oct 10, 2024
1 parent c2fc72a commit d1ab4e0
Show file tree
Hide file tree
Showing 5 changed files with 19 additions and 3 deletions.
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
import json
import time
from typing import Callable, Dict, List, Optional
from typing import Dict, List, Optional

from lavague.drivers.selenium.node import SeleniumNode
from lavague.drivers.selenium.prompt import SELENIUM_PROMPT_TEMPLATE
Expand Down
2 changes: 1 addition & 1 deletion lavague-sdk/lavague/sdk/base_driver/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@
from abc import ABC, abstractmethod
from contextlib import contextmanager
from datetime import datetime
from typing import Callable, Dict, Generic, List, Optional, TypeVar, Union
from typing import Dict, Generic, List, Optional, TypeVar

from lavague.sdk.action.navigation import NavigationCommand, NavigationOutput
from lavague.sdk.base_driver.interaction import (
Expand Down
2 changes: 1 addition & 1 deletion lavague-sdk/lavague/sdk/trajectory/__init__.py
Original file line number Diff line number Diff line change
@@ -1,2 +1,2 @@
from lavague.sdk.trajectory.base import Trajectory
from lavague.sdk.trajectory.model import RunStatus, TrajectoryData
from lavague.sdk.trajectory.model import RunStatus, TrajectoryData, RunMode
9 changes: 9 additions & 0 deletions lavague-sdk/lavague/sdk/trajectory/base.py
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,15 @@ class Trajectory(TrajectoryData):
def is_running(self):
return self.status in (RunStatus.STARTING, RunStatus.RUNNING)

@property
def studio_url(self):
return f"https://cloud.lavague.ai/studioRun?run_id={self.run_id}"

def open_in_studio(self):
import webbrowser

webbrowser.open(self.studio_url)

def next_action(self):
ret = self._controller.next_step(self.run_id)
self.status = ret.run_status
Expand Down
7 changes: 7 additions & 0 deletions lavague-sdk/lavague/sdk/trajectory/model.py
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ class RunStatus(str, Enum):
INTERRUPTED = "interrupted"


class RunMode(str, Enum):
LIVE = "live"
STEP_BY_STEP = "step_by_step"
INACTIVE = "inactive"


class TrajectoryData(BaseModel):
"""Trajectory of web interactions towards an objective."""

Expand All @@ -21,6 +27,7 @@ class TrajectoryData(BaseModel):
objective: str
viewport_size: Tuple[int, int]
status: RunStatus
run_mode: RunMode = RunMode.INACTIVE
actions: List[SerializeAsAny[Action]]
error_msg: Optional[str] = None

Expand Down

0 comments on commit d1ab4e0

Please sign in to comment.