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:
|
||||
build:
|
||||
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:
|
||||
# Check out the repository
|
||||
- name: Checkout
|
||||
uses: actions/checkout@v4
|
||||
|
||||
# Set up Docker
|
||||
- name: Set up Docker
|
||||
# Set up QEMU
|
||||
- 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
|
||||
|
||||
# Log in to GitHub Container Registry
|
||||
|
|
@ -38,35 +51,22 @@ jobs:
|
|||
username: ${{ secrets.DOCKERHUB_USERNAME }}
|
||||
password: ${{ secrets.DOCKERHUB_TOKEN }}
|
||||
|
||||
# Build Docker images
|
||||
- name: Build Docker images
|
||||
# Prepare the environment
|
||||
- name: Prepare environment
|
||||
run: |
|
||||
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
|
||||
- name: Tag and push images to GHCR
|
||||
run: |
|
||||
docker tag librechat-dev-api:latest ghcr.io/${{ github.repository_owner }}/librechat-dev-api:${{ github.sha }}
|
||||
docker push ghcr.io/${{ github.repository_owner }}/librechat-dev-api:${{ github.sha }}
|
||||
docker tag librechat-dev-api:latest ghcr.io/${{ github.repository_owner }}/librechat-dev-api:latest
|
||||
docker push ghcr.io/${{ github.repository_owner }}/librechat-dev-api:latest
|
||||
|
||||
docker tag librechat-dev:latest ghcr.io/${{ github.repository_owner }}/librechat-dev:${{ github.sha }}
|
||||
docker push ghcr.io/${{ github.repository_owner }}/librechat-dev:${{ github.sha }}
|
||||
docker tag librechat-dev:latest ghcr.io/${{ github.repository_owner }}/librechat-dev:latest
|
||||
docker push ghcr.io/${{ github.repository_owner }}/librechat-dev:latest
|
||||
|
||||
# Tag and push the images to Docker Hub
|
||||
- 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
|
||||
# Build and push Docker images for each target
|
||||
- name: Build and push Docker images
|
||||
uses: docker/build-push-action@v5
|
||||
with:
|
||||
context: .
|
||||
file: ${{ matrix.file }}
|
||||
push: true
|
||||
tags: |
|
||||
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:${{ github.sha }}
|
||||
ghcr.io/${{ github.repository_owner }}/${{ matrix.image_name }}:latest
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image_name }}:${{ github.sha }}
|
||||
${{ secrets.DOCKERHUB_USERNAME }}/${{ matrix.image_name }}:latest
|
||||
platforms: linux/amd64,linux/arm64
|
||||
target: ${{ matrix.target }}
|
||||
|
|
|
|||
|
|
@ -7,9 +7,7 @@ WORKDIR /app
|
|||
# Allow mounting of these files, which have no default
|
||||
# values.
|
||||
RUN touch .env
|
||||
# Install call deps - Install curl for health check
|
||||
RUN apk --no-cache add curl && \
|
||||
npm ci
|
||||
RUN npm ci
|
||||
|
||||
# React client build
|
||||
ENV NODE_OPTIONS="--max-old-space-size=2048"
|
||||
|
|
|
|||
|
|
@ -624,7 +624,7 @@ class OpenAIClient extends BaseClient {
|
|||
const { finish_reason } = streamResult.choices[0];
|
||||
opts.addMetadata({ finish_reason });
|
||||
}
|
||||
return reply.trim();
|
||||
return (reply ?? '').trim();
|
||||
}
|
||||
|
||||
initializeLLM({
|
||||
|
|
|
|||
|
|
@ -7,36 +7,13 @@ const addSpaceIfNeeded = (text) => (text.length > 0 && !text.endsWith(' ') ? tex
|
|||
|
||||
const createOnProgress = ({ generation = '', onProgress: _onProgress }) => {
|
||||
let i = 0;
|
||||
let code = '';
|
||||
let precode = '';
|
||||
let codeBlock = false;
|
||||
let tokens = addSpaceIfNeeded(generation);
|
||||
|
||||
const progressCallback = async (partial, { res, text, bing = false, ...rest }) => {
|
||||
let chunk = partial === text ? '' : partial;
|
||||
tokens += chunk;
|
||||
precode += chunk;
|
||||
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) {
|
||||
tokens = citeText(tokens, true);
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue