From b49b8063601ae4f1424f8b9bbbb4ae4c8107a806 Mon Sep 17 00:00:00 2001 From: Adam Tilghman Date: Sat, 17 Feb 2024 19:52:30 -0800 Subject: [PATCH] allow model spec --- .github/workflows/docker.chatgpt-minimal.yml | 38 ------------- .github/workflows/docker.yml | 59 ++++++++++++++++++++ src/pages/api/chat-completion.ts | 2 +- 3 files changed, 60 insertions(+), 39 deletions(-) delete mode 100644 .github/workflows/docker.chatgpt-minimal.yml create mode 100644 .github/workflows/docker.yml diff --git a/.github/workflows/docker.chatgpt-minimal.yml b/.github/workflows/docker.chatgpt-minimal.yml deleted file mode 100644 index 927d789..0000000 --- a/.github/workflows/docker.chatgpt-minimal.yml +++ /dev/null @@ -1,38 +0,0 @@ -name: Publish blrchen/chatgpt-minimal - -on: - workflow_dispatch: - push: - branches: - - main - -jobs: - build_and_push_image: - name: Push image to Docker Hub - runs-on: ubuntu-latest - steps: - - name: Checkout - uses: actions/checkout@v3 - - name: Set up QEMU - uses: docker/setup-qemu-action@v2 - - name: Set up Docker Buildx - uses: docker/setup-buildx-action@v2 - - name: Log in to Docker Hub - uses: docker/login-action@v2 - with: - username: ${{ secrets.DOCKER_USERNAME }} - password: ${{ secrets.DOCKER_PASSWORD }} - - name: Extract metadata (tags, labels) for Docker - id: meta - uses: docker/metadata-action@v4 - with: - images: blrchen/chatgpt-minimal - - name: Build and push multi-arch image - uses: docker/build-push-action@v4 - with: - context: . - file: ./Dockerfile - platforms: linux/amd64,linux/arm64 - push: true - tags: ${{ steps.meta.outputs.tags }} - labels: ${{ steps.meta.outputs.labels }} \ No newline at end of file diff --git a/.github/workflows/docker.yml b/.github/workflows/docker.yml new file mode 100644 index 0000000..0b4dc74 --- /dev/null +++ b/.github/workflows/docker.yml @@ -0,0 +1,59 @@ +name: Build notebook +on: + push: + +env: + REGISTRY: ghcr.io + IMAGE_NAME: ${{ github.repository }} + +jobs: + build-and-push-image: + runs-on: ubuntu-latest + permissions: + contents: read + packages: write + + steps: + - name: Checkout notebook + uses: actions/checkout@v3 + + - name: Log in to registry + uses: docker/login-action@v2 + with: + registry: ${{ env.REGISTRY }} + username: ${{ github.actor }} + password: ${{ secrets.GITHUB_TOKEN }} + + - name: Generate tags and labels + id: meta + uses: docker/metadata-action@v4 + with: + images: ${{ env.REGISTRY }}/${{ env.IMAGE_NAME }} + + - name: Check Free Space 0 + run: | + echo "Free space:" + df -h + + - name: Docker/ENV cleanup Cleanup + run: | + docker image prune -a -f + docker container prune -f + sudo rm -rf /usr/local/lib/android + sudo rm -rf /usr/share/dotnet + sudo rm -rf /opt/ghc + sudo rm -rf "/usr/local/share/boost" + sudo rm -rf "$AGENT_TOOLSDIRECTORY" + + - name: Check Free Space 1 + run: | + echo "Free space:" + df -h + + - name: Build and push notebook + uses: docker/build-push-action@v4 + with: + context: . + push: true + tags: ${{ steps.meta.outputs.tags }} + labels: ${{ steps.meta.outputs.labels }} diff --git a/src/pages/api/chat-completion.ts b/src/pages/api/chat-completion.ts index 8a80d4a..ccf2487 100644 --- a/src/pages/api/chat-completion.ts +++ b/src/pages/api/chat-completion.ts @@ -47,7 +47,7 @@ const handler = async (req: Request): Promise => { } apiUrl = `${apiBaseUrl}/v1/chat/completions` apiKey = process.env.OPENAI_API_KEY || '' - model = 'gpt-3.5-turbo' // todo: allow this to be passed through from client and support gpt-4 + model = process.env.OPENAI_API_MODEL || 'gpt-3.5-turbo' // todo: allow this to be passed through from client and support gpt-4 } const stream = await OpenAIStream(apiUrl, apiKey, model, messagesToSend)