Open Zubair2019 opened 5 days ago
@Zubair2019 you can pass it via config like this
class AgentState(TypedDict):
task: str
def run(playwright: Playwright) -> None:
browser = playwright.chromium.launch(headless=False)
context = browser.new_context()
page = context.new_page()
with SqliteSaver.from_conn_string(":memory:") as memory:
graph = builder.compile(checkpointer=memory)
config = {"configurable": {"thread_id": "1", "browser_page":page}}
try:
for s in graph.stream({
'task': "",
"max_revisions": 0,
"revision_number": 1,
}, config):
print(s)
except Exception as e:
print(f"Error in astream: {e}")
raise e
let me know if this works for you!
Error in astream: 'browser_page'
Traceback (most recent call last):
File "/Users/air/Github/0dfx/plan_agent/agDomPWCorrection.py", line 202, in
KeyError: 'browser_page'
@Zubair2019 "browser_page" is not going to be available in the state if you pass it via config -- you'll need to remove the browser_page
key from the state schema
@vbarda I need to save the browser_page in the state. if i use graph = builder.compile()
instead of graph = builder.compile(checkpointer=memory)
it works fine. The problem is with browser_page which is a playwright object and when langraph tries to save the object in the database it triers to serialize it first and thats where the error creeps in. It is not able to serialize the page object for saving. However, I need to save the browser_page as an agent state.
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Description
System Info
System Information
Package Information
Optional packages not installed
Other Dependencies