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
I searched the LangGraph/LangChain documentation with the integrated search.
I used the GitHub search to find a similar question and didn't find it.
I am sure that this is a bug in LangGraph/LangChain rather than my code.
I am sure this is better as an issue rather than a GitHub discussion, since this is a LangGraph bug and not a design question.
Example Code
fromlangchainimporthubfromlangchain_core.output_parsersimportStrOutputParserfromlangchain_core.runnablesimportRunnablePassthroughfromlangchain_openaiimportChatOpenAIfromutilsimportmark_pageimportrefromlangchain_core.messagesimportSystemMessagefromstateimportAgentStatefromlangchain_core.runnablesimportRunnableLambdafromlanggraph.graphimportEND, START, StateGraphfromtoolsimportclick, type_text, scroll, wait, go_back, to_googleasyncdefannotate(state):
marked_page=awaitmark_page.with_retry().ainvoke(state["page"])
return {**state, **marked_page}
defformat_descriptions(state):
labels= []
fori, bboxinenumerate(state["bboxes"]):
text=bbox.get("ariaLabel") or""ifnottext.strip():
text=bbox["text"]
el_type=bbox.get("type")
labels.append(f'{i} (<{el_type}/>): "{text}"')
bbox_descriptions="\nValid Bounding Boxes:\n"+"\n".join(labels)
return {**state, "bbox_descriptions": bbox_descriptions}
defparse(text: str) ->dict:
action_prefix="Action: "ifnottext.strip().split("\n")[-1].startswith(action_prefix):
return {"action": "retry", "args": f"Could not parse LLM Output: {text}"}
action_block=text.strip().split("\n")[-1]
action_str=action_block[len(action_prefix) :]
split_output=action_str.split(" ", 1)
iflen(split_output) ==1:
action, action_input=split_output[0], Noneelse:
action, action_input=split_outputaction=action.strip()
ifaction_inputisnotNone:
action_input= [
inp.strip().strip("[]") forinpinaction_input.strip().split(";")
]
return {"action": action, "args": action_input}
# Will need a later version of langchain to pull# this image prompt templateprompt=hub.pull("wfh/web-voyager")
llm=ChatOpenAI(model="gpt-4o", max_tokens=4096)
agent=annotate|RunnablePassthrough.assign(
prediction=format_descriptions|prompt|llm|StrOutputParser() |parse
)
defupdate_scratchpad(state: AgentState):
"""After a tool is invoked, we want to update the scratchpad so the agent is aware of its previous steps"""old=state.get("scratchpad")
ifold:
txt=old[0].contentlast_line=txt.rsplit("\n", 1)[-1]
step=int(re.match(r"\d+", last_line).group()) +1else:
txt="Previous action observations:\n"step=1txt+=f"\n{step}. {state['observation']}"return {**state, "scratchpad": [SystemMessage(content=txt)]}
graph_builder=StateGraph(AgentState)
graph_builder.add_node("agent", agent)
graph_builder.add_edge(START, "agent")
graph_builder.add_node("update_scratchpad", update_scratchpad)
graph_builder.add_edge("update_scratchpad", "agent")
tools= {
"Click": click,
"Type": type_text,
"Scroll": scroll,
"Wait": wait,
"GoBack": go_back,
"Google": to_google,
}
fornode_name, toolintools.items():
graph_builder.add_node(
node_name,
# The lambda ensures the function's string output is mapped to the "observation"# key in the AgentStateRunnableLambda(tool) | (lambdaobservation: {"observation": observation}),
)
# Always return to the agent (by means of the update-scratchpad node)graph_builder.add_edge(node_name, "update_scratchpad")
defselect_tool(state: AgentState):
# Any time the agent completes, this function# is called to route the output to a tool or# to the end user.action=state["prediction"]["action"]
ifaction=="ANSWER":
returnENDifaction=="retry":
return"agent"returnactiongraph_builder.add_conditional_edges("agent", select_tool)
graph=graph_builder.compile()
Error Message and Stack Trace (if applicable)
Unexpected Application Error!
h.id.split is not a function
TypeError: h.id.split is not a function
at a5 (app://./assets/GraphThreadPage-bfi-2ssS.js:74:141765)
at oJ (app://./assets/GraphThreadPage-bfi-2ssS.js:74:143433)
at Iu (app://./assets/index-Bm4AZwAA.js:34:63888)
at Ms (app://./assets/index-Bm4AZwAA.js:34:75556)
at Dh (app://./assets/index-Bm4AZwAA.js:34:117134)
at _h (app://./assets/index-Bm4AZwAA.js:34:112129)
at Xg (app://./assets/index-Bm4AZwAA.js:34:112057)
at Bi (app://./assets/index-Bm4AZwAA.js:34:111911)
at Vs (app://./assets/index-Bm4AZwAA.js:34:108287)
at _d (app://./assets/index-Bm4AZwAA.js:34:109092)
Description
I'm trying to build the Web Voyager notebook in LangGraph Studio but the IDE is unable to build the graph.
Python version: 3.11 as defined in langgraph.json file, but the Conda environment I'm using for VSCode is running Python 3.9.4. Could this be related to the issue somehow?
The text was updated successfully, but these errors were encountered:
vbarda
transferred this issue from langchain-ai/langgraph
Nov 6, 2024
Checked other resources
Example Code
Error Message and Stack Trace (if applicable)
Unexpected Application Error! h.id.split is not a function TypeError: h.id.split is not a function at a5 (app://./assets/GraphThreadPage-bfi-2ssS.js:74:141765) at oJ (app://./assets/GraphThreadPage-bfi-2ssS.js:74:143433) at Iu (app://./assets/index-Bm4AZwAA.js:34:63888) at Ms (app://./assets/index-Bm4AZwAA.js:34:75556) at Dh (app://./assets/index-Bm4AZwAA.js:34:117134) at _h (app://./assets/index-Bm4AZwAA.js:34:112129) at Xg (app://./assets/index-Bm4AZwAA.js:34:112057) at Bi (app://./assets/index-Bm4AZwAA.js:34:111911) at Vs (app://./assets/index-Bm4AZwAA.js:34:108287) at _d (app://./assets/index-Bm4AZwAA.js:34:109092)
Description
I'm trying to build the Web Voyager notebook in LangGraph Studio but the IDE is unable to build the graph.
System Info
Platform: macOS 14.6.1
Python version: 3.11 as defined in
langgraph.json
file, but the Conda environment I'm using for VSCode is running Python 3.9.4. Could this be related to the issue somehow?The text was updated successfully, but these errors were encountered: