Rathapoom commited on
Commit
842fce5
·
verified ·
1 Parent(s): 34da3fd

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +15 -18
app.py CHANGED
@@ -6,9 +6,11 @@ from data_service import DataAssessmentService
6
  from datetime import datetime
7
  import gspread
8
  from oauth2client.service_account import ServiceAccountCredentials
 
9
 
10
- # Initialize service
11
  service = DataAssessmentService(api_key=os.environ.get("OPENAI_API_KEY"))
 
12
 
13
  # Department mapping from abbreviations to full names
14
  DEPARTMENTS = {
@@ -60,29 +62,24 @@ def process_request(name, employee_id, email, department, other_dept, request_de
60
  # Combine department info
61
  final_department = other_dept if department == "Other" else department
62
 
63
- # Current timestamp
64
- timestamp = datetime.now().strftime("%Y-%m-%d %H:%M:%S")
65
-
66
  # Process the request through GPT
67
  result = service.assess_request(request_details)
68
 
69
- # Prepare data for Google Sheets
70
- sheet_data = {
71
- "Timestamp": timestamp,
72
- "Name": name,
73
- "Employee ID": employee_id,
74
- "Email": email,
75
- "Department": final_department,
76
- "Request Details": request_details,
77
- "Frequency": frequency,
78
- "Urgency": urgency,
79
- "System Response": json.dumps(result, ensure_ascii=False)
80
  }
81
 
82
- # Save to Google Sheets
83
- save_to_sheet(sheet_data)
84
 
85
- # Return formatted result
86
  return result
87
 
88
  # Create Gradio interface
 
6
  from datetime import datetime
7
  import gspread
8
  from oauth2client.service_account import ServiceAccountCredentials
9
+ from sheets_integration import SheetsLogger
10
 
11
+ # Initialize services
12
  service = DataAssessmentService(api_key=os.environ.get("OPENAI_API_KEY"))
13
+ sheets_logger = SheetsLogger()
14
 
15
  # Department mapping from abbreviations to full names
16
  DEPARTMENTS = {
 
62
  # Combine department info
63
  final_department = other_dept if department == "Other" else department
64
 
 
 
 
65
  # Process the request through GPT
66
  result = service.assess_request(request_details)
67
 
68
+ # Prepare data for logging
69
+ request_data = {
70
+ "name": name,
71
+ "employee_id": employee_id,
72
+ "email": email,
73
+ "department": final_department,
74
+ "request_details": request_details,
75
+ "frequency": frequency,
76
+ "urgency": urgency,
77
+ "system_response": json.dumps(result, ensure_ascii=False)
 
78
  }
79
 
80
+ # Log to Google Sheets
81
+ sheets_logger.log_request(request_data)
82
 
 
83
  return result
84
 
85
  # Create Gradio interface