From 4b088e84c709c9c0dcbdd1c8eebbc01e0c034f4b Mon Sep 17 00:00:00 2001 From: archer <545436317@qq.com> Date: Fri, 25 Aug 2023 15:45:24 +0800 Subject: [PATCH] fix: ts --- .github/workflows/fastgpt-image.yml | 25 +++++++++++++++++++ client/src/constants/kb.ts | 4 +-- client/src/pages/api/openapi/kb/updateData.ts | 2 +- client/src/pages/api/plugins/kb/update.ts | 2 +- .../kb/detail/components/InputDataModal.tsx | 1 - client/src/service/utils/tools.ts | 4 +-- 6 files changed, 30 insertions(+), 8 deletions(-) diff --git a/.github/workflows/fastgpt-image.yml b/.github/workflows/fastgpt-image.yml index fe6393751..97d5c12b5 100644 --- a/.github/workflows/fastgpt-image.yml +++ b/.github/workflows/fastgpt-image.yml @@ -77,3 +77,28 @@ jobs: run: docker tag ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}} ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}} - name: Push image to Docker Hub run: docker push ${{ secrets.DOCKER_IMAGE_NAME }}:${{env.IMAGE_TAG}} + push-to-ali-hub: + needs: build-fastgpt-images + runs-on: ubuntu-20.04 + steps: + - name: Checkout code + uses: actions/checkout@v3 + - name: Login to Ali Hub + uses: docker/login-action@v2 + with: + registry: registry.cn-hangzhou.aliyuncs.com + username: ${{ secrets.ALI_HUB_USERNAME }} + password: ${{ secrets.ALI_HUB_PASSWORD }} + - name: Set DOCKER_REPO_TAGGED based on branch or tag + run: | + if [[ "${{ github.ref_name }}" == "main" ]]; then + echo "IMAGE_TAG=latest" >> $GITHUB_ENV + else + echo "IMAGE_TAG=${{ github.ref_name }}" >> $GITHUB_ENV + fi + - name: Pull image from GitHub Container Registry + run: docker pull ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}} + - name: Tag image with Docker Hub repository name and version tag + run: docker tag ghcr.io/${{ github.repository_owner }}/fastgpt:${{env.IMAGE_TAG}} ${{ secrets.ALI_IMAGE_NAME }}:${{env.IMAGE_TAG}} + - name: Push image to Docker Hub + run: docker push ${{ secrets.ALI_IMAGE_NAME }}:${{env.IMAGE_TAG}} diff --git a/client/src/constants/kb.ts b/client/src/constants/kb.ts index 714e92b20..e60650fca 100644 --- a/client/src/constants/kb.ts +++ b/client/src/constants/kb.ts @@ -3,10 +3,8 @@ import type { KbItemType } from '@/types/plugin'; export const defaultKbDetail: KbItemType = { _id: '', userId: '', - updateTime: new Date(), avatar: '/icon/logo.svg', name: '', tags: '', - totalData: 0, - model: 'text-embedding-ada-002' + vectorModelName: 'text-embedding-ada-002' }; diff --git a/client/src/pages/api/openapi/kb/updateData.ts b/client/src/pages/api/openapi/kb/updateData.ts index 1c6043330..fec5683c1 100644 --- a/client/src/pages/api/openapi/kb/updateData.ts +++ b/client/src/pages/api/openapi/kb/updateData.ts @@ -40,7 +40,7 @@ export default withNextCors(async function handler(req: NextApiRequest, res: Nex return getVector({ userId, input: [q], - model: kb.model + model: kb.vectorModel }); } return { vectors: [[]] }; diff --git a/client/src/pages/api/plugins/kb/update.ts b/client/src/pages/api/plugins/kb/update.ts index cdd19f336..f67764e35 100644 --- a/client/src/pages/api/plugins/kb/update.ts +++ b/client/src/pages/api/plugins/kb/update.ts @@ -2,7 +2,7 @@ import type { NextApiRequest, NextApiResponse } from 'next'; import { jsonRes } from '@/service/response'; import { connectToDatabase, KB } from '@/service/mongo'; import { authUser } from '@/service/utils/auth'; -import type { KbUpdateParams } from '@/api/plugins/kb'; +import type { KbUpdateParams } from '@/api/request/kb'; export default async function handler(req: NextApiRequest, res: NextApiResponse) { try { diff --git a/client/src/pages/kb/detail/components/InputDataModal.tsx b/client/src/pages/kb/detail/components/InputDataModal.tsx index 06c2a0589..74fabc4c8 100644 --- a/client/src/pages/kb/detail/components/InputDataModal.tsx +++ b/client/src/pages/kb/detail/components/InputDataModal.tsx @@ -56,7 +56,6 @@ const InputDataModal = ({ }; const { insertLen } = await postKbDataFromList({ kbId, - model: vectorModelList[0].model, mode: TrainingModeEnum.index, data: [data] }); diff --git a/client/src/service/utils/tools.ts b/client/src/service/utils/tools.ts index 5f2240912..423b9a911 100644 --- a/client/src/service/utils/tools.ts +++ b/client/src/service/utils/tools.ts @@ -92,9 +92,9 @@ export const sseResponse = ({ /* add logger */ export const addLog = { info: (msg: string, obj?: Record) => { - global.logger.info(msg, { meta: obj }); + global.logger?.info(msg, { meta: obj }); }, error: (msg: string, obj?: Record) => { - global.logger.error(msg, { meta: obj }); + global.logger?.error(msg, { meta: obj }); } };