Skip to content

Hybrid tree formatting + link mapping #645

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
wants to merge 10 commits into from
Closed

Conversation

seanmcguire12
Copy link
Member

@seanmcguire12 seanmcguire12 commented Apr 7, 2025

why

  • reduce tokens & redundancy in the hybrid tree
  • improve formatting of the hybrid tree (by removing & collapsing unnecessary nodes)

what changed

  • this PR reduces redundancy in the hybrid tree by combining StaticText nodes into their parent node when possible
  • it also excludes StaticText nodes if they are a child of a link
  • links are now formatted inline with the following format: [@id]
  • the TreeResult type now holds an idToUrl dictionary where node IDs are keys and URLs are values

example

here is what the tree looked like before:

Screenshot 2025-04-07 at 4 25 36 PM

here is what the tree looks like now:

Screenshot 2025-04-07 at 4 23 43 PM

future PRs (fast follow)

  • inform the LLM on the change to link formatting
  • when an LLM chooses an ID, lookup the URL in the idToUrl mapping, and include that in the extraction result
  • remove text_extract, just have one extract function
  • reintroduce chunking

test plan

  • evals

Copy link

changeset-bot bot commented Apr 7, 2025

🦋 Changeset detected

Latest commit: a1075e4

The changes in this PR will be included in the next version bump.

This PR includes changesets to release 1 package
Name Type
@browserbasehq/stagehand Patch

Not sure what this means? Click here to learn what changesets are.

Click here if you're a maintainer who wants to add another changeset to this PR

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant