This repository contains a sample project that demonstrates how to integrate FastAPI with ChatGPT, a powerful language model developed by OpenAI. With this project, you can create a simple web application that allows users to interact with ChatGPT through a RESTful API. The API's sole capability is to request travel recommendations from ChatGPT given a country and a season.
Before you begin, ensure you have the following installed on your system:
- Python 3.8+
- An OpenAI API key (Sign up at OpenAI and follow their API key setup instructions)
- Docker
-
Build the image:
docker build -t try-fastapi-chatgpt:latest .
-
Run a container based from the image:
docker run --rm -p 3000:3000 -e "OPENAI_API_KEY=sk-YOURSECRETKEY" try-fastapi-chatgpt:latest
-
Here are the links:
localhost:3000/
- just says hello...localhost:3000/docs
- shows the SwaggerUI (OpenAPI docs)localhost:3000/recommend
- endpoint for the travel recommender (see docs for more details)
-
Clone this repository to your local machine:
git clone https://github.com/pilosoposerio/try-fastapi-chatgpt.git cd try-fastapi-chatgpt
-
Create a Python virtual environment:
python3 -m venv .venv source .venv/bin/activate
-
Install the requirements:
pip install -r requirements.txt
-
Run the API via
uvicorn
uvicorn try_fastapi_chatgpt.application.api.fastapi:app --reload --port 3000