Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
Show all changes
186 commits
Select commit Hold shift + click to select a range
f0190ae
add relay metrics
mmxiaolin Mar 8, 2025
939d613
add relay metrics
mmxiaolin Mar 8, 2025
fe200bb
add relay metrics
mmxiaolin Mar 8, 2025
2cbf2a2
add relay metrics
mmxiaolin Mar 8, 2025
d7406b4
add relay metrics
mmxiaolin Mar 8, 2025
875a2c5
add relay metrics
mmxiaolin Mar 8, 2025
086c1b1
add relay metrics
mmxiaolin Mar 8, 2025
e85e49b
Merge pull request #1 from Furion-cn/feat/monitor
Prayer3th Mar 8, 2025
674b1d9
fix slave metrics
mmxiaolin Mar 8, 2025
043638b
Merge pull request #2 from Furion-cn/fix/slave-metrics
Prayer3th Mar 8, 2025
24c4982
账单导出接口开发完毕
Mar 9, 2025
fe94d43
账单导出接口开发完毕
Mar 10, 2025
1e01ff4
fix ration
Mar 10, 2025
a154dec
fix 前端
Mar 10, 2025
c6f5815
fix
Mar 10, 2025
9bf7c12
fix
Mar 10, 2025
ae7d6c6
Merge pull request #3 from Furion-cn/billing-export
pengchengneo Mar 10, 2025
a0a3ca6
add e2e metrics and remove msg detail
mmxiaolin Mar 10, 2025
2c07bd4
add e2e metrics and remove msg detail
mmxiaolin Mar 10, 2025
0086355
add e2e metrics and remove msg detail
mmxiaolin Mar 10, 2025
55f8867
add e2e metrics and remove msg detail
mmxiaolin Mar 10, 2025
0588de0
Merge pull request #4 from Furion-cn/feat/model-search
Prayer3th Mar 10, 2025
3434aa0
adjust openai error
mmxiaolin Mar 11, 2025
7ca8892
adjust openai error
mmxiaolin Mar 11, 2025
a99026a
Merge pull request #5 from Furion-cn/feat/adjust-err
Prayer3th Mar 11, 2025
127dbce
fix
Mar 11, 2025
660ad47
fix
Mar 11, 2025
fbdbd9b
fix billing
Mar 12, 2025
7982206
fix
Mar 12, 2025
890cbc1
Merge pull request #6 from Furion-cn/billing-optim
pengchengneo Mar 12, 2025
517cbf2
只有root账户可以导出账单
Mar 12, 2025
4cc8140
权限管理
Mar 12, 2025
c66b8e1
fix 权限管理
Mar 12, 2025
dd7b261
fix bug
Mar 13, 2025
4ba377d
root权限二次开发
pengchengneo Mar 13, 2025
8a499c4
暂存代码
Mar 12, 2025
cae0438
只有root账户可以导出账单
Mar 12, 2025
3693309
fix split
Mar 13, 2025
4ac923c
fix
Mar 13, 2025
a2a924b
fix
Mar 13, 2025
ab6c0b3
fix
Mar 13, 2025
2e65fb1
fix
Mar 13, 2025
abeadb1
Merge pull request #8 from Furion-cn/split-table
pengchengneo Mar 13, 2025
c9b8af7
add user key
mmxiaolin Mar 13, 2025
1a7715a
add user key
mmxiaolin Mar 13, 2025
46141d7
add user key
mmxiaolin Mar 13, 2025
b3f1b98
add user key
mmxiaolin Mar 13, 2025
a30c4d5
add user key
mmxiaolin Mar 13, 2025
c0fc868
add user key
mmxiaolin Mar 13, 2025
0c9f316
add user key
mmxiaolin Mar 14, 2025
3ee3f45
Merge pull request #9 from Furion-cn/feat/user-key
Prayer3th Mar 14, 2025
aef54ac
bugfix
Mar 14, 2025
adc95f3
Merge pull request #10 from Furion-cn/fix/billing-bug-fix
pengchengneo Mar 17, 2025
bfb870c
export billing by username
Mar 17, 2025
f40ea2c
fix
Mar 17, 2025
925f429
fix
Mar 17, 2025
2ce45cb
fix
Mar 17, 2025
1566056
fix
Mar 18, 2025
8e669a9
fix
Mar 18, 2025
b7e2939
fix
Mar 18, 2025
f2b11ac
fix
Mar 18, 2025
9ee816e
fix
Mar 18, 2025
1757abe
Merge pull request #11 from Furion-cn/export-billing-byUserName
pengchengneo Mar 18, 2025
7d717f2
fix
Mar 18, 2025
fe020de
fix
Mar 18, 2025
ec1c642
fix
Mar 18, 2025
f56440b
Merge pull request #12 from Furion-cn/export-billing-byUserName
pengchengneo Mar 18, 2025
5c2d31e
support claude origin
mmxiaolin Mar 19, 2025
a0774c9
support claude origin
mmxiaolin Mar 20, 2025
9d171db
support claude origin
mmxiaolin Mar 20, 2025
4070438
Merge pull request #14 from Furion-cn/feat/support-claude-origin
Prayer3th Mar 24, 2025
7d04cbd
pass request-id from upstream
Mar 19, 2025
3d1138c
Merge pull request #13 from Furion-cn/feat/request-id
pengchengneo Mar 24, 2025
90fa322
fix
Mar 25, 2025
0e93486
Merge pull request #15 from Furion-cn/fix/fix-tokenname-null
pengchengneo Mar 25, 2025
5c1e20c
fix export billing
Mar 25, 2025
f945863
quotadata refactor
Mar 25, 2025
2ca7182
fix
Mar 25, 2025
cd0dac3
add base url
mmxiaolin Mar 26, 2025
d8d83a9
add base url
mmxiaolin Mar 26, 2025
5543fff
add base url
mmxiaolin Mar 27, 2025
17245d5
Merge pull request #16 from Furion-cn/fix/billing-bug-fix-0325
pengchengneo Mar 27, 2025
f2f5394
Merge pull request #17 from Furion-cn/feat/add-baseurl
Prayer3th Mar 27, 2025
1c8617e
fix
Mar 29, 2025
f9f1637
add group table
pengchengneo Mar 31, 2025
af1dc2c
fix
pengchengneo Mar 31, 2025
6347cb3
fix
pengchengneo Mar 31, 2025
cfc5ffa
Merge pull request #18 from Furion-cn/fix/fix-log-query
pengchengneo Mar 31, 2025
09cea73
fix fe error
pengchengneo Apr 3, 2025
4528a28
fix
pengchengneo Apr 3, 2025
fc3f063
Merge pull request #19 from Furion-cn/fix/fe-error
pengchengneo Apr 3, 2025
74726cc
fix
pengchengneo Apr 7, 2025
4e86823
Merge pull request #20 from Furion-cn/fix/add-logtable-check
pengchengneo Apr 8, 2025
1b194bb
add sys error
Apr 15, 2025
fbf75ba
Update relay-gemini.go
xing0821 Apr 17, 2025
2f0cef3
Update openai_request.go
xing0821 Apr 17, 2025
7c65dd0
Merge pull request #21 from Furion-cn/feat/add-log-gemini
xing0821 Apr 17, 2025
2c31f43
update youtube
Apr 17, 2025
02e8d15
update gemini request
Apr 17, 2025
11c7bd6
fix error
pengchengneo Apr 18, 2025
0f9a71a
fix completion ratio
pengchengneo Apr 22, 2025
726d4c9
fix
pengchengneo Apr 22, 2025
e0c5667
Merge pull request #22 from Furion-cn/fix/fix-price
pengchengneo Apr 25, 2025
21ae078
add thinking token record
Apr 30, 2025
b278f49
ignore log if message too large
Apr 30, 2025
9df442d
support xai
May 3, 2025
dde72bb
fix grok return completion token include thinking token
May 5, 2025
d97c2d7
bugfix: init xai adaptor
May 5, 2025
baaaab3
remove unused api
May 5, 2025
58dfbad
fix mysql table groups table no init && add web init port 80 and list…
whatattitude May 8, 2025
e688558
Merge pull request #23 from Furion-cn/fix/deployment_init
xing0821 May 8, 2025
730542d
fix: 修复客户端转发逻辑异常的问题
whatattitude May 18, 2025
d5bcf3f
Merge pull request #24 from Furion-cn/fix/client-forwarding-bug
whatattitude May 18, 2025
9b6a385
do not retry when copy body failed
May 19, 2025
032fb1f
Merge pull request #25 from Furion-cn/feat/do_not_retry_when_copy_bod…
whatattitude May 19, 2025
8c96ac1
Update github workflow
May 21, 2025
b729f98
update secret name
May 21, 2025
892406d
update secret name
May 21, 2025
610d3dd
update secret name
May 21, 2025
c8826bd
remove token encoders
May 23, 2025
da6c470
fix: remove unused service
May 23, 2025
0f46ac4
auto build when merge into main
May 23, 2025
adac3c1
add thinking config
May 27, 2025
379fbd6
add thinking disable
May 27, 2025
e2e1e92
re-init token
May 27, 2025
1235a90
fix: rename
May 27, 2025
e6cf9f5
fix: rename to thinking
May 27, 2025
e2c942b
update vol code
May 29, 2025
c7c6157
update vol code
May 29, 2025
0a6bc99
fix: include thinkingTokens in completionTokens calculation for billing
whatattitude Jun 3, 2025
2d210e1
Merge pull request #26 from Furion-cn/fix/completion-tokens-calculation
whatattitude Jun 4, 2025
366d89d
feat: 添加请求持久化和测试流量处理功能,优化日志记录和时区处理
whatattitude Jun 4, 2025
95f87ce
Merge pull request #27 from Furion-cn/feature/optimize-billing-logic
whatattitude Jun 4, 2025
3c63f48
feat: 优化计费逻辑,支持测试流量不计入账单和mock返回
whatattitude Jun 6, 2025
b355602
Merge pull request #28 from Furion-cn/feature/optimize-billing-logic
whatattitude Jun 6, 2025
3325a5c
feat: 增加gemini支持thinking budget
whatattitude Jun 7, 2025
9d3c83d
Merge pull request #29 from Furion-cn/feature/gemini-thinking-budget
whatattitude Jun 7, 2025
db8c405
fix: optimize GetBeijingTimestamp to check both timezone name and offset
whatattitude Jun 8, 2025
d16ec56
Merge pull request #30 from Furion-cn/feature/optimize-billing-logic
whatattitude Jun 8, 2025
4949605
fix: 修复计费逻辑中的时间处理问题
whatattitude Jun 9, 2025
808fa5b
Merge pull request #31 from Furion-cn/feature/optimize-billing-logic
whatattitude Jun 9, 2025
0f90678
feat: 添加日志采样功能
whatattitude Jun 10, 2025
8f0d435
Merge pull request #32 from Furion-cn/feature/optimize-billing-logic
whatattitude Jun 10, 2025
176ad7c
feat: update gitignore and volcengine adaptor
whatattitude Jun 11, 2025
d4af368
Merge pull request #33 from Furion-cn/feature/add-doubao-thinking-param
whatattitude Jun 11, 2025
52ce19b
fix: safely handle nil Thinking field in volcengine adaptor to preven…
whatattitude Jun 11, 2025
fa84835
Merge pull request #34 from Furion-cn/feature/add-doubao-thinking-param
whatattitude Jun 11, 2025
4df8397
feat: optimize user group logic - Add user role check in group.go - F…
whatattitude Jun 12, 2025
1b21860
merge: 解决合并冲突
whatattitude Jun 12, 2025
bc23fb0
Merge pull request #35 from Furion-cn/feature/optimize-user-group-logic
whatattitude Jun 12, 2025
44b46be
add group limit
whatattitude Jun 12, 2025
f8c3d22
delete Redundant statements
whatattitude Jun 12, 2025
de8f6dd
Merge pull request #36 from Furion-cn/feature/optimize-user-group-logic
whatattitude Jun 12, 2025
8b595af
fix: 修复 hash_value 在请求链路中的传递问题,统一使用 gin.Context 存储和获取 hash_value
whatattitude Jun 12, 2025
81f6f4e
Merge pull request #37 from Furion-cn/feature/optimize-billing-logic
whatattitude Jun 12, 2025
d2b69fb
fix log type and clean log
whatattitude Jun 12, 2025
a21a950
fix log type and clean log
whatattitude Jun 12, 2025
ecf5de2
Merge pull request #38 from Furion-cn/feature/optimize-billing-logic
whatattitude Jun 12, 2025
5146180
fix group limits
whatattitude Jun 12, 2025
0751300
Merge pull request #39 from Furion-cn/feature/optimize-user-group-logic
whatattitude Jun 12, 2025
5a46b33
feat: add request body logging control
whatattitude Jun 13, 2025
81ed256
Merge remote-tracking branch 'origin/main' into feat/optimize-logging
whatattitude Jun 13, 2025
a86ee82
add middleware interface
whatattitude Jun 13, 2025
318db06
Merge pull request #40 from Furion-cn/feat/optimize-logging
whatattitude Jun 13, 2025
74f7c95
add token metrics
whatattitude Jun 15, 2025
edf4a43
Merge pull request #41 from Furion-cn/feat/optimize-logging
whatattitude Jun 15, 2025
69e3bb9
add metrics label
whatattitude Jun 15, 2025
10dced1
Merge pull request #42 from Furion-cn/feat/optimize-logging
whatattitude Jun 15, 2025
48497eb
fix: 优化请求体日志输出,支持中文显示并移除换行符
whatattitude Jun 18, 2025
f823fe6
Merge pull request #43 from Furion-cn/feat/optimize-logging
whatattitude Jun 18, 2025
fbf165d
feat: add channel_name to metrics and error logging
whatattitude Jun 18, 2025
cba3bd1
add doubao batch && add gemini tts to text
whatattitude Jun 22, 2025
94e8953
feat: 同步本地更改
whatattitude Jun 22, 2025
492e05f
fix lack of channel get method
whatattitude Jun 22, 2025
aea1475
Merge pull request #44 from Furion-cn/feat/doubao-batch
whatattitude Jun 22, 2025
b2e8437
feat: add audio support for Gemini channel
whatattitude Jun 23, 2025
4c43676
Merge pull request #45 from Furion-cn/feature/gemini-patch
whatattitude Jun 23, 2025
163b53c
fix fps lose
whatattitude Jun 23, 2025
687808e
Merge pull request #46 from Furion-cn/feature/gemini-patch
whatattitude Jun 23, 2025
74fd9e9
add rate limit api
whatattitude Jun 25, 2025
ade4000
detele unless code
whatattitude Jun 25, 2025
9463922
detele unless code
whatattitude Jun 25, 2025
c11f0c3
Merge pull request #47 from Furion-cn/feat/doubao-batch
whatattitude Jun 25, 2025
09e89ef
feat: 增强火山引擎批量推理多模态支持,添加图片像素限制参数支持
whatattitude Jun 25, 2025
c43937f
add doubao image
whatattitude Jun 25, 2025
2a701d6
add doubao image data
whatattitude Jun 27, 2025
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
70 changes: 28 additions & 42 deletions .github/workflows/docker-image-amd64.yml
Original file line number Diff line number Diff line change
@@ -1,54 +1,40 @@
name: Publish Docker image (amd64)
name: Build NewAPI Docker Image

on:
push:
tags:
- '*'
- "main"
workflow_dispatch:
inputs:
name:
description: 'reason'
required: false
git_branch:
description: 'Git branch'
required: true
default: 'main'
remote_repo:
description: 'Remote repository'
required: true
default: 'https://github.com/Furion-cn/new-api.git'

jobs:
push_to_registries:
name: Push Docker image to multiple registries
runs-on: ubuntu-latest
permissions:
packages: write
contents: read
build-dev:
runs-on: ubuntu-22.04
steps:
- name: Check out the repo
uses: actions/checkout@v3

- name: Save version info
run: |
git describe --tags > VERSION

- name: Log in to Docker Hub
uses: docker/login-action@v2
with:
username: ${{ secrets.DOCKERHUB_USERNAME }}
password: ${{ secrets.DOCKERHUB_TOKEN }}
- name: Checkout repository
uses: actions/checkout@v4

- name: Log in to the Container registry
- name: Login to Tencent Cloud Registry
uses: docker/login-action@v2
with:
registry: ghcr.io
username: ${{ github.actor }}
password: ${{ secrets.GITHUB_TOKEN }}

- name: Extract metadata (tags, labels) for Docker
id: meta
uses: docker/metadata-action@v4
with:
images: |
calciumion/new-api
ghcr.io/${{ github.repository }}
registry: furion-sh.tencentcloudcr.com
username: ${{ secrets.TCR_USERNAME }}
password: ${{ secrets.TCR_PASSWORD }}

- name: Build and push Docker images
uses: docker/build-push-action@v3
with:
context: .
push: true
tags: ${{ steps.meta.outputs.tags }}
labels: ${{ steps.meta.outputs.labels }}
- name: Build and Push SGLang Image
run: |
DATETIME=$(date '+%Y%m%d_%H%M')
ORG=$(echo "${{ inputs.remote_repo }}" | awk -F'/' '{print $(NF-1)}' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')
BRANCH=$(echo "${{ inputs.git_branch }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')
VERSION="${DATETIME}_${ORG}_${BRANCH}"
git clone ${{ inputs.remote_repo }} && cd new-api
docker build . -t furion-sh.tencentcloudcr.com/furion/new-api:${VERSION}
docker push furion-sh.tencentcloudcr.com/furion/new-api:${VERSION}
Comment on lines +32 to +40

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

🛠️ Refactor suggestion

⚠️ Potential issue

Add error handling and security validation for remote repository operations

The build script has several issues:

  1. No validation of the remote repository URL (potential security risk)
  2. No error handling for git clone, docker build, or docker push operations
  3. Directory might already exist from previous runs
       - name: Build and Push SGLang Image
         run: |
           DATETIME=$(date '+%Y%m%d_%H%M')
           ORG=$(echo "${{ inputs.remote_repo }}" | awk -F'/' '{print $(NF-1)}' | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')
           BRANCH=$(echo "${{ inputs.git_branch }}" | tr '[:upper:]' '[:lower:]' | sed 's/[^a-z0-9]/-/g')
           VERSION="${DATETIME}_${ORG}_${BRANCH}"
-          git clone ${{ inputs.remote_repo }} && cd new-api
-          docker build . -t furion-sh.tencentcloudcr.com/furion/new-api:${VERSION}
-          docker push furion-sh.tencentcloudcr.com/furion/new-api:${VERSION}
+          
+          # Validate repository URL
+          if [[ ! "${{ inputs.remote_repo }}" =~ ^https://github\.com/[^/]+/[^/]+\.git$ ]]; then
+            echo "Error: Invalid repository URL format"
+            exit 1
+          fi
+          
+          # Clean up any existing directory
+          rm -rf new-api
+          
+          # Clone with error handling
+          if ! git clone --depth 1 --branch "${{ inputs.git_branch }}" "${{ inputs.remote_repo }}" new-api; then
+            echo "Error: Failed to clone repository"
+            exit 1
+          fi
+          
+          cd new-api
+          
+          # Build with error handling
+          if ! docker build . -t furion-sh.tencentcloudcr.com/furion/new-api:${VERSION}; then
+            echo "Error: Docker build failed"
+            exit 1
+          fi
+          
+          # Push with error handling
+          if ! docker push furion-sh.tencentcloudcr.com/furion/new-api:${VERSION}; then
+            echo "Error: Docker push failed"
+            exit 1
+          fi
+          
+          echo "Successfully built and pushed version: ${VERSION}"
🧰 Tools
🪛 YAMLlint (1.37.1)

[error] 40-40: no new line character at the end of file

(new-line-at-end-of-file)

🤖 Prompt for AI Agents
In .github/workflows/docker-image-amd64.yml around lines 32 to 40, add
validation to ensure the remote repository URL is safe and correctly formatted
before cloning. Implement error handling after each critical command (git clone,
docker build, docker push) to catch failures and stop the workflow if any step
fails. Also, check if the target directory exists before cloning and remove or
rename it to avoid conflicts from previous runs.

11 changes: 10 additions & 1 deletion .gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -9,4 +9,13 @@ logs
web/dist
.env
one-api
.DS_Store
.DS_Store
new-api
script/
.env_2
*_test.go
out.log
out.log_2
.env_3
*.prof
.env*
16 changes: 10 additions & 6 deletions Dockerfile
Original file line number Diff line number Diff line change
@@ -1,4 +1,4 @@
FROM oven/bun:latest AS builder
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/oven/bun:latest AS builder

WORKDIR /build
COPY web/package.json .
Expand All @@ -7,29 +7,33 @@ COPY ./web .
COPY ./VERSION .
RUN DISABLE_ESLINT_PLUGIN='true' VITE_REACT_APP_VERSION=$(cat VERSION) bun run build

FROM golang:alpine AS builder2
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/golang:alpine3.21 AS builder2

ENV GO111MODULE=on \
CGO_ENABLED=0 \
GOOS=linux
GOOS=linux \
GOPROXY=https://goproxy.cn

WORKDIR /build

ADD go.mod go.sum ./

Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

⚠️ Potential issue

Use COPY instead of ADD for local files.

Static analysis correctly identifies that COPY should be used instead of ADD when copying local files and directories, as ADD has additional functionality (URL fetching, tar extraction) that isn't needed here.

-ADD go.mod go.sum ./
+COPY go.mod go.sum ./
📝 Committable suggestion

‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation. Thoroughly test & benchmark the code to ensure it meets the requirements.

Suggested change
ADD go.mod go.sum ./
# Dockerfile – replace ADD with COPY for local files
COPY go.mod go.sum ./
🧰 Tools
🪛 Hadolint (2.12.0)

[error] 19-19: Use COPY instead of ADD for files and folders

(DL3020)

🤖 Prompt for AI Agents
In Dockerfile at line 19, replace the ADD instruction with COPY when copying
local files go.mod and go.sum. This change avoids using ADD's extra features
like URL fetching and tar extraction, which are unnecessary here, and follows
best practices for copying local files.

RUN go mod tidy
RUN go mod download

COPY . .
COPY --from=builder /build/dist ./web/dist
RUN go mod tidy
RUN go build -ldflags "-s -w -X 'one-api/common.Version=$(cat VERSION)'" -o one-api

FROM alpine
FROM swr.cn-north-4.myhuaweicloud.com/ddn-k8s/docker.io/library/alpine:latest

RUN apk update \
RUN sed -i 's/dl-cdn.alpinelinux.org/mirrors.aliyun.com/g' /etc/apk/repositories \
&& apk update \
&& apk upgrade \
&& apk add --no-cache ca-certificates tzdata ffmpeg \
&& update-ca-certificates

COPY --from=builder2 /build/one-api /
EXPOSE 3000
WORKDIR /data
ENTRYPOINT ["/one-api"]
ENTRYPOINT ["/one-api"]
7 changes: 7 additions & 0 deletions bin/groups.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
CREATE TABLE IF NOT EXISTS `groups` (
`id` int(11) NOT NULL AUTO_INCREMENT,
`name` varchar(255) NOT NULL DEFAULT '',
`ratio` int(11) NOT NULL DEFAULT 0,
PRIMARY KEY (`id`),
UNIQUE KEY `idx_name` (`name`)
) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci;
1 change: 1 addition & 0 deletions bin/log_requestid.sql
Original file line number Diff line number Diff line change
@@ -0,0 +1 @@
ALTER TABLE logs ADD COLUMN request_id VARCHAR(255) DEFAULT '' COMMENT '请求ID';
60 changes: 60 additions & 0 deletions common/constants.go
Original file line number Diff line number Diff line change
Expand Up @@ -26,12 +26,16 @@ var DataExportEnabled = true
var DataExportInterval = 5 // unit: minute
var DataExportDefaultTime = "hour" // unit: minute
var DefaultCollapseSidebar = false // default value of collapse sidebar
var MockResponseEnabled = false // whether to enable mock response for test traffic

// Any options with "Secret", "Token" in its key won't be return by GetOptions

var SessionSecret = uuid.New().String()
var CryptoSecret = uuid.New().String()

// 需要先导入 model 包
var Groups = map[string]int{}
var GroupRWMutex sync.RWMutex
var OptionMap map[string]string
var OptionMapRWMutex sync.RWMutex

Expand Down Expand Up @@ -234,6 +238,8 @@ const (
ChannelTypeMokaAI = 44
ChannelTypeVolcEngine = 45
ChannelTypeBaiduV2 = 46
ChannelTypeXai = 47
ChannelTypeDoubaoOffline = 100
ChannelTypeDummy // this one is only for count, do not add any channel after this

)
Expand Down Expand Up @@ -286,4 +292,58 @@ var ChannelBaseURLs = []string{
"https://api.moka.ai", //44
"https://ark.cn-beijing.volces.com", //45
"https://qianfan.baidubce.com", //46
"", //47
"https://api.x.ai", //48
"", //49
"", //50
"", //51
"", //52
"", //53
"", //54
"", //55
"", //56
"", //57
"", //58
"", //59
"", //60
"", //61
"", //62
"", //63
"", //64
"", //65
"", //66
"", //67
"", //68
"", //69
"", //70
"", //71
"", //72
"", //73
"", //74
"", //75
"", //76
"", //77
"", //78
"", //79
"", //80
"", //81
"", //82
"", //83
"", //84
"", //85
"", //86
"", //87
"", //88
"", //89
"", //90
"", //91
"", //92
"", //93
"", //94
"", //95
"", //96
"", //97
"", //98
"", //99
"https://ark.cn-beijing.volces.com", //100 - 豆包离线
}
4 changes: 4 additions & 0 deletions common/init.go
Original file line number Diff line number Diff line change
Expand Up @@ -66,4 +66,8 @@ func LoadEnv() {
}
}
}

// Initialize mock response feature
MockResponseEnabled = os.Getenv("MOCK_RESPONSE_ENABLED") == "true"
SysLog(fmt.Sprintf("MockResponseEnabled: %v", MockResponseEnabled))
}
Loading