Merge remote-tracking branch 'github-pro/main' into feature/1.6-liujian

This commit is contained in:
Liujian
2025-03-13 14:16:37 +08:00
7 changed files with 83 additions and 129 deletions
-99
View File
@@ -1,99 +0,0 @@
variables:
PATH: /opt/go-1.21/go/bin/:/opt/node/node/bin/:/usr/local/sbin:/usr/local/bin:/usr/sbin:/usr/bin:/root/bin
GOROOT: /opt/go-1.21/go
GOPROXY: https://goproxy.cn
VERSION: $CI_COMMIT_SHORT_SHA
APP: apipark
APP_PRE: ${APP}_${VERSION}
BUILD_DIR: ${APP}-build
DEPLOY_DESC: "DEV 环境"
VIEW_ADDR: http://172.18.166.219:8288
SAVE_DIR: /opt/${APP}
NODE_OPTIONS: --max_old_space_size=8192
APIPARK_OLLAMA_BASE: http://127.0.0.1:11434
stages:
- notice
- prefix
- build
- deploy
- webhook
feishu-informer: # 飞书回调
stage: notice
variables:
DIFF_URL: "$CI_MERGE_REQUEST_PROJECT_URL/-/merge_requests/$CI_MERGE_REQUEST_IID/diffs"
rules:
- if: $CI_PIPELINE_SOURCE=="merge_request_event" && $CI_COMMIT_BRANCH =~ "main"
script:
- echo "merge request"
- |
curl -X POST -H "Content-Type: application/json" \
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"项目:${CI_PROJECT_NAME}\\n提交人:${GITLAB_USER_NAME}\\n提交信息:${CI_MERGE_REQUEST_TITLE}\\n合并分支信息:${CI_MERGE_REQUEST_SOURCE_BRANCH_NAME} -> ${CI_MERGE_REQUEST_TARGET_BRANCH_NAME}\\n差异性地址:${DIFF_URL}\\n请及时review代码\"}}" \
https://open.feishu.cn/open-apis/bot/v2/hook/1c334752-2874-41a1-8f1b-3060f2d46b6c
prebuild:
stage: prefix
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- echo "prebuild"
- chmod +x ./scripts/prefix.sh
- ./scripts/prefix.sh
builder:
stage: build
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- set -e
- |
if [ ! -d "../artifacts" ]; then
mkdir -p ../artifacts
fi
if [ -d "../artifacts/dist" ]; then
cp -r ../artifacts/dist frontend/dist
fi
- |
if [ -n "$(git diff --name-status HEAD~1 HEAD -- frontend)" ]; then
./scripts/build.sh $BUILD_DIR ${VERSION} all ""
else
./scripts/build.sh $BUILD_DIR ${VERSION}
fi
if [ -d "frontend/dist" ]; then
echo "copy frontend/dist to artifacts/dist"
rm -fr ../artifacts/dist
cp -r frontend/dist ../artifacts/dist
fi
cp $BUILD_DIR/${APP_PRE}_linux_amd64.tar.gz ${SAVE_DIR}
deployer:
stage: deploy
rules:
- if: $CI_COMMIT_BRANCH == "main"
variables:
APIPARK_GUEST_MODE: allow
APIPARK_GUEST_ID: dklejrfbhjqwdh
script:
- cd ${SAVE_DIR};mkdir -p ${APP_PRE};tar -zxvf ${APP_PRE}_linux_amd64.tar.gz -C ${APP_PRE};cd ${APP_PRE};./install.sh ${SAVE_DIR};./run.sh restart;cd ${SAVE_DIR} && ./clean.sh ${APP_PRE}
when: on_success
success:
stage: webhook
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- |
curl -X POST -H "Content-Type: application/json" \
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"最近一次提交:${CI_COMMIT_TITLE}\\n提交人:${GITLAB_USER_NAME}\\n项目:${CI_PROJECT_NAME}\\n环境:${DEPLOY_DESC}\\n更新部署完成.\\n访问地址:${VIEW_ADDR}\\n工作流地址:${CI_PIPELINE_URL}\"}}" \
https://open.feishu.cn/open-apis/bot/v2/hook/c3672932-4dfa-4989-8023-0128bae59338
when: on_success
failure:
stage: webhook
rules:
- if: $CI_COMMIT_BRANCH == "main"
script:
- |
curl -X POST -H "Content-Type: application/json" \
-d "{\"msg_type\":\"text\",\"content\":{\"text\":\"最近一次提交:${CI_COMMIT_TITLE}\\n提交人:${GITLAB_USER_NAME}\\n项目:${CI_PROJECT_NAME}\\n环境:${DEPLOY_DESC}\\n更新部署失败,请及时到gitlab上查看\\n工作流地址:${CI_PIPELINE_URL}\"}}" \
https://open.feishu.cn/open-apis/bot/v2/hook/c3672932-4dfa-4989-8023-0128bae59338
when: on_failure
@@ -20,6 +20,15 @@ configurate_methods:
- predefined-model
provider_credential_schema:
credential_form_schemas:
- variable: vertex_api_base
label:
zh_Hans: API Base
en_US: API Base
type: text-input
required: true
placeholder:
zh_Hans: 在此输入您的 API Base
en_US: Enter your API Base
- variable: vertex_project_id
label:
en_US: Project ID
@@ -36,12 +45,12 @@ provider_credential_schema:
en_US: Enter your Google Cloud Location
- variable: vertex_service_account_key
label:
en_US: Service Account Key (Leave blank if you use Application Default Credentials)
en_US: Enter your Google Cloud Service Account Key in base64 format
type: secret-input
required: false
required: true
placeholder:
en_US: Enter your Google Cloud Service Account Key in base64 format
address: https://api.openai.com
model_config:
access_configuration_status: true
access_configuration_demo: "{\"vertex_service_account_key\": \"\", \"vertex_location\": \"\", \"vertex_project_id\": \"\"}"
access_configuration_demo: "{\"vertex_location\": \"\", \"vertex_project_id\": \"\", \"vertex_model\":\"\"}"
@@ -1,5 +1,5 @@
import { App, Col, Form, Input, Row, Table, Tooltip } from 'antd'
import { forwardRef, useEffect, useImperativeHandle, useMemo } from 'react'
import { forwardRef, useEffect, useImperativeHandle, useMemo, useRef } from 'react'
import {
PublishApprovalInfoType,
PublishApprovalModalHandle,
@@ -36,6 +36,7 @@ export const PublishApprovalModalContent = forwardRef<PublishApprovalModalHandle
const [form] = Form.useForm()
const { fetchData } = useFetch()
const { state } = useGlobalContext()
const versionInputRef = useRef<Input>(null)
const save: (operate: 'pass' | 'refuse') => Promise<boolean | string> = (operate) => {
if (type === 'view') {
@@ -140,6 +141,12 @@ export const PublishApprovalModalContent = forwardRef<PublishApprovalModalHandle
useEffect(() => {
form.setFieldsValue({ opinion: '', ...data })
// 如果是添加模式且insidePage为true,自动聚焦版本号输入框
if (type === 'add' && insidePage && versionInputRef.current) {
setTimeout(() => {
versionInputRef.current?.focus()
}, 100)
}
}, [])
const translatedUpstreamColumns = useMemo(
@@ -335,7 +342,12 @@ export const PublishApprovalModalContent = forwardRef<PublishApprovalModalHandle
{insidePage && (
<>
<Form.Item label={$t('版本号')} name="version" rules={[{ required: true, whitespace: true }]}>
<Input className="w-INPUT_NORMAL" disabled={type !== 'add'} placeholder={$t(PLACEHOLDER.input)} />
<Input
className="w-INPUT_NORMAL"
disabled={type !== 'add'}
placeholder={$t(PLACEHOLDER.input)}
ref={versionInputRef}
/>
</Form.Item>
<Form.Item label={$t('版本说明')} name="versionRemark">
@@ -91,8 +91,15 @@ const AIProviderSelect: React.FC<AIProviderSelectProps> = ({ value, onChange, so
label: (
<Space className="flex items-center">
<span
className="flex items-center h-[20px] w-[20px]"
dangerouslySetInnerHTML={{ __html: provider.logo }}
className="flex items-center justify-center h-[20px] w-[20px] overflow-hidden"
style={{
display: 'flex',
alignItems: 'center',
justifyContent: 'center'
}}
dangerouslySetInnerHTML={{
__html: provider.logo.replace(/<svg/, '<svg style="max-width:100%;max-height:100%;width:auto;height:auto;"')
}}
></span>
<span>{provider.name}</span>
</Space>
@@ -10,7 +10,7 @@ import { DefaultOptionType } from 'antd/es/select'
import { forwardRef, useEffect, useImperativeHandle, useState } from 'react'
export type AiServiceRouterModelConfigHandle = {
save: () => Promise<{ id: string; config: string, type: string, provider: string }>
save: () => Promise<{ id: string; config: string; type: string; provider: string }>
}
export type AiServiceRouterModelConfigProps = {
@@ -49,7 +49,7 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
/**
* 获取本地模型列表
* @param setDefaultValue
* @param setDefaultValue
*/
const getLocalLlmList = (setDefaultValue?: boolean) => {
fetchData<LocalLlmType[]>('simple/ai/models/local/configured', {
@@ -113,12 +113,11 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
const { code, data, msg } = response
if (code === STATUS_CODE.SUCCESS) {
setProviderList(
data.providers
?.map((x: SimpleAiProviderItem) => {
return { ...x, label: x.name, value: x.id }
})
data.providers?.map((x: SimpleAiProviderItem) => {
return { ...x, label: x.name, value: x.id }
})
)
if (setDefaultValue && data.providers.length) {
if (setDefaultValue && data.providers.length) {
const id = data.providers[0].id
form.setFieldValue('provider', id)
getLlmList(id)
@@ -179,9 +178,14 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
rules={[{ required: true }]}
>
<Select
showSearch
className="w-INPUT_NORMAL"
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
placeholder={$t(PLACEHOLDER.select)}
options={providerList}
options={providerList.map((x) => ({
...x,
searchText: x.name.toLowerCase()
}))}
onChange={(e) => {
getLlmList(e)
}}
@@ -191,19 +195,20 @@ const AiServiceRouterModelConfig = forwardRef<AiServiceRouterModelConfigHandle,
<Form.Item<AiServiceRouterModelConfigField> label={$t('模型')} name="id" rules={[{ required: true }]}>
<Select
showSearch
className="w-INPUT_NORMAL"
placeholder={$t(PLACEHOLDER.select)}
options={
llmList?.map((x) => ({
value: x.id,
label: (
<div className="flex items-center gap-[10px]" key={x.id}>
<span>{x.name || x.id}</span>
{modelType === 'online' && x?.scopes?.map((s: any) => <Tag>{s?.toLocaleUpperCase()}</Tag>)}
</div>
)
}))
}
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
options={llmList?.map((x) => ({
value: x.id,
label: (
<div className="flex items-center gap-[10px]" key={x.id}>
<span>{x.name || x.id}</span>
{modelType === 'online' && x?.scopes?.map((s: any) => <Tag>{s?.toLocaleUpperCase()}</Tag>)}
</div>
),
searchText: x.name.toLowerCase()
}))}
onChange={(e) => {
form.setFieldValue('config', llmList.find((x) => x.id === e)?.config)
}}
@@ -182,7 +182,9 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
{modelType === 'online' && (
<Form.Item<LoadModelDetailData> label={$t('模型供应商')} name="provider" rules={[{ required: true }]}>
<Select
showSearch
className="w-INPUT_NORMAL"
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
placeholder={$t(PLACEHOLDER.select)}
loading={modelProviderLoading}
options={modelProviderData?.map((x) => ({
@@ -191,7 +193,8 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
<div className="flex items-center gap-[10px]">
<span>{x.name}</span>
</div>
)
),
searchText: x.name.toLowerCase()
}))}
onChange={(e) => {
modelProviderChange(e)
@@ -201,8 +204,10 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
)}
<Form.Item label={$t('模型')} name="model" className="mt-[16px]" rules={[{ required: true }]}>
<Select
showSearch
className="w-INPUT_NORMAL"
placeholder={$t(PLACEHOLDER.input)}
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
loading={llmListLoading}
options={
llmList?.map((x) => ({
@@ -212,7 +217,8 @@ const AddLoadBalancingModel = forwardRef<LoadBalancingHandle>((props, ref: any)
<span>{x.name || x.id}</span>
{ modelType === 'online' &&x?.scopes?.map((s: any) => <Tag key={s}>{s?.toLocaleUpperCase()}</Tag>)}
</div>
)
),
searchText: x.name.toLowerCase()
}))
}
onChange={(value) => {
@@ -450,9 +450,14 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
>
{providerOptionList && providerOptionList.length > 0 ? (
<Select
showSearch
className="w-INPUT_NORMAL"
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
placeholder={$t(PLACEHOLDER.input)}
options={providerOptionList}
options={providerOptionList.map((x) => ({
...x,
searchText: x.name.toLowerCase()
}))}
onChange={(e) => {
modelProviderChange(e)
}}
@@ -467,7 +472,16 @@ const SystemConfig = forwardRef<SystemConfigHandle>((_, ref) => {
)}
</Form.Item>
<Form.Item<AiServiceConfigFieldType> label={$t('默认模型')} name="model" rules={[{ required: true }]}>
<Select className="w-INPUT_NORMAL" placeholder={$t(PLACEHOLDER.input)} options={modelList}></Select>
<Select
showSearch
filterOption={(input, option) => (option?.searchText ?? '').includes(input.toLowerCase())}
className="w-INPUT_NORMAL"
placeholder={$t(PLACEHOLDER.input)}
options={modelList ? modelList.map((x) => ({
...x,
searchText: x.name.toLowerCase()
})) : []}
></Select>
</Form.Item>
</>
)}