|
11 | 11 |
|
12 | 12 | # Set required API key for LLM operations |
13 | 13 | if not os.environ.get("OPENAI_API_KEY"): |
14 | | - print("β Error: OPENAI_API_KEY environment variable not set") |
15 | | - print(" Set it with: export OPENAI_API_KEY='sk-proj-...'") |
| 14 | + print("β Error: OPENAI_API_KEY environment variable not set") # noqa: T201 |
| 15 | + print(" Set it with: export OPENAI_API_KEY='sk-proj-...'") # noqa: T201 |
16 | 16 | sys.exit(1) |
17 | 17 |
|
18 | | -print("π Testing local server mode...") |
| 18 | +print("π Testing local server mode...") # noqa: T201 |
19 | 19 |
|
20 | 20 | try: |
21 | 21 | # Create client in local mode - will use bundled binary |
22 | | - print("π¦ Creating Stagehand client in local mode...") |
| 22 | + print("π¦ Creating Stagehand client in local mode...") # noqa: T201 |
23 | 23 | client = Stagehand( |
24 | 24 | server="local", |
25 | 25 | browserbase_api_key="local", # Dummy value - not used in local mode |
|
30 | 30 | local_ready_timeout_s=15.0, # Give it time to start |
31 | 31 | ) |
32 | 32 |
|
33 | | - print("π§ Starting session (this will start the local server)...") |
| 33 | + print("π§ Starting session (this will start the local server)...") # noqa: T201 |
34 | 34 | session = client.sessions.start( |
35 | 35 | model_name="openai/gpt-5-nano", |
36 | 36 | browser={ |
|
40 | 40 | ) |
41 | 41 | session_id = session.data.session_id |
42 | 42 |
|
43 | | - print(f"β
Session started: {session_id}") |
44 | | - print(f"π Server running at: {client.base_url}") |
| 43 | + print(f"β
Session started: {session_id}") # noqa: T201 |
| 44 | + print(f"π Server running at: {client.base_url}") # noqa: T201 |
45 | 45 |
|
46 | | - print("\nπ Navigating to example.com...") |
| 46 | + print("\nπ Navigating to example.com...") # noqa: T201 |
47 | 47 | client.sessions.navigate( |
48 | 48 | id=session_id, |
49 | 49 | url="https://example.com", |
50 | 50 | frame_id="", |
51 | 51 | ) |
52 | | - print("β
Navigation complete") |
| 52 | + print("β
Navigation complete") # noqa: T201 |
53 | 53 |
|
54 | | - print("\nπ Extracting page heading...") |
| 54 | + print("\nπ Extracting page heading...") # noqa: T201 |
55 | 55 | result = client.sessions.extract( |
56 | 56 | id=session_id, |
57 | 57 | instruction="Extract the main heading text from the page", |
58 | 58 | ) |
59 | | - print(f"π Extracted: {result.data.result}") |
| 59 | + print(f"π Extracted: {result.data.result}") # noqa: T201 |
60 | 60 |
|
61 | | - print("\nπ Ending session...") |
| 61 | + print("\nπ Ending session...") # noqa: T201 |
62 | 62 | client.sessions.end(id=session_id) |
63 | | - print("β
Session ended") |
| 63 | + print("β
Session ended") # noqa: T201 |
64 | 64 |
|
65 | | - print("\nπ Closing client (will shut down server)...") |
| 65 | + print("\nπ Closing client (will shut down server)...") # noqa: T201 |
66 | 66 | client.close() |
67 | | - print("β
Server shut down successfully!") |
| 67 | + print("β
Server shut down successfully!") # noqa: T201 |
68 | 68 |
|
69 | | - print("\nπ All tests passed!") |
| 69 | + print("\nπ All tests passed!") # noqa: T201 |
70 | 70 |
|
71 | 71 | except Exception as e: |
72 | | - print(f"\nβ Error: {e}") |
| 72 | + print(f"\nβ Error: {e}") # noqa: T201 |
73 | 73 | import traceback |
74 | 74 | traceback.print_exc() |
75 | 75 | sys.exit(1) |
0 commit comments