This project demonstrates how to create a real-time conversational AI by streaming responses from OpenAI's GPT-3.5-turbo model. It uses FastAPI to create a web server that accepts user inputs and streams generated responses back to the user.
- Clone the repository.
- Install Python (Python 3.7+ is recommended).
- Install necessary libraries. This project uses FastAPI, uvicorn, LangChain, among others. You can install them with pip:
pip install fastapi uvicorn langchain
. - Add your OpenAI API key to the
.env
file. - Start the FastAPI server by running
uvicorn main:app
in the terminal. - Access the application by opening your web browser and navigating to
localhost:8000
.
Note: Ensure the appropriate CORS settings if you're not serving the frontend and the API from the same origin.
The project uses an HTML interface for user input. The user's input is sent to a FastAPI server, which forwards it to the GPT-3.5-turbo model. The generated response is streamed back to the user, simulating a real-time conversation.