Skip to content
Merged
Show file tree
Hide file tree
Changes from 2 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
12 changes: 11 additions & 1 deletion examples/agent_example.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,16 @@

from stagehand import Stagehand, StagehandConfig, configure_logging

# Compatibility function for Panel.fit (available in Rich >= 14.0.0)
def create_panel(content, **kwargs):
"""Create a panel with fallback for older Rich versions."""
try:
# Try to use Panel.fit if available
return Panel.fit(content, **kwargs)
except AttributeError:
# Fallback to regular Panel for older Rich versions
return Panel(content, **kwargs)

# Create a custom theme for consistent styling
custom_theme = Theme(
{
Expand Down Expand Up @@ -100,7 +110,7 @@ async def main():
# Add a fancy header
console.print(
"\n",
Panel.fit(
create_panel(
"[light_gray]Stagehand 🤘 Agent Example[/]",
border_style="green",
padding=(1, 10),
Expand Down
26 changes: 22 additions & 4 deletions examples/example.py
Original file line number Diff line number Diff line change
Expand Up @@ -7,8 +7,17 @@
from rich.panel import Panel
from rich.theme import Theme

from stagehand import Stagehand, StagehandConfig
from stagehand.utils import configure_logging
from stagehand import Stagehand, StagehandConfig, configure_logging

# Compatibility function for Panel.fit (available in Rich >= 14.0.0)
def create_panel(content, **kwargs):
"""Create a panel with fallback for older Rich versions."""
try:
# Try to use Panel.fit if available
return Panel.fit(content, **kwargs)
except AttributeError:
# Fallback to regular Panel for older Rich versions
return Panel(content, **kwargs)

# Configure logging with cleaner format
configure_logging(
Expand All @@ -35,7 +44,16 @@
load_dotenv()

console.print(
Panel.fit(
create_panel(
"[yellow]Stagehand Python SDK Example[/]\n"
"[white]This example demonstrates basic Stagehand functionality.[/]",
title="Welcome",
border_style="blue",
)
)

console.print(
create_panel(
"[yellow]Logging Levels:[/]\n"
"[white]- Set [bold]verbose=0[/] for errors (ERROR)[/]\n"
"[white]- Set [bold]verbose=1[/] for minimal logs (INFO)[/]\n"
Expand Down Expand Up @@ -127,7 +145,7 @@ async def main():
# Add a fancy header
console.print(
"\n",
Panel.fit(
create_panel(
"[light_gray]Stagehand 🤘 Python Example[/]",
border_style="green",
padding=(1, 10),
Expand Down
4 changes: 2 additions & 2 deletions pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,12 +4,12 @@ build-backend = "setuptools.build_meta"

[project]
name = "stagehand"
version = "0.4.0"
version = "0.4.1"
description = "Python SDK for Stagehand"
readme = "README.md"
classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]
requires-python = ">=3.9"
dependencies = [ "httpx>=0.24.0", "python-dotenv>=1.0.0", "pydantic>=1.10.0", "playwright>=1.42.1", "requests>=2.31.0", "browserbase>=1.4.0", "rich>=14.0.0", "openai>=1.83.0", "anthropic>=0.51.0", "litellm>=1.72.0",]
dependencies = [ "httpx>=0.24.0", "python-dotenv>=1.0.0", "pydantic>=1.10.0", "playwright>=1.42.1", "requests>=2.31.0", "browserbase>=1.4.0", "rich>=13.7.0", "openai>=1.83.0", "anthropic>=0.51.0", "litellm>=1.72.0",]
[[project.authors]]
name = "Browserbase, Inc."
email = "[email protected]"
Expand Down