This project demonstrates how to utilize Langchain and FastAPI to stream GPT-generated text in real-time, serving it to a dynamic JavaScript frontend.
- Real-time Streaming: Stream GPT-generated text in real-time.
- FastAPI Backend: Powered by FastAPI for high-performance asynchronous processing.
- JavaScript Frontend: Dynamic frontend to display streamed text.
- Python 3.8+
- Git
- Virtualenv
git clone https://github.com/ehsanahmadkhan525/langchain-fastapi-streaming.git
cd langchain-fastapi-streaming
Create a virtual environment to manage dependencies:
python3 -m venv venv
Activate the virtual environment:
-
On Windows:
venv\Scripts\activate
-
On macOS/Linux:
source venv/bin/activate
Install the required Python packages:
pip install -r requirements.txt
Start the FastAPI server by running:
python3 app.py
This will start the server on https://localhost:8000
.
Open your web browser and navigate to https://localhost:8000
to access the application.
Feel free to submit issues or pull requests if you would like to contribute to the project.
This project is licensed under the MIT License. See the LICENSE file for details.
Enjoy streaming with Langchain and FastAPI!