-
Notifications
You must be signed in to change notification settings - Fork 2.1k
Conversation
Added folder with name flask_api_dome and added code to implement parlai model with flask framework and readme file in the same folder. Also added URL to flask API folder on main README.md file.
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.
This is great! Thanks so much for adding!
I don't love it as a top level directory though. Some options:
- Since this is mostly just an example that fits in a README, we could move it into the docs (just rename the README.md to docs/source/tutorial_flask.md and add tutorial_flask in tutorial.md)
- Move all the documentation inline into the script, and move the script into the
scripts
folder. Add the relevant templates so that the docs generate it.
What do you think?
Some options:
- Move it to scripts
Thank you so much for the response @stephenroller , I have done the necessary changes as per your suggestions. Please review It. |
Added flask on requirements.txt file
@stephenroller can you help me what I'm doing wrong here? |
Thanks @khushaljethava for adding this. Please make sure that your added scripts are consistent with the scripts that we have in the script folder. This is a short script to follow as a good example. Note the extension of |
docs/source/tutorial_flask.md
Outdated
__Authors__: Khushal Jethava | ||
|
||
|
||
### Parl.ai model implement on flask framework |
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.
nit: it is better to use as ParlAI instead of Parl.ai.
|
||
Just change the model path and model name inside the create_agent_from_model_file function. | ||
|
||
```python |
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.
Please change this to be a parameter set while running the script. Add that in your setup_args
implementation. The default can be the zoo model.
requirements.txt
Outdated
@@ -1,3 +1,4 @@ | |||
flask |
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 it possible to avoid installing an extra web server? We already use Tornado web server, could you redo this in Tornado to make our ParlAI installation leaner? Thanks!
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.
@mojtaba-komeili Thank you for the guidance, I have created a tornado script with Parlai setup_args but not help with the result still trying to improve it, I'll get back to you once it will be completed and any idea about the flask solution? @stephenroller
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.
Flask is fine by me, and we don't need this imported for parlai flask_demo
, at least not 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.
looks like you got the right setup, and I'm fine with flask -- it's good for tutorial purposes. I suspect the website build is broken because of the global model import.
requirements.txt
Outdated
@@ -1,3 +1,4 @@ | |||
flask |
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.
Flask is fine by me, and we don't need this imported for parlai flask_demo
, at least not now.
app = Flask(__name__) | ||
|
||
#import model from the model file can be pretrained or fine tuned | ||
blender_agent = create_agent_from_model_file("zoo:blender/blender_90M/model") |
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 you move this initialization into main
somehow, so that the website builder doesn't do this?
parlai/scripts/flask_demo.py
Outdated
# the associated function. | ||
@app.route("/response", methods=["GET","POST"]) # API URL | ||
def chatbot_response(): # function name | ||
data = request.json # Take input as json format |
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.
nit: you'll need to format all the comments
docs/source/tutorial_flask.md
Outdated
Just change the model path and model name inside the create_agent_from_model_file function. | ||
|
||
```python | ||
blender_agent = create_agent_from_model_file("Model Name") |
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.
blender_agent = create_agent_from_model_file("Model Name") | |
blender_agent = create_agent_from_model_file("path_to_model_or_zoo_name") | |
Im not getting what im doing wrong here? @stephenroller |
lint again
lol keep linting
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.
Looks perfect
Yup, this is all good. I got pulled away to try to fix the tests in another PR. |
Completed in #4433. |
Patch description
Many people in the community were asking for the Parlai implementation on the flask framework. So I have created a script to run parlai models on the Flask framework and make flask API for the parlai model.
Testing steps
Other information
I haven't changed or modified any code related to the pariai I have just added two files one with flask code and one readme file for the same. also, I have added path the flask API code in the main README.me file.