Gaykar commited on
Commit
44513b8
·
1 Parent(s): 4a43592

added traceback

Browse files
Files changed (2) hide show
  1. app/main.py +10 -1
  2. app/nodes/archive_node.py +6 -1
app/main.py CHANGED
@@ -16,6 +16,7 @@ from app.database.connection import SessionLocal
16
  from fastapi import Request
17
  from app.database.models import User
18
  from app.core.auth import create_access_token,get_current_user
 
19
 
20
  # CREATE GMAIL AUTH FILES FROM HF SECRETS
21
 
@@ -110,7 +111,13 @@ def process_email(request: EmailProcessRequest, db: Session = Depends(get_sessio
110
  "sender_email_body": request.sender_email_body,
111
  }
112
 
113
- final_state = graph.invoke(input_data, config=config)
 
 
 
 
 
 
114
 
115
  if final_state.get('triage_label') == "FOLLOW_UP_REQUIRED":
116
  if "__interrupt__" in final_state and not final_state.get("draft_id"):
@@ -138,6 +145,7 @@ def process_email(request: EmailProcessRequest, db: Session = Depends(get_sessio
138
 
139
  except Exception as e:
140
  logger.error(f"Error processing email: {str(e)}")
 
141
  raise HTTPException(status_code=500, detail=str(e))
142
 
143
 
@@ -196,6 +204,7 @@ def review_action(request: ReviewActionRequest,db: Session = Depends(get_session
196
 
197
  except Exception as e:
198
  logger.error(f"Error in review action: {str(e)}")
 
199
  raise HTTPException(status_code=500, detail=str(e))
200
 
201
 
 
16
  from fastapi import Request
17
  from app.database.models import User
18
  from app.core.auth import create_access_token,get_current_user
19
+ import traceback
20
 
21
  # CREATE GMAIL AUTH FILES FROM HF SECRETS
22
 
 
111
  "sender_email_body": request.sender_email_body,
112
  }
113
 
114
+ try:
115
+
116
+ final_state = graph.invoke(input_data, config=config)
117
+ except Exception as e:
118
+ logger.error(f"Error invoking graph: {str(e)}")
119
+ traceback.print_exc()
120
+ raise HTTPException(status_code=500, detail=f"Graph invocation error: {str(e)}")
121
 
122
  if final_state.get('triage_label') == "FOLLOW_UP_REQUIRED":
123
  if "__interrupt__" in final_state and not final_state.get("draft_id"):
 
145
 
146
  except Exception as e:
147
  logger.error(f"Error processing email: {str(e)}")
148
+ traceback.print_exc()
149
  raise HTTPException(status_code=500, detail=str(e))
150
 
151
 
 
204
 
205
  except Exception as e:
206
  logger.error(f"Error in review action: {str(e)}")
207
+ traceback.print_exc()
208
  raise HTTPException(status_code=500, detail=str(e))
209
 
210
 
app/nodes/archive_node.py CHANGED
@@ -41,5 +41,10 @@ def archive_node(state: EmailAgentState,config: RunnableConfig) -> dict:
41
 
42
 
43
 
 
 
 
44
  # A Context Manager is a brilliant Python tool that automatically handles the setup and cleanup of a resource for you. It guarantees that no matter what happens inside your code—even if an unexpected error crashes the system—your resources (like database connections or files) are safely closed and cleaned up.
45
- # A context manager is a Python utility used to allocate and release resources precisely when we want them to. By wrapping our database generator with @contextmanager, it allows us to use the standard with statement. This guarantees resource safety, ensuring that our database session is automatically and cleanly closed in the finally block, even if our core logic throws a runtime exception.
 
 
 
41
 
42
 
43
 
44
+
45
+
46
+
47
  # A Context Manager is a brilliant Python tool that automatically handles the setup and cleanup of a resource for you. It guarantees that no matter what happens inside your code—even if an unexpected error crashes the system—your resources (like database connections or files) are safely closed and cleaned up.
48
+ # A context manager is a Python utility used to allocate and release resources precisely when we want them to. By wrapping our database generator with @contextmanager, it allows us to use the standard with statement. This guarantees resource safety, ensuring that our database session is automatically and cleanly closed in the finally block, even if our core logic throws a runtime exception.
49
+
50
+