chore: enhance Anthropic support and optimize CI/CD processes

- Enhance the `Message` struct with new fields to support additional functionality.
- Streamline CI configuration by commenting out unused jobs and optimizing the build process for ARM64.
- Improve documentation and feature support for VolcEngine channel and bot model.
- Update Dockerfile to efficiently manage dependencies and enhance multi-architecture support.
This commit is contained in:
Laisky.Cai 2025-02-26 05:39:08 +00:00
parent db992c26c4
commit 1bc83bf812
4 changed files with 141 additions and 107 deletions

View File

@ -8,110 +8,112 @@ on:
- "test/ci"
jobs:
build_latest:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# build_latest:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Build and push latest
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ppcelery/one-api:latest
cache-from: type=gha
# cache-to: type=gha,mode=max
# - name: Build and push latest
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: ppcelery/one-api:latest
# cache-from: type=gha
# # cache-to: type=gha,mode=max
build_hash:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# build_hash:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
# - name: Add SHORT_SHA env property with commit short sha
# run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
- name: Build and push hash label
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ppcelery/one-api:${{ env.SHORT_SHA }}
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: Build and push hash label
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: ppcelery/one-api:${{ env.SHORT_SHA }}
# cache-from: type=gha
# cache-to: type=gha,mode=max
deploy:
runs-on: ubuntu-latest
needs: build_latest
steps:
- name: executing remote ssh commands using password
uses: appleboy/ssh-action@v1.0.3
with:
host: ${{ secrets.TARGET_HOST }}
username: ${{ secrets.TARGET_HOST_USERNAME }}
password: ${{ secrets.TARGET_HOST_PASSWORD }}
port: ${{ secrets.TARGET_HOST_SSH_PORT }}
script: |
docker pull ppcelery/one-api:latest
cd /home/laisky/repo/VPS
docker-compose -f b1-docker-compose.yml up -d --remove-orphans --force-recreate oneapi
docker ps
# deploy:
# runs-on: ubuntu-latest
# needs: build_latest
# steps:
# - name: executing remote ssh commands using password
# uses: appleboy/ssh-action@v1.0.3
# with:
# host: ${{ secrets.TARGET_HOST }}
# username: ${{ secrets.TARGET_HOST_USERNAME }}
# password: ${{ secrets.TARGET_HOST_PASSWORD }}
# port: ${{ secrets.TARGET_HOST_SSH_PORT }}
# script: |
# docker pull ppcelery/one-api:latest
# cd /home/laisky/repo/VPS
# docker-compose -f b1-docker-compose.yml up -d --remove-orphans --force-recreate oneapi
# docker ps
build_arm64_hash:
runs-on: ubuntu-latest
steps:
- name: Checkout
uses: actions/checkout@v4
# build_arm64_hash:
# runs-on: ubuntu-latest
# steps:
# - name: Checkout
# uses: actions/checkout@v4
- name: Set up QEMU
uses: docker/setup-qemu-action@v3
# - name: Set up QEMU
# uses: docker/setup-qemu-action@v3
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3
# - name: Set up Docker Buildx
# uses: docker/setup-buildx-action@v3
- name: Login to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
# - name: Login to Docker Hub
# uses: docker/login-action@v3
# with:
# username: ${{ secrets.DOCKERHUB_USERNAME }}
# password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Add SHORT_SHA env property with commit short sha
run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
# - name: Add SHORT_SHA env property with commit short sha
# run: echo "SHORT_SHA=`echo ${GITHUB_SHA} | cut -c1-7`" >> $GITHUB_ENV
- name: Build and push arm64 hash label
uses: docker/build-push-action@v5
with:
context: .
push: true
tags: ppcelery/one-api:arm64-${{ env.SHORT_SHA }}
platforms: linux/arm64
cache-from: type=gha
cache-to: type=gha,mode=max
# - name: Build and push arm64 hash label
# uses: docker/build-push-action@v5
# with:
# context: .
# push: true
# tags: ppcelery/one-api:arm64-${{ env.SHORT_SHA }}
# platforms: linux/arm64
# build-args: |
# TARGETARCH=arm64
# cache-from: type=gha
# cache-to: type=gha,mode=max
build_arm64_latest:
runs-on: ubuntu-latest
@ -138,5 +140,7 @@ jobs:
push: true
tags: ppcelery/one-api:arm64-latest
platforms: linux/arm64
build-args: |
TARGETARCH=arm64
cache-from: type=gha
# cache-to: type=gha,mode=max
cache-to: type=gha,mode=max

View File

@ -4,11 +4,16 @@ WORKDIR /web
COPY ./VERSION .
COPY ./web .
# Fix the React build issues by installing dependencies globally first
RUN npm install -g react-scripts
# Install dependencies for each project
RUN npm install --prefix /web/default & \
npm install --prefix /web/berry & \
npm install --prefix /web/air & \
wait
# Build the web projects
RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/default & \
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/berry & \
DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run build --prefix /web/air & \
@ -16,19 +21,27 @@ RUN DISABLE_ESLINT_PLUGIN='true' REACT_APP_VERSION=$(cat ./VERSION) npm run buil
FROM golang:1.24.0-bullseye AS builder2
RUN apt-get update && apt-get install -y --no-install-recommends \
build-essential \
sqlite3 libsqlite3-dev && \
rm -rf /var/lib/apt/lists/*
# Declare TARGETARCH so BuildKit can set it correctly.
# Make sure to use ARG with a default value
ARG TARGETARCH=amd64
# Set proper environment variables based on TARGETARCH
ENV GO111MODULE=on \
CGO_ENABLED=1 \
GOOS=linux \
CGO_CFLAGS="-I/usr/include" \
CGO_LDFLAGS="-L/usr/lib" \
GOARCH=$TARGETARCH
GOARCH=${TARGETARCH}
# For ARM64 builds
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
apt-get update && apt-get install -y gcc-aarch64-linux-gnu && \
export CC=aarch64-linux-gnu-gcc; \
else \
apt-get update && apt-get install -y build-essential; \
fi
# Common dependencies
RUN apt-get install -y --no-install-recommends \
sqlite3 libsqlite3-dev && \
rm -rf /var/lib/apt/lists/*
WORKDIR /build
@ -38,26 +51,32 @@ RUN go mod download
COPY . .
COPY --from=builder /web/build ./web/build
# For ARM64 builds, install and use the appropriate cross-compiler.
RUN if [ "$GOARCH" = "arm64" ]; then \
apt-get update && apt-get install -y gcc-aarch64-linux-gnu; \
fi
# Use a single RUN command to conditionally set CC for ARM64.
RUN if [ "$GOARCH" = "arm64" ]; then \
# Use the appropriate compiler based on architecture
RUN if [ "${TARGETARCH}" = "arm64" ]; then \
CC=aarch64-linux-gnu-gcc go build -trimpath -ldflags "-s -w -X github.com/songquanpeng/one-api/common.Version=$(cat VERSION)" -o one-api; \
else \
go build -trimpath -ldflags "-s -w -X github.com/songquanpeng/one-api/common.Version=$(cat VERSION)" -o one-api; \
fi
FROM debian:bullseye
# Use a pre-built image that already has ffmpeg for ARM64
FROM --platform=$TARGETPLATFORM jrottenberg/ffmpeg:4.3-ubuntu2004 AS ffmpeg
RUN rm /var/lib/dpkg/info/libc-bin.*
# Use Ubuntu as the base image which has better ARM64 support
FROM --platform=$TARGETPLATFORM ubuntu:20.04
ARG TARGETARCH=amd64
ENV DEBIAN_FRONTEND=noninteractive
# Install basic requirements without triggering libc-bin reconfiguration
RUN apt-get update && apt-get install -y --no-install-recommends \
ca-certificates tzdata bash haveged libc-bin ffmpeg && \
ca-certificates tzdata bash haveged && \
rm -rf /var/lib/apt/lists/*
# Copy ffmpeg binaries from the ffmpeg image
COPY --from=ffmpeg /usr/local/bin/ffmpeg /usr/local/bin/
COPY --from=ffmpeg /usr/local/bin/ffprobe /usr/local/bin/
# Copy our application binary
COPY --from=builder2 /build/one-api /
EXPOSE 3000

View File

@ -179,3 +179,4 @@ By default, the thinking mode is not enabled. You need to manually pass the `thi
- [fix: 修复高并发下,高额度用户使用低额度令牌没有预扣费而导致令牌大额欠费 #25](https://github.com/Laisky/one-api/pull/25)
- [fix: channel test false negative #2065](https://github.com/songquanpeng/one-api/pull/2065)
- [fix: resolve "bufio.Scanner: token too long" error by increasing buff… #2128](https://github.com/songquanpeng/one-api/pull/2128)
- [feat: Enhance VolcEngine channel support with bot model #2131](https://github.com/songquanpeng/one-api/pull/2131)

View File

@ -29,6 +29,11 @@ type Message struct {
// -------------------------------------
Reasoning *string `json:"reasoning,omitempty"`
Refusal *bool `json:"refusal,omitempty"`
// -------------------------------------
// Anthropic
// -------------------------------------
Thinking *string `json:"thinking,omitempty"`
Signature *string `json:"signature,omitempty"`
}
type messageAudio struct {
@ -135,6 +140,11 @@ type MessageContent struct {
Text string `json:"text"`
ImageURL *ImageURL `json:"image_url,omitempty"`
InputAudio *InputAudio `json:"input_audio,omitempty"`
// -------------------------------------
// Anthropic
// -------------------------------------
Thinking *string `json:"thinking,omitempty"`
Signature *string `json:"signature,omitempty"`
}
type InputAudio struct {