AIEmailAutomationUtility 0.0.11__py3-none-any.whl → 0.0.12__py3-none-any.whl

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
@@ -7,7 +7,7 @@ from flask import Flask,request
7
7
 
8
8
  class Email_Classification:
9
9
  def detect_category_openai(self, openai_api_key, categories, email_body):
10
- logger.log("Inside detect_category_openai::")
10
+ print("Inside detect_category_openai::")
11
11
  try:
12
12
  categories_str = ', '.join(categories)
13
13
  message = [{
@@ -27,14 +27,14 @@ class Email_Classification:
27
27
  presence_penalty=0,
28
28
  )
29
29
  category = json.loads(result.choices[0].message.content.replace("\n```", "").replace("```", "").replace("json","").replace("JSON","").replace("csv","").replace("CSV",""))['category']
30
- logger.log(f"category:: {category}")
30
+ print(f"category:: {category}")
31
31
  return {"status": "Success", "message": category}
32
32
  except Exception as e:
33
33
  logger.log(f"Error detecting category with OpenAI: {str(e)}")
34
34
  return {"success": "Failed", "message": f"Error detecting category with OpenAI: {str(e)}"}
35
35
 
36
36
  def detect_category_gemini(self, gemini_api_key, categories, email_body, detect_email_category=True, signature=None):
37
- logger.log("Inside detect_category_gemini::")
37
+ print("Inside detect_category_gemini::")
38
38
  try:
39
39
  categories_str = ', '.join(categories)
40
40
  if detect_email_category:
@@ -74,23 +74,23 @@ class Email_Classification:
74
74
  if final_result.startswith("{{") and final_result.endswith("}}"):
75
75
  final_result = final_result[1:-1]
76
76
  final_result = json.loads(final_result)
77
- logger.log(f"finalResult::: {final_result}")
77
+ print(f"finalResult::: {final_result}")
78
78
  except json.JSONDecodeError:
79
- logger.log(f"Exception : Invalid JSON Response GEMINI 1.5: {final_result} {type(final_result)}")
79
+ print(f"Exception : Invalid JSON Response GEMINI 1.5: {final_result} {type(final_result)}")
80
80
 
81
81
  if detect_email_category:
82
82
  category = final_result.get('category', 'Others')
83
83
  return {"status": "Success", "message": category}
84
84
  else:
85
- logger.log(f"finalResult::: {final_result}")
85
+ print(f"finalResult::: {final_result}")
86
86
  return {"status": "Success", "message": final_result}
87
87
 
88
88
  except Exception as e:
89
- logger.log(f"Error with Gemini AI detection/generation: {str(e)}")
89
+ print(f"Error with Gemini AI detection/generation: {str(e)}")
90
90
  return {"success": "Failed", "message": f"Error with Gemini AI detection/generation: {str(e)}"}
91
91
 
92
92
  def detect_category_local(self, openai_api_key, categories, email_body, detect_email_category=True, signature=None, local_ai_url=None):
93
- logger.log("Inside detect_category_local::")
93
+ print("Inside detect_category_local::")
94
94
  try:
95
95
  categories_str = ', '.join(categories)
96
96
  if detect_email_category:
@@ -125,17 +125,17 @@ class Email_Classification:
125
125
  if json_start != -1 and json_end != -1:
126
126
  json_str = final_result[json_start:json_end]
127
127
  final_result = json.loads(json_str)
128
- logger.log(f"finalResult::: {final_result}")
128
+ print(f"finalResult::: {final_result}")
129
129
  category = final_result.get('category', 'Others')
130
- logger.log(f"category::1037 {category}")
130
+ print(f"category::1037 {category}")
131
131
  return {"status": "Success", "message": category}
132
132
  else:
133
133
  raise ValueError("No valid JSON object found in the response")
134
134
  except json.JSONDecodeError as e:
135
- logger.log(f"JSON decode error: {e}")
135
+ print(f"JSON decode error: {e}")
136
136
  raise
137
137
  else:
138
- logger.log(f"finalResult:1040 {final_result}")
138
+ print(f"finalResult:1040 {final_result}")
139
139
  return {"status": "Success", "message": final_result}
140
140
 
141
141
  except Exception as e:
@@ -16,7 +16,7 @@ class Email_DocumentUploader:
16
16
 
17
17
  # Save file temporarily
18
18
  file_path = os.path.join(temp_dir, file_data['filename'])
19
- logger.log(f"file_path:: {file_path}")
19
+ print(f"file_path:: {file_path}")
20
20
  with open(file_path, 'wb') as f:
21
21
  f.write(file_data['content'])
22
22
 
@@ -46,7 +46,7 @@ class Email_DocumentUploader:
46
46
  files=files,
47
47
  data=params
48
48
  )
49
- logger.log("file read")
49
+ print("file read")
50
50
 
51
51
  if response.status_code == 200:
52
52
  result = json.loads(response.text)
@@ -56,7 +56,7 @@ class Email_DocumentUploader:
56
56
  return str(response.status_code), f"Upload failed: {response.text}"
57
57
 
58
58
  def email_document_upload(self, file, parameters_details):
59
- logger.log(f"file ::: {file}")
59
+ print(f"file ::: {file}")
60
60
  if not file:
61
61
  return "file not found"
62
62
 
@@ -81,5 +81,5 @@ class Email_DocumentUploader:
81
81
 
82
82
  response_status, restAPI_Result = self.upload_document(upload_config, file_data)
83
83
 
84
- logger.log(f"Upload_Document response result: {restAPI_Result}")
84
+ print(f"Upload_Document response result: {restAPI_Result}")
85
85
  return response_status, restAPI_Result
@@ -110,7 +110,7 @@ class Email_Draft:
110
110
  success, draft_message = self.draft_email_response(email_details)
111
111
 
112
112
  if success == "Success":
113
- logger.log(f"draft_message {draft_message}")
113
+ print(f"draft_message {draft_message}")
114
114
  return draft_message
115
115
 
116
116
  except Exception as e:
@@ -99,7 +99,7 @@ class Email_Read:
99
99
 
100
100
  mail = imaplib.IMAP4_SSL(host, port)
101
101
  mail.login(reciever_email_addr, receiver_email_pwd)
102
- logger.log("login successfully")
102
+ print("login successfully")
103
103
  mail.select('inbox')
104
104
 
105
105
  file_JsonArray, categories = self.read_JSON_File(templateName)
@@ -112,8 +112,8 @@ class Email_Read:
112
112
  email_ids = email_ids[0].split()
113
113
 
114
114
  if not email_ids:
115
- logger.log("Email not found, going to check new mail")
116
- logger.log("Email not found,\ngoing to check new mail \n")
115
+ print("Email not found, going to check new mail")
116
+ print("Email not found,\ngoing to check new mail \n")
117
117
  else:
118
118
 
119
119
  for email_id in email_ids:
@@ -162,7 +162,7 @@ class Email_Read:
162
162
  email_classification = Email_Classification()
163
163
  emailCategory = email_classification.detect_category(email_cat_data)
164
164
  emailCategory = emailCategory['message']
165
- logger.log(f"\nDetected Email category ::: {emailCategory}")
165
+ print(f"\nDetected Email category ::: {emailCategory}")
166
166
 
167
167
  if emailCategory == 'Others':
168
168
  logger.log(f"Marking email as UNREAD. ")
@@ -172,7 +172,7 @@ class Email_Read:
172
172
  mail.copy(email_id, LABEL)
173
173
  mail.store(email_id, '+FLAGS', '\\Deleted') # Mark for deletion
174
174
  mail.expunge()
175
- logger.log(f"Mail removed from inbox and added to '{LABEL}' label.")
175
+ print(f"Mail removed from inbox and added to '{LABEL}' label.")
176
176
 
177
177
  elif emailCategory == "Product Enquiry":
178
178
 
@@ -188,7 +188,7 @@ class Email_Read:
188
188
 
189
189
  email_draft = Email_Draft()
190
190
  status, response = email_draft.draft_email(email_config, email_details, openai_Response['message'])
191
- logger.log(f"status ::: {status}")
191
+ print(f"status ::: {status}")
192
192
  else :
193
193
  message = f"Invalid response method received '{responseMethod}' for category : '{emailCategory}'"
194
194
  raise ValueError(message)
@@ -201,7 +201,7 @@ class Email_Read:
201
201
 
202
202
  email_draft = Email_Draft()
203
203
  status, response = email_draft.draft_email(email_config, email_details, LocalAI_Response)
204
- logger.log(f"status ::: {status}")
204
+ print(f"status ::: {status}")
205
205
  elif Model_Name == "GeminiAI":
206
206
  logger.log("GeminiAI")
207
207
  Detect_Email_category = False
@@ -211,7 +211,7 @@ class Email_Read:
211
211
 
212
212
  email_draft = Email_Draft()
213
213
  status, response = email_draft.draft_email(email_config, email_details, GeminiAI_Response)
214
- logger.log(f"status ::: {status}")
214
+ print(f"status ::: {status}")
215
215
  else:
216
216
  raise ValueError(f"Invalid Model Name provided : '{Model_Name}'")
217
217
 
@@ -226,18 +226,18 @@ class Email_Read:
226
226
  email_upload_document = Email_DocumentUploader()
227
227
  with open(f"temp/{fileName}", "rb") as file:
228
228
  response_status, restAPI_Result = email_upload_document.email_document_upload(file, parameters)
229
- logger.log(f"email_upload_document_response ::: {restAPI_Result}")
229
+ print(f"email_upload_document_response ::: {restAPI_Result}")
230
230
  else:
231
231
 
232
232
  new_fileName = self.create_file_from_emailBody(email_body, sender_email_addr, parameters)
233
233
  with open(f"temp/{new_fileName}", "rb") as file:
234
234
  response_status, restAPI_Result = email_upload_document.email_document_upload(file, parameters)
235
- logger.log(f"email_upload_document_response ::: {restAPI_Result}")
235
+ print(f"email_upload_document_response ::: {restAPI_Result}")
236
236
 
237
237
  if response_status == "200" :
238
- logger.log(f"Attachment uploaded sucessfully against Document id: '{restAPI_Result}'.")
238
+ print(f"Attachment uploaded sucessfully against Document id: '{restAPI_Result}'.")
239
239
  else:
240
- logger.log(restAPI_Result)
240
+ print(restAPI_Result)
241
241
 
242
242
  else :
243
243
  message = f"Invalid response method received '{responseMethod}' for category : '{emailCategory}'"
@@ -1,6 +1,6 @@
1
1
  Metadata-Version: 2.1
2
2
  Name: AIEmailAutomationUtility
3
- Version: 0.0.11
3
+ Version: 0.0.12
4
4
  Summary: Create 2 different methods in read_email for different client
5
5
  Author: Proteus Technology PVT. LTD.
6
6
  Author-email: <apps@baseinformation.com>
@@ -0,0 +1,14 @@
1
+ AIEmailAutomationUtility/EmailReplyAssistant.py,sha256=NQlBPugGdEvNwGFOoaiJNb4JDQB_DYvCy_hWLgAVLns,3938
2
+ AIEmailAutomationUtility/Email_Classification.py,sha256=nq958GJ5GwOF7FgMSoItp1AOD0CUUg0Dz25ERLxy1GI,9283
3
+ AIEmailAutomationUtility/Email_DocumentUploader.py,sha256=bkDWekmhOOd7G6dAoVYYTEcerT0rGP49xlMIORU6mEw,3035
4
+ AIEmailAutomationUtility/Email_Draft.py,sha256=uCFiu9OUWDGmUBnWv9RqElv2P43SFnRw1HB6YuQ5p_8,5239
5
+ AIEmailAutomationUtility/Email_Read.py,sha256=qRtHY7qxQPe90JjMv27yW3bZoNtnTyuZqAl1cBB3PcQ,20732
6
+ AIEmailAutomationUtility/Email_Upload_Document.py,sha256=3bdkxfDlwoeRp-46KPw2Gs1dqBhEIoA1yE5GCudpdV8,1320
7
+ AIEmailAutomationUtility/Save_Draft.py,sha256=yzLgFN14I_lXE6qL0I3tKNduvcnWdbsY9i2mKdTtio4,5348
8
+ AIEmailAutomationUtility/Save_Transaction.py,sha256=Gg1w6hhzHmEFjsuzYvkq-3-EsWReetjLHsYSv5YIGgM,3816
9
+ AIEmailAutomationUtility/__init__.py,sha256=bB7N-qQD85RdMaXHg_ZU5oPtHtx9zgeG6-ue4rhcfYI,379
10
+ AIEmailAutomationUtility-0.0.12.dist-info/LICENCE.txt,sha256=2qX9IkEUBx0VJp1Vh9O2dsRwE-IpYId0lXDyn7OVsJ8,1073
11
+ AIEmailAutomationUtility-0.0.12.dist-info/METADATA,sha256=p2FYQU14fI60ODJSPRJSS2mGQ8z5jF_U80F2tTHCgTw,623
12
+ AIEmailAutomationUtility-0.0.12.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
13
+ AIEmailAutomationUtility-0.0.12.dist-info/top_level.txt,sha256=3jTWrTUblVkaP7mpwY2UBSnrlfot5Ykpfsehyke-Uzw,25
14
+ AIEmailAutomationUtility-0.0.12.dist-info/RECORD,,
@@ -1,14 +0,0 @@
1
- AIEmailAutomationUtility/EmailReplyAssistant.py,sha256=NQlBPugGdEvNwGFOoaiJNb4JDQB_DYvCy_hWLgAVLns,3938
2
- AIEmailAutomationUtility/Email_Classification.py,sha256=eL52Td50zo7V0QTIqjN4Khhg-5HKvf2RUITIcKz5yZ0,9343
3
- AIEmailAutomationUtility/Email_DocumentUploader.py,sha256=ImTmMz_JeU6Xynt9kyu7lFv7vqrxzqAtBF-A7014fYc,3055
4
- AIEmailAutomationUtility/Email_Draft.py,sha256=BfseewnnlwNl1moodq3kZiUPXDUE9a_nQjuFQsUp3fY,5244
5
- AIEmailAutomationUtility/Email_Read.py,sha256=Wc8HzZfMkDZ6XjjfNOibrI6r5XsytPEoA1ilw4DPRuA,20792
6
- AIEmailAutomationUtility/Email_Upload_Document.py,sha256=3bdkxfDlwoeRp-46KPw2Gs1dqBhEIoA1yE5GCudpdV8,1320
7
- AIEmailAutomationUtility/Save_Draft.py,sha256=yzLgFN14I_lXE6qL0I3tKNduvcnWdbsY9i2mKdTtio4,5348
8
- AIEmailAutomationUtility/Save_Transaction.py,sha256=Gg1w6hhzHmEFjsuzYvkq-3-EsWReetjLHsYSv5YIGgM,3816
9
- AIEmailAutomationUtility/__init__.py,sha256=bB7N-qQD85RdMaXHg_ZU5oPtHtx9zgeG6-ue4rhcfYI,379
10
- AIEmailAutomationUtility-0.0.11.dist-info/LICENCE.txt,sha256=2qX9IkEUBx0VJp1Vh9O2dsRwE-IpYId0lXDyn7OVsJ8,1073
11
- AIEmailAutomationUtility-0.0.11.dist-info/METADATA,sha256=IQIl4bsEQoWRCJuHhkUaqeZvgQQga8TK4f2y3SDVtfE,623
12
- AIEmailAutomationUtility-0.0.11.dist-info/WHEEL,sha256=GJ7t_kWBFywbagK5eo9IoUwLW6oyOeTKmQ-9iHFVNxQ,92
13
- AIEmailAutomationUtility-0.0.11.dist-info/top_level.txt,sha256=3jTWrTUblVkaP7mpwY2UBSnrlfot5Ykpfsehyke-Uzw,25
14
- AIEmailAutomationUtility-0.0.11.dist-info/RECORD,,