AI Chat Demo is a sample application designed to help you learn and reinforce your skills in real-time communication using SignalR and integrating OpenAI's ChatGPT within a .NET Core environment. The main goal of this project is to understand how to implement real-time communication with SignalR and how to integrate it with an AI service.
- .NET Core 8: The base framework used for building the API and Client projects.
- SignalR: Used for real-time communication between the client and server.
- OpenAI API: Integrated to enable AI-based responses using ChatGPT.
The project is divided into two main components:
- API: Handles SignalR connections and interacts with the AI service.
- Client: Provides the frontend interface for users to interact with the chat application.
- /chatHub: The main SignalR hub endpoint for real-time chat communication.
The ChatHub class in the API handles all real-time messaging between the client and the AI service. It:
- Accepts messages from the client, along with the user's ID and name.
- Sends these messages to OpenAI's ChatGPT via the
AIChatService. - Returns the AI's response back to the user in real-time.
- .NET Core 8 SDK
- PostgreSQL (or another used database)
-
Clone the repository:
git clone https://github.com/anilklc/AIChatDemo.git
-
Navigate to the project directory:
cd AIChatDemo -
Set up the API:
-
Navigate to the API project directory:
cd AIChatDemo.API -
Update the database connection string and other configurations in
appsettings.json. -
Apply migrations and create the database:
dotnet ef database update
-
Run the API application:
dotnet run
-
-
Set up the Client:
-
Navigate to the Client project directory:
cd ../AIChatDemo.Client -
Run the Client application:
dotnet run
-
Shows an error alert for incomplete form submission on the registration page.
Displays a success alert for correct and complete form submission, followed by redirection to the login page.
Demonstrates an attempt to access the chat page without logging in, leading to redirection to the login page.
Shows successful access to the chat page after logging in.
Shows individual conversations between two users and AI on different browsers.
This project is licensed under the MIT License.