Skip to content
Closed

my #2981

Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
75 changes: 0 additions & 75 deletions .github/workflows/docker-image-alpha.yml
Original file line number Diff line number Diff line change
@@ -1,9 +1,6 @@
name: Publish Docker image (alpha)

on:
push:
branches:
- alpha
workflow_dispatch:
inputs:
name:
Expand Down Expand Up @@ -48,12 +45,6 @@ jobs:
- name: Set up Docker Buildx
uses: docker/setup-buildx-action@v3

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Log in to GHCR
uses: docker/login-action@v3
with:
Expand All @@ -76,76 +67,10 @@ jobs:
platforms: ${{ matrix.platform }}
push: true
tags: |
calciumion/new-api:alpha-${{ matrix.arch }}
calciumion/new-api:${{ steps.version.outputs.value }}-${{ matrix.arch }}
ghcr.io/${{ env.GHCR_REPOSITORY }}:alpha-${{ matrix.arch }}
ghcr.io/${{ env.GHCR_REPOSITORY }}:${{ steps.version.outputs.value }}-${{ matrix.arch }}
labels: ${{ steps.meta.outputs.labels }}
cache-from: type=gha
cache-to: type=gha,mode=max
provenance: false
sbom: false

create_manifests:
name: Create multi-arch manifests (Docker Hub + GHCR)
needs: [build_single_arch]
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
steps:
- name: Check out (shallow)
uses: actions/checkout@v4
with:
fetch-depth: 1

- name: Normalize GHCR repository
run: echo "GHCR_REPOSITORY=${GITHUB_REPOSITORY,,}" >> $GITHUB_ENV

- name: Determine alpha version
id: version
run: |
VERSION="alpha-$(date +'%Y%m%d')-$(git rev-parse --short HEAD)"
echo "value=$VERSION" >> $GITHUB_OUTPUT
echo "VERSION=$VERSION" >> $GITHUB_ENV

- name: Log in to Docker Hub
uses: docker/login-action@v3
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}

- name: Create & push manifest (Docker Hub - alpha)
run: |
docker buildx imagetools create \
-t calciumion/new-api:alpha \
calciumion/new-api:alpha-amd64 \
calciumion/new-api:alpha-arm64

- name: Create & push manifest (Docker Hub - versioned alpha)
run: |
docker buildx imagetools create \
-t calciumion/new-api:${VERSION} \
calciumion/new-api:${VERSION}-amd64 \
calciumion/new-api:${VERSION}-arm64

- name: Log in to GHCR
uses: docker/login-action@v3
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Create & push manifest (GHCR - alpha)
run: |
docker buildx imagetools create \
-t ghcr.io/${GHCR_REPOSITORY}:alpha \
ghcr.io/${GHCR_REPOSITORY}:alpha-amd64 \
ghcr.io/${GHCR_REPOSITORY}:alpha-arm64

- name: Create & push manifest (GHCR - versioned alpha)
run: |
docker buildx imagetools create \
-t ghcr.io/${GHCR_REPOSITORY}:${VERSION} \
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-amd64 \
ghcr.io/${GHCR_REPOSITORY}:${VERSION}-arm64
4 changes: 0 additions & 4 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -8,10 +8,6 @@ on:
name:
description: 'reason'
required: false
push:
tags:
- '*'
- '!*-alpha*'

jobs:
linux:
Expand Down
15 changes: 13 additions & 2 deletions relay/channel/api_request.go
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@ import (

common2 "github.com/QuantumNous/new-api/common"
"github.com/QuantumNous/new-api/logger"
"github.com/QuantumNous/new-api/model"
"github.com/QuantumNous/new-api/relay/common"
"github.com/QuantumNous/new-api/relay/constant"
"github.com/QuantumNous/new-api/relay/helper"
Expand Down Expand Up @@ -40,7 +41,7 @@ func SetupApiRequestHeader(info *common.RelayInfo, c *gin.Context, req *http.Hea

const clientHeaderPlaceholderPrefix = "{client_header:"

func applyHeaderOverridePlaceholders(template string, c *gin.Context, apiKey string) (string, bool, error) {
func applyHeaderOverridePlaceholders(template string, c *gin.Context, apiKey string, info *common.RelayInfo) (string, bool, error) {
trimmed := strings.TrimSpace(template)
if strings.HasPrefix(trimmed, clientHeaderPlaceholderPrefix) {
afterPrefix := trimmed[len(clientHeaderPlaceholderPrefix):]
Expand All @@ -67,6 +68,15 @@ func applyHeaderOverridePlaceholders(template string, c *gin.Context, apiKey str
if strings.Contains(template, "{api_key}") {
template = strings.ReplaceAll(template, "{api_key}", apiKey)
}
if strings.Contains(template, "{client_ip}") {
clientIp := c.ClientIP()
template = strings.ReplaceAll(template, "{client_ip}", clientIp)
}
if strings.Contains(template, "{ext_account}") {
username, _ := model.GetUsernameById(info.UserId, true)
template = strings.ReplaceAll(template, "{ext_account}", username)
}

if strings.TrimSpace(template) == "" {
return "", false, nil
}
Expand All @@ -85,7 +95,7 @@ func processHeaderOverride(info *common.RelayInfo, c *gin.Context) (map[string]s
return nil, types.NewError(nil, types.ErrorCodeChannelHeaderOverrideInvalid)
}

value, include, err := applyHeaderOverridePlaceholders(str, c, info.ApiKey)
value, include, err := applyHeaderOverridePlaceholders(str, c, info.ApiKey, info)
if err != nil {
return nil, types.NewError(err, types.ErrorCodeChannelHeaderOverrideInvalid)
}
Expand All @@ -95,6 +105,7 @@ func processHeaderOverride(info *common.RelayInfo, c *gin.Context) (map[string]s

headerOverride[k] = value
}
//fmt.Printf("processHeaderOverride headerOverride = %+v\n", headerOverride)
return headerOverride, nil
}

Expand Down
2 changes: 1 addition & 1 deletion web/index.html
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@
content="OpenAI 接口聚合管理,支持多种渠道包括 Azure,可用于二次分发管理 key,仅单可执行文件,已打包好 Docker 镜像,一键部署,开箱即用"
/>
<meta name="generator" content="new-api" />
<title>New API</title>
<title>Gthree AI</title>
<!--umami-->
<!--Google Analytics-->
</head>
Expand Down
Binary file modified web/public/logo.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Binary file added web/public/logo1.png
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
6 changes: 2 additions & 4 deletions web/src/components/layout/Footer.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -196,7 +196,7 @@ const FooterBar = () => {
</div>

<div className='text-sm'>
<span className='!text-semi-color-text-1'>
<span className='!text-semi-color-text-1' style={{ visibility: 'hidden' }}>
{t('设计与开发由')}{' '}
</span>
<a
Expand All @@ -205,7 +205,6 @@ const FooterBar = () => {
rel='noopener noreferrer'
className='!text-semi-color-primary font-medium'
>
New API
</a>
</div>
</div>
Expand All @@ -226,15 +225,14 @@ const FooterBar = () => {
className='custom-footer'
dangerouslySetInnerHTML={{ __html: footer }}
></div>
<div className='absolute bottom-2 right-4 text-xs !text-semi-color-text-2 opacity-70'>
<div style={{visibility: 'hidden'}} className='absolute bottom-2 right-4 text-xs !text-semi-color-text-2 opacity-70'>
<span>{t('设计与开发由')} </span>
<a
href='https://github.com/QuantumNous/new-api'
target='_blank'
rel='noopener noreferrer'
className='!text-semi-color-primary font-medium'
>
New API
</a>
</div>
</div>
Expand Down
2 changes: 1 addition & 1 deletion web/src/components/settings/OtherSetting.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -477,7 +477,7 @@ const OtherSetting = () => {
'移除 One API 的版权标识必须首先获得授权,项目维护需要花费大量精力,如果本项目对你有意义,请主动支持本项目',
)}
closeIcon={null}
style={{ marginTop: 15 }}
style={{ marginTop: 15, visibility: 'hidden' }}
/>
<Form.Input
label={t('页脚')}
Expand Down
2 changes: 1 addition & 1 deletion web/src/helpers/utils.jsx
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ export function isRoot() {

export function getSystemName() {
let system_name = localStorage.getItem('system_name');
if (!system_name) return 'New API';
if (!system_name) return 'Gthree AI';
return system_name;
}

Expand Down
4 changes: 2 additions & 2 deletions web/src/i18n/locales/zh.json
Original file line number Diff line number Diff line change
Expand Up @@ -769,7 +769,7 @@
"多密钥渠道操作项目组": "多密钥渠道操作项目组",
"多密钥管理": "多密钥管理",
"多种充值方式,安全便捷": "多种充值方式,安全便捷",
"大模型接口网关": "大模型接口网关",
"大模型接口网关": "LLM API 网关",
"天": "天",
"天前": "天前",
"失败": "失败",
Expand Down Expand Up @@ -1300,7 +1300,7 @@
"更多": "更多",
"更多信息请参考": "更多信息请参考",
"更多参数请参考": "更多参数请参考",
"更好的价格,更好的稳定性,只需要将模型基址替换为:": "更好的价格,更好的稳定性,只需要将模型基址替换为:",
"更好的价格,更好的稳定性,只需要将模型基址替换为:": "更高的效率,只需要将模型基址替换为:",
"更新": "更新",
"更新 Creem 设置": "更新 Creem 设置",
"更新 Stripe 设置": "更新 Stripe 设置",
Expand Down