naman1102 commited on
Commit
f74ec57
·
1 Parent(s): 133d76b

Update tools.py

Browse files
Files changed (1) hide show
  1. tools.py +9 -9
tools.py CHANGED
@@ -104,16 +104,16 @@ def ocr_image_tool(state: AgentState) -> AgentState:
104
  """
105
  print("reached ocr_image_tool")
106
  path_or_id = state.get("ocr_path", "")
107
- if not path_or_id:
108
- return {}
109
 
110
  # 1) Determine local_img: either existing path_or_id or download by Task ID
111
- local_img = ""
112
- if os.path.exists(path_or_id):
113
- local_img = path_or_id
114
- else:
115
- for ext in ("png", "jpg", "jpeg"):
116
- candidate = _download_file_for_task(path_or_id, ext)
117
  if candidate:
118
  local_img = candidate
119
  break
@@ -185,7 +185,7 @@ def ocr_image_tool(state: AgentState) -> AgentState:
185
 
186
  # 6) Combine OCR + caption
187
  combined = f"OCR text:\n{ocr_text}\n\nImage caption:\n{caption}"
188
-
189
  return {
190
  "ocr_path": None,
191
  "ocr_result": combined
 
104
  """
105
  print("reached ocr_image_tool")
106
  path_or_id = state.get("ocr_path", "")
107
+ # if not path_or_id:
108
+ # return {}
109
 
110
  # 1) Determine local_img: either existing path_or_id or download by Task ID
111
+ # local_img = ""
112
+ # if os.path.exists(path_or_id):
113
+ # local_img = path_or_id
114
+ # else:
115
+ for ext in ("png", "jpg", "jpeg"):
116
+ candidate = _download_file_for_task(state.get("task_id"), ext)
117
  if candidate:
118
  local_img = candidate
119
  break
 
185
 
186
  # 6) Combine OCR + caption
187
  combined = f"OCR text:\n{ocr_text}\n\nImage caption:\n{caption}"
188
+ print("combined: ")
189
  return {
190
  "ocr_path": None,
191
  "ocr_result": combined