Package: inarrator
INarratorInstall the Packagepip install inarratorUse the PackageGmailIn the Google Cloud console, enable the GmailAPI.Register your AppIn the Google Cloud console, go toOAuth Consent screenOnce on OAuth Consent Screen, select User Type External and then click create:Now complete the registration of your app which is fairly simple. Just remember two things:Since this is a Testing App, you will have to add some test users (ideally make it the same email through which you are registering the app)Add.../auth/gmail.readonlyscopeCreate "gmail_credentials.json" file:Go toCredentialsClick+ CREATE CREDENTIALS > OAuth client IDSELECTDesktop appas application typeAfter this a pop up will appear which will have a option to DOWNLOAD OAuth Client JSON file.Save the JSON and rename it togmail_credentials.jsonUse the inarratorChat-GPT Examplefrominarrator.emailimportGmailfrominarrator.summarizer.gptimportGPTModelgmail=Gmail()gmail.authenticate(credentials_path="gmail_credentials.json",gmail_scope=["https://www.googleapis.com/auth/gmail.readonly"],)# https://support.google.com/mail/answer/7190 (You can read more about Gmail Filters)emails=gmail.get_latest_emails(gmail_filters="from:(-noreply -no-reply) is:unread -category:social -category:promotions -unsubscribe",#gmail_max_emails="30",)model=GPTModel(model_name='gpt-3.5-turbo-16k',api_token="")# OPENAI_API_KEYdocuments=[]foremailinemails:documents.append(email)print(model.summarize(documents))Hugging Face Hub Examplefrominarrator.emailimportGmailfrominarrator.summarizerimportHuggingFaceModelgmail=Gmail()gmail.authenticate(credentials_path="gmail_credentials.json",gmail_scope=["https://www.googleapis.com/auth/gmail.readonly"],)emails=gmail.get_latest_emails(gmail_filters="from:(-noreply -no-reply) is:unread -category:social -category:promotions -unsubscribe",gmail_max_emails="30",)model=HuggingFaceModel(model_name="tuner007/pegasus_summarizer",api_token="")# HF_HUB_TOKENprint(model.summarize(emails[0]))# Hugging Face Hub Models currently can summarize one email at a time.OutlookCreate a New AppRegistrationRequest API permissions (Only Mail.Read)Configure the PlatformAdd a Mobile and Desktop ApplicationChoose the Following ConfigurationCreate a new client secretClick on+ New client secret.Now create the following JSON and name itoutlook_credentials.json. You can getApplication (client) ID&Directory (tenant) IDfrom overview of your App.{"application_id":"Application (client) ID","authority_url":"https://login.microsoftonline.com/{Directory (tenant) ID}","outlook_scope":["Mail.Read"]}Since OAuth only work https but our redirect URI is localhost, we would have to make the following environment variableexport OAUTHLIB_INSECURE_TRANSPORT=1Use the inarratorChat-GPT Examplefrominarrator.emailimportOutLookfrominarrator.summarizer.gptimportGPTModeloutlook=OutLook()outlook.authenticate(credentials_path="outlook_credentials.json",outlook_scope=["Mail.Read"],)emails=outlook.get_latest_emails(outlook_max_emails=5,)model=GPTModel(model_name='gpt-3.5-turbo-16k',api_token="")# OPENAI_API_KEYdocuments=[]foremailinemails:documents.append(email)print(model.summarize(documents))Hugging Face Hub Examplefrominarrator.emailimportOutLookfrominarrator.summarizer.huggingfaceimportHuggingFaceModeloutlook=OutLook()outlook.authenticate(credentials_path="outlook_credentials.json",outlook_scope=["Mail.Read"],)emails=outlook.get_latest_emails(outlook_max_emails=5,)model=HuggingFaceModel(model_name="tuner007/pegasus_summarizer",api_token="")# HF_HUB_TOKENprint(model.summarize(emails[0]))# Hugging Face Hub Models currently can summarize one email at a time.