Info: | See OpenAI site for the latest source. |
---|---|
Documentation: | Available at ChatGPT |
Author: | Amit Das |
This code provides an API endpoint that generates text based on prompts given by users, using the pre-trained GPT2 language model from the transformers library.
You can install the dependencies using the following command:
pip install -r requirements.txt
To start the server, simply run the following command:
python3 app.py
This will start the server on http://localhost:8000.
The API has a single endpoint /generate which accepts a POST request with a JSON payload containing the prompt string to generate text from. The generated text is then returned in the response.
POST /generate HTTP/1.1
Host: localhost:8000
Content-Type: application/json
{
"prompt": "The quick brown fox"
}
HTTP/1.1 200 OK
Content-Type: text/plain
jumps over the lazy dog.