Skip to content

Commit b8ca9df

Browse files
docs: update navigation examples to use navigate instead of act (#9)
Closes: #7
1 parent 3291691 commit b8ca9df

2 files changed

Lines changed: 11 additions & 23 deletions

File tree

README.md

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -141,7 +141,7 @@ async-std = { version = "1", features = ["attributes"] }
141141

142142
```rust
143143
use stagehand_sdk::{Stagehand, V3Options, Env, Model, TransportChoice};
144-
use stagehand_sdk::{ActResponseEvent, ExtractResponseEvent};
144+
use stagehand_sdk::{ActResponseEvent, ExtractResponseEvent, NavigateResponseEvent};
145145
use futures::StreamExt;
146146
use serde::{Deserialize, Serialize};
147147
use std::collections::HashMap;
@@ -177,17 +177,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
177177
println!("Session ID: {:?}", stagehand.session_id());
178178

179179
// 3. Navigate to a page
180-
let mut act_stream = stagehand.act(
181-
"Go to https://quotes.toscrape.com/",
182-
None,
183-
HashMap::new(),
184-
Some(60_000),
185-
None,
186-
).await?;
180+
let mut nav_stream = stagehand
181+
.navigate("https://quotes.toscrape.com/", None, None)
182+
.await?;
187183

188-
while let Some(res) = act_stream.next().await {
184+
while let Some(res) = nav_stream.next().await {
189185
if let Ok(response) = res {
190-
if let Some(ActResponseEvent::Success(success)) = response.event {
186+
if let Some(NavigateResponseEvent::Success(success)) = response.event {
191187
println!("Navigation success: {}", success);
192188
}
193189
}

examples/basic.rs

Lines changed: 5 additions & 13 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,5 @@
11
use stagehand_sdk::{
2-
ActResponseEvent, AgentConfig, AgentExecuteOptions, Env, ExecuteResponseEvent,
3-
ExtractResponseEvent, Model, ModelConfiguration, ObserveResponseEvent, Stagehand,
4-
TransportChoice, V3Options,
2+
ActResponseEvent, AgentConfig, AgentExecuteOptions, Env, ExecuteResponseEvent, ExtractResponseEvent, Model, ModelConfiguration, NavigateResponseEvent, ObserveResponseEvent, Stagehand, TransportChoice, V3Options
53
};
64
use futures::StreamExt;
75
use serde::{Deserialize, Serialize};
@@ -44,19 +42,13 @@ async fn main() -> Result<(), Box<dyn std::error::Error + Send + Sync>> {
4442

4543
// 3. Navigate to https://news.ycombinator.com
4644
println!("3. Navigating to Hacker News...");
47-
let mut act_stream = stagehand
48-
.act(
49-
"Navigate to https://news.ycombinator.com",
50-
None,
51-
HashMap::new(),
52-
Some(60_000),
53-
None,
54-
)
45+
let mut nav_stream = stagehand
46+
.navigate("https://news.ycombinator.com", None, None)
5547
.await?;
5648

57-
while let Some(res) = act_stream.next().await {
49+
while let Some(res) = nav_stream.next().await {
5850
if let Ok(response) = res {
59-
if let Some(ActResponseEvent::Success(success)) = response.event {
51+
if let Some(NavigateResponseEvent::Success(success)) = response.event {
6052
println!(" Navigation success: {}\n", success);
6153
}
6254
}

0 commit comments

Comments
 (0)