Skip to content

Commit ce939cc

Browse files
loosen rich dep and update example render
1 parent cbcc333 commit ce939cc

File tree

3 files changed

+34
-5
lines changed

3 files changed

+34
-5
lines changed

examples/agent_example.py

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,16 @@
99

1010
from stagehand import Stagehand, StagehandConfig, configure_logging
1111

12+
# Compatibility function for Panel.fit (available in Rich >= 14.0.0)
13+
def create_panel(content, **kwargs):
14+
"""Create a panel with fallback for older Rich versions."""
15+
try:
16+
# Try to use Panel.fit if available
17+
return Panel.fit(content, **kwargs)
18+
except AttributeError:
19+
# Fallback to regular Panel for older Rich versions
20+
return Panel(content, **kwargs)
21+
1222
# Create a custom theme for consistent styling
1323
custom_theme = Theme(
1424
{
@@ -100,7 +110,7 @@ async def main():
100110
# Add a fancy header
101111
console.print(
102112
"\n",
103-
Panel.fit(
113+
create_panel(
104114
"[light_gray]Stagehand 🤘 Agent Example[/]",
105115
border_style="green",
106116
padding=(1, 10),

examples/example.py

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,16 @@
1010
from stagehand import Stagehand, StagehandConfig
1111
from stagehand.utils import configure_logging
1212

13+
# Compatibility function for Panel.fit (available in Rich >= 14.0.0)
14+
def create_panel(content, **kwargs):
15+
"""Create a panel with fallback for older Rich versions."""
16+
try:
17+
# Try to use Panel.fit if available
18+
return Panel.fit(content, **kwargs)
19+
except AttributeError:
20+
# Fallback to regular Panel for older Rich versions
21+
return Panel(content, **kwargs)
22+
1323
# Configure logging with cleaner format
1424
configure_logging(
1525
level=logging.INFO,
@@ -35,7 +45,16 @@
3545
load_dotenv()
3646

3747
console.print(
38-
Panel.fit(
48+
create_panel(
49+
"[yellow]Stagehand Python SDK Example[/]\n"
50+
"[white]This example demonstrates basic Stagehand functionality.[/]",
51+
title="Welcome",
52+
border_style="blue",
53+
)
54+
)
55+
56+
console.print(
57+
create_panel(
3958
"[yellow]Logging Levels:[/]\n"
4059
"[white]- Set [bold]verbose=0[/] for errors (ERROR)[/]\n"
4160
"[white]- Set [bold]verbose=1[/] for minimal logs (INFO)[/]\n"
@@ -127,7 +146,7 @@ async def main():
127146
# Add a fancy header
128147
console.print(
129148
"\n",
130-
Panel.fit(
149+
create_panel(
131150
"[light_gray]Stagehand 🤘 Python Example[/]",
132151
border_style="green",
133152
padding=(1, 10),

pyproject.toml

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,12 +4,12 @@ build-backend = "setuptools.build_meta"
44

55
[project]
66
name = "stagehand"
7-
version = "0.4.0"
7+
version = "0.4.1"
88
description = "Python SDK for Stagehand"
99
readme = "README.md"
1010
classifiers = [ "Programming Language :: Python :: 3", "License :: OSI Approved :: MIT License", "Operating System :: OS Independent",]
1111
requires-python = ">=3.9"
12-
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",]
12+
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",]
1313
[[project.authors]]
1414
name = "Browserbase, Inc."
1515

0 commit comments

Comments
 (0)