![Server Sent Events in Laravel and OpenAI API](https://private-user-images.githubusercontent.com/1163421/262355407-5e14721f-7d33-4673-bcc3-e97644811391.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjM5NjI3ODMsIm5iZiI6MTcyMzk2MjQ4MywicGF0aCI6Ii8xMTYzNDIxLzI2MjM1NTQwNy01ZTE0NzIxZi03ZDMzLTQ2NzMtYmNjMy1lOTc2NDQ4MTEzOTEucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgxOCUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MThUMDYyODAzWiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9NmY1ZWEzN2NkYjU1NDQ3OWJjNzUzNjY1Njc1Njk5NWRmZmMwNmU1NmFmM2ZmMDYyNjQxODU1ZTc4MzEyMmZlYiZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.l9obix44-xYsela5ik5fpHRUhwBQuCQkuWe_geMOplM)
This repository showcases the utilization of server-sent events within a Laravel application, emphasizing the seamless integration of the OpenAI API for real-time chat streaming.
The focal point of this project is the development of a streamlined chat interface, harmonizing the dynamic interaction between users and the OpenAI API through the utilization of server-sent events. The application's core functionality revolves around users posing inquiries, to which OpenAI furnishes responses. This exchange of information is achieved through the continuous streaming of responses, employing the server-sent events capability.
To experience this application firsthand on your local machine, you can follow these steps:
-
Clone Repository: Begin by cloning this repository to your local environment.
-
Install Dependencies: Utilize the
composer
package manager to install all essential PHP dependencies. -
Local Environment Setup: With the aid of Laravel Sail, this application can be readily set up and executed locally. Ensure that Docker is installed on your system. Then, proceed with the subsequent commands:
sail up -d sail npm install sail npm run dev
It's important to note that this application exclusively serves as a demonstration, thereby rendering it unsuitable for deployment in a production environment.
Should you be interested in further exploring similar projects for potential production applications, feel free to get in touch with me at: bhaidar@gmail.com.
We hope you find this demonstration both informative and insightful. Thank you for your interest and exploration!