Skip to content

consolidate schemas into types folder #92

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Draft
wants to merge 2 commits into
base: main
Choose a base branch
from
Draft
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 4 additions & 4 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -190,7 +190,7 @@ if __name__ == "__main__":
import os
from stagehand.sync import Stagehand
from stagehand import StagehandConfig
from stagehand.schemas import AgentConfig, AgentExecuteOptions, AgentProvider
from stagehand.types import AgentConfigAPI as AgentConfig, AgentExecuteOptionsAPI as AgentExecuteOptions, AgentProvider
from dotenv import load_dotenv

load_dotenv()
Expand Down Expand Up @@ -246,7 +246,7 @@ if __name__ == "__main__":

The `ActOptions` model takes an `action` field that tells the AI what to do on the page, plus optional fields such as `useVision` and `variables`:
```python
from stagehand.schemas import ActOptions
from stagehand.types import ActOptions

# Example:
await page.act(ActOptions(action="click on the 'Quickstart' button"))
Expand All @@ -256,7 +256,7 @@ if __name__ == "__main__":

The `ObserveOptions` model lets you find elements on the page using natural language. The `onlyVisible` option helps limit the results:
```python
from stagehand.schemas import ObserveOptions
from stagehand.types import ObserveOptions

# Example:
await page.observe(ObserveOptions(instruction="find the button labeled 'News'", onlyVisible=True))
Expand All @@ -266,7 +266,7 @@ if __name__ == "__main__":

The `ExtractOptions` model extracts structured data from the page. Pass your instructions and a schema defining your expected data format. **Note:** If you are using a Pydantic model for the schema, call its `.model_json_schema()` method to ensure JSON serializability.
```python
from stagehand.schemas import ExtractOptions
from stagehand.types import ExtractOptions
from pydantic import BaseModel

class DescriptionSchema(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion examples/agent_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from rich.theme import Theme

from stagehand import Stagehand, StagehandConfig, AgentConfig, configure_logging
from stagehand.schemas import AgentExecuteOptions, AgentProvider
from stagehand.types import AgentExecuteOptionsAPI as AgentExecuteOptions, AgentProvider

# Create a custom theme for consistent styling
custom_theme = Theme(
Expand Down
6 changes: 3 additions & 3 deletions stagehand/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,11 +8,11 @@
from .main import Stagehand
from .metrics import StagehandFunctionName, StagehandMetrics
from .page import StagehandPage
from .schemas import (
from .types import (
ActOptions,
ActResult,
AgentConfig,
AgentExecuteOptions,
AgentConfigAPI as AgentConfig,
AgentExecuteOptionsAPI as AgentExecuteOptions,
AgentExecuteResult,
AgentProvider,
ExtractOptions,
Expand Down
6 changes: 3 additions & 3 deletions stagehand/agent.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,6 @@
from .schemas import (
AgentConfig,
AgentExecuteOptions,
from .types import (
AgentConfigAPI as AgentConfig,
AgentExecuteOptionsAPI as AgentExecuteOptions,
AgentExecuteResult,
AgentProvider,
)
Expand Down
2 changes: 1 addition & 1 deletion stagehand/config.py
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
from browserbase.types import SessionCreateParams as BrowserbaseSessionCreateParams
from pydantic import BaseModel, ConfigDict, Field

from stagehand.schemas import AvailableModel
from stagehand.types import AvailableModel


class StagehandConfig(BaseModel):
Expand Down
2 changes: 1 addition & 1 deletion stagehand/handlers/observe_handler.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from stagehand.a11y.utils import get_accessibility_tree, get_xpath_by_resolved_object_id
from stagehand.llm.inference import observe as observe_inference
from stagehand.metrics import StagehandFunctionName # Changed import location
from stagehand.schemas import ObserveOptions, ObserveResult
from stagehand.types import ObserveOptions, ObserveResult
from stagehand.utils import draw_observe_overlay


Expand Down
2 changes: 1 addition & 1 deletion stagehand/main.py
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
from .logging import StagehandLogger, default_log_handler
from .metrics import StagehandFunctionName, StagehandMetrics
from .page import StagehandPage
from .schemas import AgentConfig
from .types import AgentConfigAPI as AgentConfig
from .utils import make_serializable

load_dotenv()
Expand Down
2 changes: 1 addition & 1 deletion stagehand/page.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,7 @@
from stagehand.handlers.extract_handler import ExtractHandler
from stagehand.handlers.observe_handler import ObserveHandler

from .schemas import (
from .types import (
DEFAULT_EXTRACT_SCHEMA,
ActOptions,
ActResult,
Expand Down
288 changes: 0 additions & 288 deletions stagehand/schemas.py

This file was deleted.

Loading
Loading