Skip to content
This repository has been archived by the owner on Jun 27, 2024. It is now read-only.

Full stack application built with ASP.NET Core 8 and Next.js with TypeScript and TailwindCSS. The application is a chat bot powered by PaLM 2.

License

Notifications You must be signed in to change notification settings

RianNegreiros/DotNetChatBot

Repository files navigation

Docker Compose CI

Table of Contents

  1. Introduction
  2. Getting Started
  3. Usage
  4. Extensions
  5. Rate Limiting
  6. Built With
  7. Contact
  8. License

Chat Bot Application

This is a full stack application built with ASP.NET Core 8 and Next.js with TypeScript and TailwindCSS. The application is a chat bot powered by PaLM 2.

GIF to showcase the Chat Bot

Article Reference

This application is part of the blog post titled "Creating a Chatbot with ASP.NET Core, Next.js and PaLM API". Feel free to read the article for a more detailed explanation of the application.

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes.

Prerequisites

Installing

  1. Clone the repository
 git clone https://github.com/RianNegreiros/DotNetChatBot.git
  1. Setup the server configuration
 cd src/API
 cp appsettings.json.example appsettings.json

Then set the LANGUAGE_MODEL:API_KEY with your PaLM API key or get one here

  1. Setup the client configuration
 cd src/client
 cp .env.example .env
  1. Restore the .NET packages and run the ASP.NET API
 dotnet restore
 dotnet run --project src/API
  1. Navigate to the client directory, install the dependencies and run the client
 cd src/client
 npm install
 npm run dev

Running with Docker Compose

If you have Docker Compose installed, you can use it to run the application:

  1. Setup the server configuration
 cd src/API
 cp appsettings.json.example appsettings.json

Then set the LANGUAGE_MODEL:API_KEY with your PaLM API key or get one here

  1. Setup the client configuration
 cd src/client
 cp .env.example .env
  1. Run the Docker compose
docker compose up --build

The application should now be running at http://localhost:3000.

Usage

API

The API has the following endpoints:

  • /prompt/{text}: This endpoint generates a language model response from the PaLM API. The {text} parameter is the text to be processed by the language model. The endpoint returns a JSON response with the generated message.

  • /health: This endpoint checks the health of the application and its connection to the Google API.

The API also includes Swagger UI for testing and documenting the API endpoints. You can access it at /swagger.

Extensions

The project includes the following extensions:

  • AddSwaggerExtension: This extension adds Swagger/OpenAPI support to the project.

  • AddCorsExtension: This extension adds CORS policy to the project. By default, it allows POST requests from http://localhost:3000.

  • AddHealthChecksExtension: This extension adds health checks to the project. It includes a custom health check for the Google API.

  • AddServicesExtension: This extension adds an HTTP client to the project.

Rate Limiting

The project uses rate limiting to limit the number of requests from a single IP address. The limit is set to 10 requests per 10 seconds. If the limit is exceeded, the API will return a 429 Too Many Requests status code.

Client

The client has a chat interface where you can interact with the chat bot. The chat interface is rendered by the Chat component. The Chat component uses the useChat hook to manage the state of the chat.

The useChat hook uses the axios library to send POST requests to the chat bot API. The responses from the API are stored in the messages state variable. The messages state variable is also stored in the session storage to persist the chat history across page reloads.

The Chat component also uses the Loading component to display a loading animation while waiting for the response from the API, and the DangerError component to display any error messages.

Built With

Contact

Website: riannegreiros.dev

License

This project is licensed under the MIT License - see the LICENSE file for details

About

Full stack application built with ASP.NET Core 8 and Next.js with TypeScript and TailwindCSS. The application is a chat bot powered by PaLM 2.

Topics

Resources

License

Stars

Watchers

Forks