Skip to content

Commit edb7c4c

Browse files
committed
placeholders
1 parent 01010d8 commit edb7c4c

File tree

9 files changed

+170
-102
lines changed

9 files changed

+170
-102
lines changed

examples/async_retrieve.py

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ async def retrieve_regular_task() -> None:
1919

2020
print("Retrieving regular task...")
2121

22-
regular_task = await client.tasks.create_task(
22+
task = await client.tasks.create_task(
2323
task="""
2424
Find top 10 Hacker News articles and return the title and url.
2525
""",
2626
llm="gemini-2.5-flash",
2727
)
2828

29-
print(f"Regular Task ID: {regular_task.id}")
29+
print(f"Regular Task ID: {task.id}")
3030

3131
while True:
32-
regular_status = await client.tasks.get_task(regular_task.id)
32+
regular_status = await client.tasks.get_task(task.id)
3333
print(f"Regular Task Status: {regular_status.status}")
3434
if regular_status.status == "finished":
3535
print(f"Regular Task Output: {regular_status.output}")
@@ -55,18 +55,18 @@ class HackerNewsPost(BaseModel):
5555
class SearchResult(BaseModel):
5656
posts: List[HackerNewsPost]
5757

58-
structured_task = await client.tasks.create_task(
58+
task = await client.tasks.create_task(
5959
task="""
6060
Find top 10 Hacker News articles and return the title and url.
6161
""",
6262
llm="gpt-4.1",
6363
schema=SearchResult,
6464
)
6565

66-
print(f"Structured Task ID: {structured_task.id}")
66+
print(f"Structured Task ID: {task.id}")
6767

6868
while True:
69-
structured_status = await client.tasks.retrieve(task_id=structured_task.id, schema=SearchResult)
69+
structured_status = await client.tasks.get_task(task_id=task.id, schema=SearchResult)
7070
print(f"Structured Task Status: {structured_status.status}")
7171

7272
if structured_status.status == "finished":

examples/async_run.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -43,16 +43,16 @@ class SearchResult(BaseModel):
4343
Find top 10 Hacker News articles and return the title and url.
4444
""",
4545
llm="gpt-4.1",
46-
structured_output_json=SearchResult,
46+
schema=SearchResult,
4747
)
4848

4949
print(f"Structured Task ID: {task.id}")
5050

5151
result = await task.complete()
5252

53-
if result.parsed is not None:
53+
if result.parsed_output is not None:
5454
print("Structured Task Output:")
55-
for post in result.parsed.posts:
55+
for post in result.parsed_output.posts:
5656
print(f" - {post.title} - {post.url}")
5757

5858
print("Structured Task Done")

examples/async_stream.py

Lines changed: 14 additions & 22 deletions
Original file line numberDiff line numberDiff line change
@@ -13,23 +13,17 @@
1313

1414
# Regular Task
1515
async def stream_regular_task() -> None:
16-
regular_task = await client.tasks.create(
16+
task = await client.tasks.create_task(
1717
task="""
1818
Find top 10 Hacker News articles and return the title and url.
1919
""",
2020
llm="gemini-2.5-flash",
2121
)
2222

23-
print(f"Regular Task ID: {regular_task.id}")
23+
print(f"Regular Task ID: {task.id}")
2424

25-
async for res in client.tasks.stream(regular_task.id):
26-
print(f"Regular Task Status: {res.status}")
27-
28-
if len(res.steps) > 0:
29-
last_step = res.steps[-1]
30-
print(f"Regular Task Step: {last_step.url} ({last_step.next_goal})")
31-
for action in last_step.actions:
32-
print(f" - Regular Task Action: {action}")
25+
async for step in task.stream():
26+
print(f"Regular Task Status: {step.number}")
3327

3428
print("Regular Task Done")
3529

@@ -43,26 +37,24 @@ class HackerNewsPost(BaseModel):
4337
class SearchResult(BaseModel):
4438
posts: List[HackerNewsPost]
4539

46-
structured_task = await client.tasks.create(
40+
task = await client.tasks.create_task(
4741
task="""
4842
Find top 10 Hacker News articles and return the title and url.
4943
""",
5044
llm="gpt-4.1",
51-
structured_output_json=SearchResult,
45+
schema=SearchResult,
5246
)
5347

54-
print(f"Structured Task ID: {structured_task.id}")
48+
print(f"Structured Task ID: {task.id}")
49+
50+
async for step in task.stream():
51+
print(f"Structured Task Step {step.number}: {step.url} ({step.next_goal})")
5552

56-
async for res in client.tasks.stream(structured_task.id, structured_output_json=SearchResult):
57-
print(f"Structured Task Status: {res.status}")
53+
result = await task.complete()
5854

59-
if res.status == "finished":
60-
if res.parsed_output is None:
61-
print("Structured Task No output")
62-
else:
63-
for post in res.parsed_output.posts:
64-
print(f" - Structured Task Post: {post.title} - {post.url}")
65-
break
55+
if result.parsed_output is not None:
56+
for post in result.parsed_output.posts:
57+
print(f" - {post.title} - {post.url}")
6658

6759
print("Structured Task Done")
6860

examples/retrieve.py

Lines changed: 8 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -19,17 +19,17 @@ def retrieve_regular_task() -> None:
1919

2020
print("Retrieving regular task...")
2121

22-
regular_task = client.tasks.create_task(
22+
task = client.tasks.create_task(
2323
task="""
2424
Find top 10 Hacker News articles and return the title and url.
2525
""",
2626
llm="gemini-2.5-flash",
2727
)
2828

29-
print(f"Task ID: {regular_task.id}")
29+
print(f"Task ID: {task.id}")
3030

3131
while True:
32-
regular_status = client.tasks.get_task(regular_task.id)
32+
regular_status = client.tasks.get_task(task.id)
3333
print(regular_status.status)
3434
if regular_status.status == "finished":
3535
print(regular_status.output)
@@ -58,25 +58,25 @@ class HackerNewsPost(BaseModel):
5858
class SearchResult(BaseModel):
5959
posts: List[HackerNewsPost]
6060

61-
structured_task = client.tasks.create_task(
61+
task = client.tasks.create_task(
6262
task="""
6363
Find top 10 Hacker News articles and return the title and url.
6464
""",
6565
llm="gpt-4.1",
6666
schema=SearchResult,
6767
)
6868

69-
print(f"Task ID: {structured_task.id}")
69+
print(f"Task ID: {task.id}")
7070

7171
while True:
72-
structured_status = client.tasks.get_task(task_id=structured_task.id, schema=SearchResult)
72+
structured_status = client.tasks.get_task(task_id=task.id, schema=SearchResult)
7373
print(structured_status.status)
7474

7575
if structured_status.status == "finished":
76-
if structured_status.parsed is None:
76+
if structured_status.parsed_output is None:
7777
print("No output")
7878
else:
79-
for post in structured_status.parsed.posts:
79+
for post in structured_status.parsed_output.posts:
8080
print(f" - {post.title} - {post.url}")
8181

8282
break

examples/run.py

Lines changed: 7 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -40,18 +40,20 @@ class HackerNewsPost(BaseModel):
4040
class SearchResult(BaseModel):
4141
posts: List[HackerNewsPost]
4242

43-
structured_result = client.tasks.create_task(
43+
task = client.tasks.create_task(
4444
task="""
4545
Find top 10 Hacker News articles and return the title and url.
4646
""",
4747
llm="gpt-4.1",
48-
structured_output_json=SearchResult,
48+
schema=SearchResult,
4949
)
5050

51-
print(f"Task ID: {structured_result.id}")
51+
print(f"Task ID: {task.id}")
52+
53+
result = task.complete()
5254

53-
if structured_result.parsed_output is not None:
54-
for post in structured_result.parsed_output.posts:
55+
if result.parsed_output is not None:
56+
for post in result.parsed_output.posts:
5557
print(f" - {post.title} - {post.url}")
5658

5759
print("Done")

examples/stream.py

Lines changed: 10 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -21,17 +21,8 @@ def stream_regular_task() -> None:
2121

2222
print(f"Task ID: {task.id}")
2323

24-
for res in task.stream():
25-
print(res.status)
26-
27-
if len(res.steps) > 0:
28-
last_step = res.steps[-1]
29-
print(f"{last_step.url} ({last_step.next_goal})")
30-
for action in last_step.actions:
31-
print(f" - {action}")
32-
33-
if res.status == "finished":
34-
print(res.done_output)
24+
for step in task.stream():
25+
print(f"Step {step.number}: {step.url} ({step.next_goal})")
3526

3627
print("Regular: DONE")
3728

@@ -53,21 +44,19 @@ class SearchResult(BaseModel):
5344
Find top 10 Hacker News articles and return the title and url.
5445
""",
5546
llm="gpt-4.1",
56-
structured_output_json=SearchResult,
47+
schema=SearchResult,
5748
)
5849

5950
print(f"Task ID: {task.id}")
6051

61-
for res in task.stream():
62-
print(res.status)
52+
for step in task.stream():
53+
print(f"Step {step.number}: {step.url} ({step.next_goal})")
54+
55+
result = task.complete()
6356

64-
if res.status == "finished":
65-
if res.parsed_output is None:
66-
print("No output")
67-
else:
68-
for post in res.parsed_output.posts:
69-
print(f" - {post.title} - {post.url}")
70-
break
57+
if result.parsed_output is not None:
58+
for post in result.parsed_output.posts:
59+
print(f" - {post.title} - {post.url}")
7160

7261
print("Done")
7362

src/browser_use/wrapper/browser_use_client.py

Whitespace-only changes.

0 commit comments

Comments
 (0)