mirror of
https://github.com/danny-avila/LibreChat.git
synced 2025-12-16 16:30:15 +01:00
🐳 experimental: Dev Image Workflow & Remove Unused Code (#1928)
* chore: remove unused code in progressCallback, as well as handle reply.trim(), post `getCompletion` * chore(Dockerfile): remove curl installation * experimental: dev image parallelized with matrix strategy and building for amd64/arm64 support * make platforms explicit
This commit is contained in:
parent
388dc1789b
commit
93803323cf
4 changed files with 33 additions and 58 deletions
62
.github/workflows/dev-images.yml
vendored
62
.github/workflows/dev-images.yml
vendored
|
|
@ -13,14 +13,27 @@ on:
|
||||||
jobs:
|
jobs:
|
||||||
build:
|
build:
|
||||||
runs-on: ubuntu-latest
|
runs-on: ubuntu-latest
|
||||||
|
strategy:
|
||||||
|
matrix:
|
||||||
|
include:
|
||||||
|
- target: api-build
|
||||||
|
file: Dockerfile.multi
|
||||||
|
image_name: librechat-dev-api
|
||||||
|
- target: node
|
||||||
|
file: Dockerfile
|
||||||
|
image_name: librechat-dev
|
||||||
|
|
||||||
steps:
|
steps:
|
||||||
# Check out the repository
|
# Check out the repository
|
||||||
- name: Checkout
|
- name: Checkout
|
||||||
uses: actions/checkout@v4
|
uses: actions/checkout@v4
|
||||||
|
|
||||||
# Set up Docker
|
# Set up QEMU
|
||||||
- name: Set up Docker
|
- name: Set up QEMU
|
||||||
|
uses: docker/setup-qemu-action@v3
|
||||||
|
|
||||||
|
# Set up Docker Buildx
|
||||||
|
- name: Set up Docker Buildx
|
||||||
uses: docker/setup-buildx-action@v3
|
uses: docker/setup-buildx-action@v3
|
||||||
|
|
||||||
# Log in to GitHub Container Registry
|
# Log in to GitHub Container Registry
|
||||||
|
|
@ -38,35 +51,22 @@ jobs:
|
||||||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||||
|
|
||||||
# Build Docker images
|
# Prepare the environment
|
||||||
- name: Build Docker images
|
- name: Prepare environment
|
||||||
run: |
|
run: |
|
||||||
cp .env.example .env
|
cp .env.example .env
|
||||||
docker build -f Dockerfile.multi --target api-build -t librechat-dev-api .
|
|
||||||
docker build -f Dockerfile -t librechat-dev .
|
|
||||||
|
|
||||||
# Tag and push the images to GitHub Container Registry
|
# Build and push Docker images for each target
|
||||||
- name: Tag and push images to GHCR
|
- name: Build and push Docker images
|
||||||
run: |
|
uses: docker/build-push-action@v5
|
||||||
docker tag librechat-dev-api:latest ghcr.io/${{ github.repository_owner }}/librechat-dev-api:${{ github.sha }}
|
with:
|
||||||
docker push ghcr.io/${{ github.repository_owner }}/librechat-dev-api:${{ github.sha }}
|
context: .
|
||||||
docker tag librechat-dev-api:latest ghcr.io/${{ github.repository_owner }}/librechat-dev-api:latest
|
file: ${{ matrix.file }}
|
||||||
docker push ghcr.io/${{ github.repository_owner }}/librechat-dev-api:latest
|
push: true
|
||||||
|
tags: |
|
||||||
docker tag librechat-dev:latest ghcr.io/${{ github.repository_owner }}/librechat-dev:${{ github.sha }}
|
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:${{ github.sha }}
|
||||||
docker push ghcr.io/${{ github.repository_owner }}/librechat-dev:${{ github.sha }}
|
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:latest
|
||||||
docker tag librechat-dev:latest ghcr.io/${{ github.repository_owner }}/librechat-dev:latest
|
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image_name }}:${{ github.sha }}
|
||||||
docker push ghcr.io/${{ github.repository_owner }}/librechat-dev:latest
|
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image_name }}:latest
|
||||||
|
platforms: linux/amd64,linux/arm64
|
||||||
# Tag and push the images to Docker Hub
|
target: ${{ matrix.target }}
|
||||||
- name: Tag and push images to Docker Hub
|
|
||||||
run: |
|
|
||||||
docker tag librechat-dev-api:latest ${{ secrets.DOCKERHUB_USERNAME }}/librechat-dev-api:${{ github.sha }}
|
|
||||||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/librechat-dev-api:${{ github.sha }}
|
|
||||||
docker tag librechat-dev-api:latest ${{ secrets.DOCKERHUB_USERNAME }}/librechat-dev-api:latest
|
|
||||||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/librechat-dev-api:latest
|
|
||||||
|
|
||||||
docker tag librechat-dev:latest ${{ secrets.DOCKERHUB_USERNAME }}/librechat-dev:${{ github.sha }}
|
|
||||||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/librechat-dev:${{ github.sha }}
|
|
||||||
docker tag librechat-dev:latest ${{ secrets.DOCKERHUB_USERNAME }}/librechat-dev:latest
|
|
||||||
docker push ${{ secrets.DOCKERHUB_USERNAME }}/librechat-dev:latest
|
|
||||||
|
|
|
||||||
|
|
@ -7,9 +7,7 @@ WORKDIR /app
|
||||||
# Allow mounting of these files, which have no default
|
# Allow mounting of these files, which have no default
|
||||||
# values.
|
# values.
|
||||||
RUN touch .env
|
RUN touch .env
|
||||||
# Install call deps - Install curl for health check
|
RUN npm ci
|
||||||
RUN apk --no-cache add curl && \
|
|
||||||
npm ci
|
|
||||||
|
|
||||||
# React client build
|
# React client build
|
||||||
ENV NODE_OPTIONS="--max-old-space-size=2048"
|
ENV NODE_OPTIONS="--max-old-space-size=2048"
|
||||||
|
|
|
||||||
|
|
@ -624,7 +624,7 @@ class OpenAIClient extends BaseClient {
|
||||||
const { finish_reason } = streamResult.choices[0];
|
const { finish_reason } = streamResult.choices[0];
|
||||||
opts.addMetadata({ finish_reason });
|
opts.addMetadata({ finish_reason });
|
||||||
}
|
}
|
||||||
return reply.trim();
|
return (reply ?? '').trim();
|
||||||
}
|
}
|
||||||
|
|
||||||
initializeLLM({
|
initializeLLM({
|
||||||
|
|
|
||||||
|
|
@ -7,36 +7,13 @@ const addSpaceIfNeeded = (text) => (text.length > 0 && !text.endsWith(' ') ? tex
|
||||||
|
|
||||||
const createOnProgress = ({ generation = '', onProgress: _onProgress }) => {
|
const createOnProgress = ({ generation = '', onProgress: _onProgress }) => {
|
||||||
let i = 0;
|
let i = 0;
|
||||||
let code = '';
|
|
||||||
let precode = '';
|
|
||||||
let codeBlock = false;
|
|
||||||
let tokens = addSpaceIfNeeded(generation);
|
let tokens = addSpaceIfNeeded(generation);
|
||||||
|
|
||||||
const progressCallback = async (partial, { res, text, bing = false, ...rest }) => {
|
const progressCallback = async (partial, { res, text, bing = false, ...rest }) => {
|
||||||
let chunk = partial === text ? '' : partial;
|
let chunk = partial === text ? '' : partial;
|
||||||
tokens += chunk;
|
tokens += chunk;
|
||||||
precode += chunk;
|
|
||||||
tokens = tokens.replaceAll('[DONE]', '');
|
tokens = tokens.replaceAll('[DONE]', '');
|
||||||
|
|
||||||
if (codeBlock) {
|
|
||||||
code += chunk;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (precode.includes('```') && codeBlock) {
|
|
||||||
codeBlock = false;
|
|
||||||
precode = precode.replace(/```/g, '');
|
|
||||||
code = '';
|
|
||||||
}
|
|
||||||
|
|
||||||
if (precode.includes('```') && code === '') {
|
|
||||||
precode = precode.replace(/```/g, '');
|
|
||||||
codeBlock = true;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (tokens.match(/^\n(?!:::plugins:::)/)) {
|
|
||||||
tokens = tokens.replace(/^\n/, '');
|
|
||||||
}
|
|
||||||
|
|
||||||
if (bing) {
|
if (bing) {
|
||||||
tokens = citeText(tokens, true);
|
tokens = citeText(tokens, true);
|
||||||
}
|
}
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue