itskavya commited on
Commit
97ed181
·
verified ·
1 Parent(s): b550350

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -3
app.py CHANGED
@@ -8,7 +8,7 @@ from langchain_core.messages import AnyMessage
8
  from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
9
  from langgraph.graph.message import add_messages
10
  from langchain_hyperbrowser import HyperbrowserBrowserUseTool
11
- from langgraph.graph import START, StateGraph
12
  from langgraph.prebuilt import ToolNode, tools_condition
13
  from langchain_core.messages import HumanMessage, SystemMessage
14
  from langchain_community.tools import DuckDuckGoSearchResults
@@ -23,14 +23,14 @@ llm_with_tools = chat.bind_tools(tools)
23
  class State(TypedDict):
24
  messages = Annotated[list[AnyMessage], add_messages]
25
 
26
- def assistant(state:State):
27
  system_message = SystemMessage(content="You are a helpful assistant. Your job is to answer the questions asked of you as accurately as possible. You have access to search and browser tools, which you may use when needed to answer a question.")
28
  print(state["messages"])
29
  return {
30
  "messages": [llm_with_tools.invoke([system_message] + state["messages"])]
31
  }
32
 
33
- workflow = StateGraph(State)
34
  workflow.add_node("assistant", assistant)
35
  workflow.add_node("tools", ToolNode(tools))
36
  workflow.add_edge(START, "assistant")
 
8
  from langchain_huggingface import HuggingFaceEndpoint, ChatHuggingFace
9
  from langgraph.graph.message import add_messages
10
  from langchain_hyperbrowser import HyperbrowserBrowserUseTool
11
+ from langgraph.graph import START, StateGraph, MessagesState
12
  from langgraph.prebuilt import ToolNode, tools_condition
13
  from langchain_core.messages import HumanMessage, SystemMessage
14
  from langchain_community.tools import DuckDuckGoSearchResults
 
23
  class State(TypedDict):
24
  messages = Annotated[list[AnyMessage], add_messages]
25
 
26
+ def assistant(state:MessagesState):
27
  system_message = SystemMessage(content="You are a helpful assistant. Your job is to answer the questions asked of you as accurately as possible. You have access to search and browser tools, which you may use when needed to answer a question.")
28
  print(state["messages"])
29
  return {
30
  "messages": [llm_with_tools.invoke([system_message] + state["messages"])]
31
  }
32
 
33
+ workflow = StateGraph(state_schema=MessagesState)
34
  workflow.add_node("assistant", assistant)
35
  workflow.add_node("tools", ToolNode(tools))
36
  workflow.add_edge(START, "assistant")