diff --git a/README.md b/README.md index 015b491..f90286e 100644 --- a/README.md +++ b/README.md @@ -41,6 +41,18 @@ The following environment variables must be set to configure the bot: `USE_PRIVATE_API` : Whether or not to use the Private API in BlueBubbles. Default is `false` +## Configuring Skills + +Each skill consumes it's own environment variables to configure and run. Here are some of the configurable options for the included skills: + +### chatgpt.py + +`OPENAI_API_KEY` : The API key to OpenAI, from OpenAI. + +`OPENAI_ORGANIZATION` : The Organization ID from OpenAI. + +`RESPONSE_PREAMBLE` : Instructions to ChatGPT for how it should respond and behave, given as a preamble for any conversation with it. A default preamble is provided (see [persona/skills/chatgpt.py](chatgpt.py). + ## Justification Initially all I wanted to do was translate Apple Music links to Spotify links and vice-versa. But building platforms is more fun than building tools. diff --git a/bin/bluebubbles_bot b/bin/bluebubbles_bot index e9f6fd0..96cccca 100644 --- a/bin/bluebubbles_bot +++ b/bin/bluebubbles_bot @@ -123,11 +123,11 @@ if __name__ == '__main__': if content['type'] == 'new-message' : message = content['data'] # Determine sender and receiver - if message['isFromMe'] : + if not message['isFromMe'] : sender = message['handle']['address'] recipients = [] else : - sender = None + sender = 'Me' recipients = [message['handle']['address']] # Resolve attachments attachments = [] @@ -138,10 +138,13 @@ if __name__ == '__main__': # Get any effects or subjects subject = '' effect_id = '' + isfromme = False if 'subject' in message.keys() : subject = message['subject'] if 'expressiveSendStyleId' in message.keys() : effect_id = message['expressiveSendStyleId'] + if 'isFromMe' in message.keys() : + isfromme = message['isFromMe'] # Craft the message persona_message = persona.Message( text=message['text'], @@ -151,7 +154,7 @@ if __name__ == '__main__': timestamp=date_sent, recipients=recipients, attachments=attachments, - meta={'subject': subject, 'effectId': effect_id} + meta={'subject': subject, 'effectId': effect_id,'isFromMe': isfromme} ) persona_message = get_full_attachments(persona_message) responses = current_persona.receive_message(persona_message) diff --git a/persona/persona.py b/persona/persona.py index f9dd9ba..ab9af7c 100644 --- a/persona/persona.py +++ b/persona/persona.py @@ -102,10 +102,14 @@ class Persona : def startup(self) : """Startup all message skill processors""" for skill in self._skill_map.keys() : - ClassInstance = self._skill_map[skill] - skillinstance = ClassInstance() - skillinstance.startup() - self.ready_skills.update({skill:skillinstance}) + try : + ClassInstance = self._skill_map[skill] + skillinstance = ClassInstance() + skillinstance.startup() + self.ready_skills.update({skill:skillinstance}) + except Exception as e : + self.log.error(str(e)) + continue def receive_message(self,message: Message) : diff --git a/setup.py b/setup.py index 0167515..181e786 100644 --- a/setup.py +++ b/setup.py @@ -54,7 +54,7 @@ setup(name='bluebubbles_bot', description='A chatbot for a local BlueBlubbles server.', packages=find_packages(exclude=['tests']), package_data={"": ['skills/*.py']}, - install_requires=['pyyaml','datetime','requests','fastapi[all]'], + install_requires=['pyyaml','datetime','requests','fastapi[all]','openai'], scripts=['bin/bluebubbles_bot'], long_description=open('README.md').read(), zip_safe=True