naman1102 commited on
Commit
9fb6d05
·
1 Parent(s): 697d647
Files changed (3) hide show
  1. app.py +1 -15
  2. state.py +15 -0
  3. tools.py +1 -1
app.py CHANGED
@@ -15,22 +15,8 @@ from langgraph.graph.message import add_messages
15
  from langchain.schema import HumanMessage, AIMessage, SystemMessage
16
  # Create a ToolNode that knows about your web_search function
17
  import json
 
18
 
19
- from typing import TypedDict, Annotated
20
-
21
- class AgentState(TypedDict, total=False):
22
- messages: Annotated[list, add_messages]
23
- # Fields that the agent node can set to request a tool
24
- web_search_query: str
25
- ocr_path: str
26
- excel_path: str
27
- excel_sheet_name: str
28
- # Fields to hold the tool outputs
29
- web_search_result: str
30
- ocr_result: str
31
- excel_result: str
32
- # A “final_answer” field that the last agent node will fill
33
- final_answer: str# (Keep Constants as is)
34
  # --- Constants ---
35
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
36
 
 
15
  from langchain.schema import HumanMessage, AIMessage, SystemMessage
16
  # Create a ToolNode that knows about your web_search function
17
  import json
18
+ from state import AgentState
19
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
20
  # --- Constants ---
21
  DEFAULT_API_URL = "https://agents-course-unit4-scoring.hf.space"
22
 
state.py ADDED
@@ -0,0 +1,15 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ from typing import TypedDict, Annotated
2
+ from langgraph.graph.message import add_messages
3
+ class AgentState(TypedDict, total=False):
4
+ messages: Annotated[list, add_messages]
5
+ # Fields that the agent node can set to request a tool
6
+ web_search_query: str
7
+ ocr_path: str
8
+ excel_path: str
9
+ excel_sheet_name: str
10
+ # Fields to hold the tool outputs
11
+ web_search_result: str
12
+ ocr_result: str
13
+ excel_result: str
14
+ # A “final_answer” field that the last agent node will fill
15
+ final_answer: str# (Keep Constants as is)
tools.py CHANGED
@@ -5,7 +5,7 @@ from langchain_community.tools import DuckDuckGoSearchRun
5
  from pathlib import Path
6
  from PIL import Image
7
  import pytesseract
8
- from app import AgentState
9
  def web_search_tool(state: AgentState) -> AgentState:
10
  """
11
  Expects: state["web_search_query"] is a non‐empty string.
 
5
  from pathlib import Path
6
  from PIL import Image
7
  import pytesseract
8
+ from state import AgentState
9
  def web_search_tool(state: AgentState) -> AgentState:
10
  """
11
  Expects: state["web_search_query"] is a non‐empty string.