I am pleased to announce that my project for automated deployment of LibreChat on AWS EC2 has been updated to fix issues related to recent changes in how LibreChat is installed, while now supporting version v0.7.6. This update also includes the ability to choose between On-Demand and Spot instances, as well as improvements to simplify usage, even for beginners.

What’s new in this update?

Support for LibreChat version v0.7.6

The project now directly clones the v0.7.6 tag of LibreChat, ensuring that all deployments use a validated and tested version. This avoids surprises related to unexpected changes in the main repository.

Updated code in the User-Data script:

# Clone le dépôt LibreChat avec uniquement le tag v0.7.6
git clone --branch v0.7.6 --depth 1 https://github.com/danny-avila/LibreChat.git
cd LibreChat/

Management of On-Demand and Spot instances

I have added a spot_enabled variable in Terraform that allows you to dynamically choose whether the deployment uses Spot or On-Demand instances. By default, the On-Demand mode is activated to offer a more accessible experience for beginners, avoiding the need to configure spot prices. This ensures that the project is immediately functional for everyone.

Updated excerpt from ec2.tf:

# Bloc dynamique pour conditionner les options du marché Spot
dynamic "instance_market_options" {
  for_each = var.spot_enabled ? [1] : [] # Si spot_enabled est true, le bloc est créé
  content {
    market_type = "spot"
    spot_options {
      max_price                      = var.spot_max_price[var.instance_type]
      instance_interruption_behavior = var.spot_request_type == "persistent" ? "stop" : null
      spot_instance_type             = var.spot_request_type
    }
  }
}

Excerpt from variables.tf:

variable "spot_enabled" {
  description = "Active ou désactive l'utilisation du marché Spot"
  type        = bool
  default     = false
}

Update of Terraform version

The version of Terraform used in the project has been updated from 1.5.7 to 1.10.3. This ensures compatibility with the latest features and improvements of Terraform.

# Version de l'image Docker Terraform
TERRAFORM_VERSION: hashicorp/terraform:1.10.3

Fixes for Mistral model configuration

The configuration of Mistral in librechat.yaml has been updated to support format changes in the latest version. The API key is still retrieved from AWS Systems Manager (SSM), just like for other models, and the default models now include mistral-large-latest.

Updated code:

# Remplace la ligne contenant apiKey: '${MISTRAL_API_KEY}' par la clé réelle dans librechat.yaml
sed -i "s|apiKey: '\${MISTRAL_API_KEY}'|apiKey: '${MISTRAL_API_KEY}'|" librechat.yaml

# Modèles par défaut pour Mistral
sed -i '/- name:.*Mistral/,/default:/ s|default:.*|default: [\'mistral-tiny\', \'mistral-small\', \'mistral-medium\', \'mistral-large-latest\']|' librechat.yaml

Addition of multilingual README files

To make the project accessible to a larger number of users around the world, I used my AI-powered Markdown file translation script, powered by the GPT-4o model, to generate README files in multiple languages. Supported languages include English, German, Spanish, Japanese, Korean, and Chinese.

Files added:

  • README-de-gpt-4o.md
  • README-en-gpt-4o.md
  • README-es-gpt-4o.md
  • README-ja-gpt-4o.md
  • README-ko-gpt-4o.md
  • README-zh-gpt-4o.md

Update of Nginx configuration

The Nginx configuration for SSL, provided by default, was deprecated in this version. I fixed this by adapting the directives and adding support for SSL certificates with sed commands to ensure compatibility.

Updated code:

# Monter les certificats SSL dans le fichier deploy-compose.yml
sed -i '/- .\/client\/nginx.conf:\/etc\/nginx\/conf.d\/default.conf/a \      - \/etc\/nginx\/ssl:\/etc\/nginx\/ssl' deploy-compose.yml

# Corrige les directives dans nginx.conf pour la version récente de Nginx
sed -i '/listen 443 ssl;/!s/listen 443 ssl;/listen 443 ssl http2;/' client/nginx.conf
sed -i '/listen \[::\]:443 ssl;/!s/listen \[::\]:443 ssl;/listen [::]:443 ssl http2;/' client/nginx.conf

# Corriger les erreurs de commentaire sur les URLs
sed -i 's|https://docs.nginx.com/nginx/admin-guide/web-server/compression/|# https://docs.nginx.com/nginx/admin-guide/web-server/compression/|' client/nginx.conf
sed -i 's|https://docs.nginx.com/nginx/admin-guide/web-server/compression/|# &|' client/nginx.conf

Terraform improvements

  • Changed the default instance type from t3a.micro to t3a.small for better performance.
  • Updated spot prices in variables.tf to reflect current costs.

Updated excerpt from variables.tf:

variable "spot_max_price" {
  default = {
    "t3a.large"  = "0.0376"
    "t3a.small"  = "0.0095"
    "t3a.medium" = "0.01940"
    "t3a.micro"  = "0.006"
  }
}

Why this update is important

By fixing the version of LibreChat, correcting issues related to Nginx and Mistral configurations, and offering the ability to choose between On-Demand and Spot instances, this update enhances the reliability and flexibility of the project. With On-Demand mode by default, even beginners can deploy LibreChat without complex prerequisites.

Summary

  • Support for LibreChat version v0.7.6: Cloning the correct tag to avoid issues related to uncontrolled changes.
  • Instance management: Choice between On-Demand and Spot, with On-Demand by default to simplify the user experience.
  • Terraform version: Updated to version 1.10.3 to take advantage of the latest improvements.
  • Mistral AI: Automatic management of API keys and models, adapted to the new format.
  • Multilingual READMEs: Documentation accessible in multiple languages.
  • Nginx: SSL configuration fixed and adapted to new directives.
  • Terraform: Adjustments for improved performance and accurate costs.

Discover the complete project

You can consult and use this project on the GitLab repository.

Feel free to share your feedback or contribute to the project!

This document has been translated from the French version to the English language using the o1-preview model. For more information on the translation process, see https://gitlab.com/jls42/ai-powered-markdown-translator