-
Notifications
You must be signed in to change notification settings - Fork 2.3k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Messenger Llama2 Chatbot Tutorial #311
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Great example, left some inline comments
@@ -0,0 +1,192 @@ | |||
# Building a Llama-enabled Messenger Chatbot | |||
|
|||
This step-by-step tutorial shows the complete process of building a Llama-enabled Messenger chatbot. A demo video of using the iOS Messenger app to send a question to a Facebook business page and receive the Llama 2 generated answer is [here](https://drive.google.com/file/d/1B4ijFH4X3jEHZfkGdTPmdsgpUes_RNud/view). |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is google drive the best way to share this video?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It's the easiest for me and I've been using gdrive mainly. Any suggestion on a better way?
|
||
## Modifying the Webhook | ||
|
||
Open your glitch.com webhook URL created earlier, and change your `app.js` to simply forward the user message and the user and page ids sent by the Messenger Platform to the Llama 2 enabled web app `llama_messenger.py` described in the previous section: |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What is the purpose of the web hook needed if it just forwards the message? Can the messenger platform not be used to send the message directly to the web app?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ideally the webhook should do what the web app does, or the other way around. But I haven't simplified this yet, and am just using the WhatsApp/Messenger doc to set up a JS based webhook, which then calls the Python web app to invoke Llama. I did mention this in https://github.com/facebookresearch/llama-recipes/blob/main/demo_apps/whatsapp_llama2.md:
Note: It's possible and even recommended to implement a webhook in Python and call the Llama directly inside the webhook, instead of making an HTTP request, as the JavaScript code above does, to a Python app which calls Llama and sends the answer to WhatsApp.
I'll try to improve this in a future PR update?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I mean, making the call without the intermediate stage of the webhook will make your system less complex and when its recommended it probably the way to go. You think its a lot of work?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Agreed in general but in this case (and the WhatsApp Llama2 tutorial too) the JS based Glitch is the recommended webhook provider - I'd need to port it to Python and test with the webhook configuration in the API setting which would take at least half a day, so will leave it for a future update.
gunicorn -b 0.0.0.0:5000 llama_messenger:app | ||
``` | ||
|
||
If you use Amazon EC2 as your web server, make sure you have port 5000 added to your EC2 instance's security group's inbound rules. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can the scope of access be narrowed to improve security? ip range or similar? Is there a tutorial we can reference for this?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
i'm not sure but added the Gunicorn doc.
@mreso thanks for the great review! i addressed all your comments and made some code and doc changes. please see if it looks good now. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks for addressing the comments, LGTM
What does this PR do?
This step-by-step tutorial shows the complete process of building a Llama-enabled Messenger chatbot. A demo video of using the iOS Messenger app to send a question to a Facebook page and receive the Llama 2 generated answer is here.
Fixes # (issue)
Feature/Issue validation/testing
Please describe the tests that you ran to verify your changes and relevant result summary. Provide instructions so it can be reproduced.
Please also list any relevant details for your test configuration.
Test A
Logs for Test A
Test B
Logs for Test B
Before submitting
Pull Request section?
to it if that's the case.
Thanks for contributing 🎉!