Added basic ChatGPT as a skill
All checks were successful
git.cronocide.net/bluebubbles-bot/pipeline/head This commit looks good
All checks were successful
git.cronocide.net/bluebubbles-bot/pipeline/head This commit looks good
This commit is contained in:
parent
de3b39f3ca
commit
74dae2c133
12
README.md
12
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`
|
`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
|
## 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.
|
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.
|
||||||
|
@ -123,11 +123,11 @@ if __name__ == '__main__':
|
|||||||
if content['type'] == 'new-message' :
|
if content['type'] == 'new-message' :
|
||||||
message = content['data']
|
message = content['data']
|
||||||
# Determine sender and receiver
|
# Determine sender and receiver
|
||||||
if message['isFromMe'] :
|
if not message['isFromMe'] :
|
||||||
sender = message['handle']['address']
|
sender = message['handle']['address']
|
||||||
recipients = []
|
recipients = []
|
||||||
else :
|
else :
|
||||||
sender = None
|
sender = 'Me'
|
||||||
recipients = [message['handle']['address']]
|
recipients = [message['handle']['address']]
|
||||||
# Resolve attachments
|
# Resolve attachments
|
||||||
attachments = []
|
attachments = []
|
||||||
@ -138,10 +138,13 @@ if __name__ == '__main__':
|
|||||||
# Get any effects or subjects
|
# Get any effects or subjects
|
||||||
subject = ''
|
subject = ''
|
||||||
effect_id = ''
|
effect_id = ''
|
||||||
|
isfromme = False
|
||||||
if 'subject' in message.keys() :
|
if 'subject' in message.keys() :
|
||||||
subject = message['subject']
|
subject = message['subject']
|
||||||
if 'expressiveSendStyleId' in message.keys() :
|
if 'expressiveSendStyleId' in message.keys() :
|
||||||
effect_id = message['expressiveSendStyleId']
|
effect_id = message['expressiveSendStyleId']
|
||||||
|
if 'isFromMe' in message.keys() :
|
||||||
|
isfromme = message['isFromMe']
|
||||||
# Craft the message
|
# Craft the message
|
||||||
persona_message = persona.Message(
|
persona_message = persona.Message(
|
||||||
text=message['text'],
|
text=message['text'],
|
||||||
@ -151,7 +154,7 @@ if __name__ == '__main__':
|
|||||||
timestamp=date_sent,
|
timestamp=date_sent,
|
||||||
recipients=recipients,
|
recipients=recipients,
|
||||||
attachments=attachments,
|
attachments=attachments,
|
||||||
meta={'subject': subject, 'effectId': effect_id}
|
meta={'subject': subject, 'effectId': effect_id,'isFromMe': isfromme}
|
||||||
)
|
)
|
||||||
persona_message = get_full_attachments(persona_message)
|
persona_message = get_full_attachments(persona_message)
|
||||||
responses = current_persona.receive_message(persona_message)
|
responses = current_persona.receive_message(persona_message)
|
||||||
|
@ -102,10 +102,14 @@ class Persona :
|
|||||||
def startup(self) :
|
def startup(self) :
|
||||||
"""Startup all message skill processors"""
|
"""Startup all message skill processors"""
|
||||||
for skill in self._skill_map.keys() :
|
for skill in self._skill_map.keys() :
|
||||||
|
try :
|
||||||
ClassInstance = self._skill_map[skill]
|
ClassInstance = self._skill_map[skill]
|
||||||
skillinstance = ClassInstance()
|
skillinstance = ClassInstance()
|
||||||
skillinstance.startup()
|
skillinstance.startup()
|
||||||
self.ready_skills.update({skill:skillinstance})
|
self.ready_skills.update({skill:skillinstance})
|
||||||
|
except Exception as e :
|
||||||
|
self.log.error(str(e))
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
def receive_message(self,message: Message) :
|
def receive_message(self,message: Message) :
|
||||||
|
2
setup.py
2
setup.py
@ -54,7 +54,7 @@ setup(name='bluebubbles_bot',
|
|||||||
description='A chatbot for a local BlueBlubbles server.',
|
description='A chatbot for a local BlueBlubbles server.',
|
||||||
packages=find_packages(exclude=['tests']),
|
packages=find_packages(exclude=['tests']),
|
||||||
package_data={"": ['skills/*.py']},
|
package_data={"": ['skills/*.py']},
|
||||||
install_requires=['pyyaml','datetime','requests','fastapi[all]'],
|
install_requires=['pyyaml','datetime','requests','fastapi[all]','openai'],
|
||||||
scripts=['bin/bluebubbles_bot'],
|
scripts=['bin/bluebubbles_bot'],
|
||||||
long_description=open('README.md').read(),
|
long_description=open('README.md').read(),
|
||||||
zip_safe=True
|
zip_safe=True
|
||||||
|
Loading…
Reference in New Issue
Block a user