You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Model: Doesn't work with gpt-4.1-mini (but seems to work when not specifying a model, probably will use gpt-4o then)
Issue Description
As described in the documentation Stagehand uses internal ID's to map URLs to the ExtractedResult. My final result however doesn't include the URLs for all items found on the page
Steps to Reproduce
Run code below (will not work)
Comment the line that specifies the model (will work)
Minimal Reproduction Code
fromstagehandimportStagehandimportasynciofromdotenvimportload_dotenvfrompydanticimportBaseModel, HttpUrlfromtypingimportOptionalimportjsonload_dotenv()
classAgency(BaseModel):
name: strurl: HttpUrldescription: Optional[str] =Nonelocation: Optional[str] =NoneclassAgencies(BaseModel):
agencies: list[Agency]
asyncdefmain():
stagehand=Stagehand(
env="LOCAL",
headless=False,
model_name="gpt-4.1-mini"
)
all_agencies= []
awaitstagehand.init()
page=stagehand.pageawaitpage.goto("<url I want to scrape>")
should_continue=Truewhileshould_continue:
agencies=awaitpage.extract("Extract all agencies from the page", schema=Agencies)
all_agencies.extend([agency.model_dump(mode='json') foragencyinagencies.agencies])
next_page_button=awaitpage.observe("Find the next page button")
should_continue=has_next_page(next_page_button)
ifshould_continue:
awaitpage.click(next_page_button[0].selector)
print(all_agencies)
withopen("agencies.json", "w") asf:
json.dump(all_agencies, f)
if__name__=="__main__":
asyncio.run(main())
Error Messages / Log trace
Screenshots / Videos
Related Issues
No related PRs found (also not in Typescript version)
Activity