From cc0ad3f9f11ee6b5c7bb2a7f287f1eac2d41b611 Mon Sep 17 00:00:00 2001 From: naisanza Date: Tue, 8 Apr 2025 04:25:44 -0700 Subject: [PATCH 1/2] [gmail] fixed attachment handling --- automon/integrations/google/gmail/client.py | 17 ++++++++++------- automon/integrations/requestsWrapper/client.py | 9 ++------- 2 files changed, 12 insertions(+), 14 deletions(-) diff --git a/automon/integrations/google/gmail/client.py b/automon/integrations/google/gmail/client.py index 57c66b00..246fd5b2 100644 --- a/automon/integrations/google/gmail/client.py +++ b/automon/integrations/google/gmail/client.py @@ -445,10 +445,10 @@ def _improved_messages_get(self, message: Message) -> Message: if hasattr(_payload_part.body, 'attachmentId'): _attachmentId = _payload_part.body.attachmentId - _messages_attachments_get = self.messages_attachments_get(messageId=message.id, - attachmentId=_attachmentId) - - _payload_part.body.update_dict(_messages_attachments_get) + if _attachmentId: + _messages_attachments_get = self.messages_attachments_get(messageId=message.id, + attachmentId=_attachmentId) + _payload_part.body.update_dict(_messages_attachments_get) if hasattr(_payload_part.body, 'automon_attachment'): setattr(_payload_part, 'automon_attachment', _payload_part.body.automon_attachment) @@ -519,9 +519,12 @@ def messages_attachments_get(self, return api = UsersMessagesAttachments(self._userId).get(messageId=messageId, id=attachmentId) - self.requests.get(api, headers=self.config.headers) - attachments = MessagePartBody().update_dict(self.requests.to_dict()) - logger.debug(f"[GoogleGmailClient] :: messages_attachments_get :: {attachments=}") + if self.requests.get(api, headers=self.config.headers): + attachments = MessagePartBody().update_dict(self.requests.to_dict()) + logger.debug(f"[GoogleGmailClient] :: messages_attachments_get :: {attachments=}") + else: + raise Exception(f"[GoogleGmailClient] :: messages_attachments_get :: error :: {self.requests.text}") + logger.info(f"[GoogleGmailClient] :: messages_attachments_get :: done") return attachments diff --git a/automon/integrations/requestsWrapper/client.py b/automon/integrations/requestsWrapper/client.py index a79d84b1..2db81f66 100644 --- a/automon/integrations/requestsWrapper/client.py +++ b/automon/integrations/requestsWrapper/client.py @@ -150,7 +150,6 @@ def delete( if self.status_code == 200: return True - return False except Exception as error: self.errors = error raise Exception(f'RequestsClient :: DELETE :: ERROR :: {error=}') @@ -181,7 +180,6 @@ def get( self.errors = self.content - return False except Exception as error: self.errors = error raise Exception(f'RequestsClient :: GET :: ERROR :: {error=}') @@ -212,7 +210,6 @@ def patch( self.errors = self.content - return False except Exception as error: self.errors = error raise Exception(f'RequestsClient :: PATCH :: ERROR :: {error=}') @@ -243,7 +240,6 @@ def post( self.errors = self.content - return False except Exception as error: self.errors = error raise Exception(f'RequestsClient :: POST :: ERROR :: {error=}') @@ -274,7 +270,6 @@ def put( self.errors = self.content - return False except Exception as error: self.errors = error raise Exception(f'RequestsClient :: PUT :: ERROR :: {error=}') @@ -300,14 +295,14 @@ def to_dict(self): try: return json.loads(self.content) except Exception as error: - logger.error(f'RequestsClient :: TO DICT :: ERROR :: {error=}') + raise Exception(f'RequestsClient :: TO DICT :: ERROR :: {error=}') def to_json(self): if self.content: try: return json.dumps(json.loads(self.content)) except Exception as error: - logger.error(f'RequestsClient :: TO JSON :: ERROR :: {error=}') + raise Exception(f'RequestsClient :: TO JSON :: ERROR :: {error=}') def update_headers(self, headers: dict): return self.session.headers.update(headers) From 9885122d8b9bc7e9ce3157ab4f78d801ba8db79a Mon Sep 17 00:00:00 2001 From: naisanza Date: Tue, 8 Apr 2025 05:00:52 -0700 Subject: [PATCH 2/2] [gemini] fixed followup prompt --- .../google/gmail/tests/test_client_autoreply.py | 6 ------ automon/integrations/ollamaWrapper/prompt_templates.py | 4 +++- 2 files changed, 3 insertions(+), 7 deletions(-) diff --git a/automon/integrations/google/gmail/tests/test_client_autoreply.py b/automon/integrations/google/gmail/tests/test_client_autoreply.py index 228feb5b..6c39dbe4 100644 --- a/automon/integrations/google/gmail/tests/test_client_autoreply.py +++ b/automon/integrations/google/gmail/tests/test_client_autoreply.py @@ -204,12 +204,6 @@ def main(): if labels.resume in _first.automon_labels: continue - if [x for x in _thread.messages - if labels.retry in x.automon_labels]: - _FOUND = True - print('retry', end='') - break - if (labels.draft in _latest.automon_labels and labels.trash not in _latest.automon_labels ): diff --git a/automon/integrations/ollamaWrapper/prompt_templates.py b/automon/integrations/ollamaWrapper/prompt_templates.py index e813f799..31bd5466 100644 --- a/automon/integrations/ollamaWrapper/prompt_templates.py +++ b/automon/integrations/ollamaWrapper/prompt_templates.py @@ -17,4 +17,6 @@ def agent_machine_job_applicant(self): f"Respond to an inquiry regarding availability. Provide the provided scheduling resource. Be professional, efficient, and slightly informal. Ensure no extraneous information is included. \n" f"Today's date is {datetime.datetime.now()}. \n" f"Given the preceding email exchange, and if at least 4 days have elapsed without a response from the recruiter, craft a brief conversational reply from the perspective of the resume owner to gently inquire about the status of the application. Maintain the professional yet subtly assertive tone established in earlier communications. \n" - f"When crafting a response, first verify that at least four full days (96 hours) have elapsed since the last email received from the recruiter before composing a follow-up. If the four-day threshold has not been met, do not generate a follow-up response. \n") + f"When crafting a response, first verify that at least four full days (96 hours) have elapsed since the last email received from the recruiter before composing a follow-up. If the four-day threshold has not been met, do not generate a follow-up response. \n" + f"To accurately determine if a follow-up email is appropriate, the process must begin by extracting the precise timestamp from the recruiter's last email, explicitly noting the timezone. This timestamp must then be converted to the current timezone to facilitate an accurate comparison. The time difference between the recruiter's timestamp and the current timestamp should be calculated meticulously. Only if this calculated difference equals or exceeds 96 hours, representing four full days, should a follow-up email be considered. If the calculated time difference falls short of this 96-hour threshold, generating a follow-up email should be avoided entirely. \n" + f"From now on, *always* use the 'AVAILABILITY' link provided in the resume when responding to inquiries about scheduling or availability for calls or meetings. Prioritize the use of this link over any other method of communicating availability. \n")