ChatGPT-Clone Svelte Themes

Chatgpt Clone

ChatGPT clone project based on full-stack-fastapi-template

ChatGPT Clone Project

μ–Έμ–΄ 선택 / Language Selection:

Technology Stack and Features

  • ⚑ FastAPI for the Python backend API.
    • 🧰 SQLAlchemy for the Python SQL database interactions (ORM).
    • πŸ” Pydantic used by FastAPI, for the data validation and settings management.
    • πŸ’Ύ PostgreSQL as the SQL database.
    • πŸ“ Adminer as the Database Management System
    • πŸ€– Ollama as the local hosting server for LLM(EEVE-Korean)
    • ⛓️ LangChain to build LLM chat bot
  • πŸš€ Svelte for the frontend
  • πŸ‹ Docker Compose for development and production.
  • πŸ”’ Secure password hashing by default.
  • πŸ”‘ JWT (JSON Web Token) authentication.
  • πŸ“« Email based password recovery.
  • βœ… Tests with Pytest.
  • πŸ“ž Traefik as a reverse proxy / load balancer.
  • 🚒 Deployment instructions using Docker Compose, including how to set up a frontend Traefik proxy to handle automatic HTTPS certificates.

Dashboard Login

Dashboard password recovery

Dashboard Chat

How to use it

Infra

I developed this project using the GPU cloud service(paperspace)

  • OS: Ubuntu 22.04
  • GPU: Quadro RTX4000(8192MiB)
    • It could be difficult to use RAG because of out of memory in GPU.
  • CUDA version: 12.6

.env file setting

please make the .env file in the root folder

PROJECT_NAME="ChatGPT Clone Project"
STACK_NAME="ChatGPT-Clone-Project"
DOMAIN=localhost

# backend url
VITE_SERVER_URL=http://127.0.0.1:8000

# frontend url
BACKEND_CORS_ORIGINS="http://localhost,http://localhost:5173,http://127.0.0.1:5173,https://localhost,https://localhost:5173,https://127.0.0.1:5173"
DOMAIN_PORT="5173"

USE_HASH_ROUTER = "True"
ACCESS_TOKEN_EXPIRE_MINUTES = 60

# secret key and algorithm for auth
SECRET_KEY =
ALGORITHM =

SMTP_HOST = "smtp.gmail.com"
SMTP_PORT = 587
SMTP_USERNAME =
SMTP_PASSWORD =
EMAILS_FROM_EMAIL = "[email protected]"
EMAILS_FROM_NAME = "ChatGPT Clone Project Information"

# Postgres
POSTGRES_SERVER=localhost
POSTGRES_PORT=5432
POSTGRES_DB=app
POSTGRES_USER=postgres
POSTGRES_PASSWORD=changethis

# langsmith
LANGCHAIN_TRACING_V2 = 'true'
LANGCHAIN_API_KEY =
  • PROJECT_NAME: The name of the project
  • STACK_NAME: The name of the stack used for Docker Compose labels and project name (no spaces, no periods) (in .env).
  • SECRET_KEY: The secret key for the project, used for security, stored in .env.
  • SMTP_USERNAME: The SMTP server user to send emails.
  • SMTP_PASSWORD: The SMTP server password to send emails.
  • LANGCHAIN_TRACING_V2: Where to use Langsmith to tracing AI chat bot's response in detail.
  • LANGCHAIN_API_KEY: API Key to tracing AI chat bot's response in Langsmith.

Execute Containers using docker compsoe

sudo docker-compose up

it will make the containeres

  • reverse proxy(Traefik)
  • Database(PostgreSQL)
  • backend(FastAPI)
  • frontend(Svelte)
  • Database Management System(Adminer)

for example)

[+] Building 0.0s (0/0)                                                                                                                                                               docker:default
[+] Running 5/0
 βœ” Container chatgpt-clone-proxy-1    Created                                                                                                                                                   0.0s
 βœ” Container chatgpt-clone-db-1       Created                                                                                                                                                   0.0s
 βœ” Container backend                  Created                                                                                                                                                   0.0s
 βœ” Container frontend                 Created                                                                                                                                                   0.0s
 βœ” Container chatgpt-clone-adminer-1  Created                                                                                                                                                   0.0s
Attaching to backend, chatgpt-clone-adminer-1, chatgpt-clone-db-1, chatgpt-clone-proxy-1, frontend

Backend Development

Backend docs: backend/readme.md

Development

General development docs: development.md.

This includes using Docker Compose, pre-commit, .env configurations, etc.

Acknowledgements

This repository is built upon full-stack-fastapi-template. If you want to use FastAPI, that will be good reference or starting point.

@online{full-stack-fastapi-template,
  author    = {fastapi},
  title     = {full-stack-fastapi-template},
  url       = {https://github.com/fastapi/full-stack-fastapi-template},
  year      = {2024},
}

Top categories

Loading Svelte Themes