Spaces:
Sleeping
Sleeping
Update app.py
Browse files
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
|
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
|
70 |
-
|
71 |
-
"
|
72 |
-
"
|
73 |
-
"
|
74 |
-
"
|
75 |
-
"
|
76 |
-
"
|
77 |
-
"
|
78 |
-
"
|
79 |
-
"System Response": json.dumps(result, ensure_ascii=False)
|
80 |
}
|
81 |
|
82 |
-
#
|
83 |
-
|
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
|