polakowo / gpt2bot

Your new Telegram buddy powered by transformers
MIT License
429 stars 107 forks source link

Flask/Gunicorn server api #9

Open ghost opened 4 years ago

ghost commented 4 years ago

Hi,

Hope you are all well !

I would like to setup a flask server with a query endpoint for processing a message. Is it possible to push an example of gpt2bot with a flask server or gunicorn ?

In fact, I am writing a multi bot project (written in Golang) and I d like to aggregate response of several type of chatbots with an agent. The projet reference is there: https://github.com/paper2code/telegram-multibot

As I am much more a gopher than a pythonista, I am requesting your kind help on that. ^^

Can you help me on that ?

Cheers, X

polakowo commented 4 years ago

You need to adapt interactive_bot.py by creating a route around the following lines https://github.com/polakowo/gpt2bot/blob/a091b7ec7b350819ca5cf3efa5675ed420890fc8/gpt2bot/interactive_bot.py#L35-L66

Having query prompt it will generate a bot message bot_message that you can send back to the user.

To create a Flask app for text generation you can look at my other project textai, for example this app. I'm currently preparing a new release of gpt2bot, so maybe after I finished that I will consider creating a Flask version.

ghost commented 4 years ago

Awesome mate :-)

When do you think you gonna release it ?

For the flask server, we managed to create one so no hurries ^^ https://github.com/paper2code/gpt2bot/blob/master/server.py

Cheers, X

polakowo commented 4 years ago

Looks good. You would also need some sort of session management and ideally a route for updating the parameters of the generator such as temperature, no need to restart the server to update the config.

I will release it the next week I guess, I'm trying to decouple it from dialogpt and generalize it to accept any gpt2 model.

ghost commented 4 years ago

Hi @polakowo

I tried to create a new flask server from your latest changes with no luck...

Do you mind to create it ? That would be so awesome and kind of you :-)

Cheers, X