Merge branch 'main' of github.com:maxkb-dev/maxkb
This commit is contained in:
commit
321cb29712
53
.github/workflows/build-and-push.yml
vendored
Normal file
53
.github/workflows/build-and-push.yml
vendored
Normal file
@ -0,0 +1,53 @@
|
|||||||
|
name: build-and-push
|
||||||
|
|
||||||
|
on:
|
||||||
|
workflow_dispatch:
|
||||||
|
inputs:
|
||||||
|
registryAddress:
|
||||||
|
description: 'Registry Address'
|
||||||
|
default: 'registry-hkproxy.fit2cloud.com'
|
||||||
|
required: true
|
||||||
|
dockerImageName:
|
||||||
|
description: 'Docker Image Name'
|
||||||
|
default: 'maxkb/maxkb'
|
||||||
|
required: true
|
||||||
|
dockerImageTag:
|
||||||
|
description: 'Docker Image Tag'
|
||||||
|
default: 'v1.0.0'
|
||||||
|
required: true
|
||||||
|
|
||||||
|
jobs:
|
||||||
|
build-and-push:
|
||||||
|
runs-on: ubuntu-latest
|
||||||
|
steps:
|
||||||
|
- name: Checkout
|
||||||
|
uses: actions/checkout@v2
|
||||||
|
- name: Prepare
|
||||||
|
id: prepare
|
||||||
|
run: |
|
||||||
|
DOCKER_IMAGE=${{ github.event.inputs.registryAddress }}/${{ github.event.inputs.dockerImageName }}
|
||||||
|
DOCKER_PLATFORMS=linux/amd64,linux/arm64
|
||||||
|
TAG_NAME=${{ github.event.inputs.dockerImageTag }}
|
||||||
|
DOCKER_IMAGE_TAGS="--tag ${DOCKER_IMAGE}:${TAG_NAME} --tag ${DOCKER_IMAGE}:latest"
|
||||||
|
echo ::set-output name=docker_image::${DOCKER_IMAGE}
|
||||||
|
echo ::set-output name=version::${TAG_NAME}
|
||||||
|
echo ::set-output name=buildx_args::--platform ${DOCKER_PLATFORMS} \
|
||||||
|
--build-arg VERSION=${TAG_NAME} \
|
||||||
|
--build-arg BUILD_DATE=$(date -u +'%Y-%m-%dT%H:%M:%SZ') \
|
||||||
|
--build-arg --no-cache \
|
||||||
|
--build-arg VCS_REF=${GITHUB_SHA::8} \
|
||||||
|
${DOCKER_IMAGE_TAGS} .
|
||||||
|
- name: Set up Docker Buildx
|
||||||
|
uses: crazy-max/ghaction-docker-buildx@v3
|
||||||
|
- name: Docker Buildx (build)
|
||||||
|
run: |
|
||||||
|
docker buildx build --output "type=image,push=false" ${{ steps.prepare.outputs.buildx_args }}
|
||||||
|
- name: Login to Registry
|
||||||
|
uses: docker/login-action@v1
|
||||||
|
with:
|
||||||
|
registry: ${{ github.event.inputs.registryAddress }}
|
||||||
|
username: ${{ secrets.FIT2CLOUD_REGISTRY_USERNAME }}
|
||||||
|
password: ${{ secrets.FIT2CLOUD_REGISTRY_PASSWORD }}
|
||||||
|
- name: Docker Buildx (push)
|
||||||
|
run: |
|
||||||
|
docker buildx build --output "type=image,push=true" ${{ steps.prepare.outputs.buildx_args }}
|
||||||
18
Dockerfile
18
Dockerfile
@ -1,3 +1,16 @@
|
|||||||
|
FROM python:3.11-slim as vector-model-build
|
||||||
|
COPY install_model.py install_model.py
|
||||||
|
RUN pip3 install --upgrade pip setuptools && \
|
||||||
|
pip install pycrawlers && \
|
||||||
|
pip install transformers && \
|
||||||
|
python3 install_model.py
|
||||||
|
|
||||||
|
FROM node:18-alpine3.18 as web-build
|
||||||
|
COPY ui ui
|
||||||
|
RUN cd ui && \
|
||||||
|
npm install && \
|
||||||
|
npm run build
|
||||||
|
|
||||||
FROM python:3.11-slim
|
FROM python:3.11-slim
|
||||||
|
|
||||||
ENV LANG=C.UTF-8
|
ENV LANG=C.UTF-8
|
||||||
@ -6,7 +19,10 @@ USER root
|
|||||||
# 创建工作目录
|
# 创建工作目录
|
||||||
RUN mkdir -p /opt/maxkb/app && mkdir -p /opt/maxkb/model
|
RUN mkdir -p /opt/maxkb/app && mkdir -p /opt/maxkb/model
|
||||||
# 拷贝项目
|
# 拷贝项目
|
||||||
|
RUN ls -la
|
||||||
COPY . /opt/maxkb/app
|
COPY . /opt/maxkb/app
|
||||||
|
COPY --from=vector-model-build model /opt/maxkb/app/model
|
||||||
|
COPY --from=web-build ui /opt/maxkb/app/ui
|
||||||
# 复制模型
|
# 复制模型
|
||||||
RUN mv /opt/maxkb/app/model/* /opt/maxkb/model
|
RUN mv /opt/maxkb/app/model/* /opt/maxkb/model
|
||||||
RUN ls /opt/maxkb/model
|
RUN ls /opt/maxkb/model
|
||||||
@ -22,7 +38,7 @@ RUN pip3 install poetry
|
|||||||
# 导出依赖
|
# 导出依赖
|
||||||
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
|
RUN poetry export -f requirements.txt --output requirements.txt --without-hashes
|
||||||
# 下载python依赖
|
# 下载python依赖
|
||||||
RUN pip3 install --no-cache-dir -r requirements.txt --trusted-host pypi.tuna.tsinghua.edu.cn
|
RUN pip3 install --no-cache-dir -r requirements.txt
|
||||||
# 删除前端依赖
|
# 删除前端依赖
|
||||||
RUN rm -rf ui/node_modules
|
RUN rm -rf ui/node_modules
|
||||||
# 启动命令
|
# 启动命令
|
||||||
|
|||||||
@ -14,7 +14,7 @@
|
|||||||
},
|
},
|
||||||
"dependencies": {
|
"dependencies": {
|
||||||
"axios": "^0.27.2",
|
"axios": "^0.27.2",
|
||||||
"element-plus": "^2.4.3",
|
"element-plus": "^2.5.3",
|
||||||
"install": "^0.13.0",
|
"install": "^0.13.0",
|
||||||
"lodash": "^4.17.21",
|
"lodash": "^4.17.21",
|
||||||
"markdown-it": "^13.0.2",
|
"markdown-it": "^13.0.2",
|
||||||
|
|||||||
@ -211,7 +211,7 @@ const prologueList = computed(() => {
|
|||||||
const temp = props.data?.prologue
|
const temp = props.data?.prologue
|
||||||
let arr: any = []
|
let arr: any = []
|
||||||
const lines = temp?.split('\n')
|
const lines = temp?.split('\n')
|
||||||
lines.forEach((str: string, index: number) => {
|
lines?.forEach((str: string, index: number) => {
|
||||||
if (isMdArray(str)) {
|
if (isMdArray(str)) {
|
||||||
arr[index] = {
|
arr[index] = {
|
||||||
type: 'question',
|
type: 'question',
|
||||||
@ -292,7 +292,8 @@ function getChartOpenId() {
|
|||||||
chatMessage()
|
chatMessage()
|
||||||
})
|
})
|
||||||
.catch((res) => {
|
.catch((res) => {
|
||||||
if (res.response.status === 401) {
|
console.log(res)
|
||||||
|
if (res.response.status === 403) {
|
||||||
application.asyncAppAuthentication(accessToken).then(() => {
|
application.asyncAppAuthentication(accessToken).then(() => {
|
||||||
getChartOpenId()
|
getChartOpenId()
|
||||||
})
|
})
|
||||||
@ -405,26 +406,33 @@ function chatMessage() {
|
|||||||
record_id: '',
|
record_id: '',
|
||||||
vote_status: '-1'
|
vote_status: '-1'
|
||||||
})
|
})
|
||||||
chatList.value.push(chat)
|
|
||||||
inputValue.value = ''
|
|
||||||
nextTick(() => {
|
|
||||||
// 将滚动条滚动到最下面
|
|
||||||
scrollDiv.value.setScrollTop(Number.MAX_SAFE_INTEGER)
|
|
||||||
})
|
|
||||||
// 对话
|
// 对话
|
||||||
applicationApi
|
applicationApi
|
||||||
.postChatMessage(chartOpenId.value, problem_text)
|
.postChatMessage(chartOpenId.value, problem_text)
|
||||||
.then((response) => {
|
.then((response) => {
|
||||||
ChatManagement.addChatRecord(chat, 50, loading)
|
console.log(response.status)
|
||||||
ChatManagement.write(chat.id)
|
if (response.status === 401) {
|
||||||
const reader = response.body.getReader()
|
application.asyncAppAuthentication(accessToken).then(() => {
|
||||||
// 处理流数据
|
chatMessage()
|
||||||
const write = getWrite(
|
})
|
||||||
chat,
|
} else {
|
||||||
reader,
|
chatList.value.push(chat)
|
||||||
response.headers.get('Content-Type') !== 'application/json'
|
inputValue.value = ''
|
||||||
)
|
nextTick(() => {
|
||||||
return reader.read().then(write)
|
// 将滚动条滚动到最下面
|
||||||
|
scrollDiv.value.setScrollTop(Number.MAX_SAFE_INTEGER)
|
||||||
|
})
|
||||||
|
ChatManagement.addChatRecord(chat, 50, loading)
|
||||||
|
ChatManagement.write(chat.id)
|
||||||
|
const reader = response.body.getReader()
|
||||||
|
// 处理流数据
|
||||||
|
const write = getWrite(
|
||||||
|
chat,
|
||||||
|
reader,
|
||||||
|
response.headers.get('Content-Type') !== 'application/json'
|
||||||
|
)
|
||||||
|
return reader.read().then(write)
|
||||||
|
}
|
||||||
})
|
})
|
||||||
.then(() => {
|
.then(() => {
|
||||||
return !props.appId && getSourceDetail(chat)
|
return !props.appId && getSourceDetail(chat)
|
||||||
|
|||||||
@ -2,15 +2,8 @@
|
|||||||
<div class="login-warp flex-center">
|
<div class="login-warp flex-center">
|
||||||
<div class="login-container w-full h-full">
|
<div class="login-container w-full h-full">
|
||||||
<el-row class="container w-full h-full">
|
<el-row class="container w-full h-full">
|
||||||
<el-col
|
<!-- v-if="screenWidth && screenWidth >= 990" -->
|
||||||
:xs="0"
|
<el-col :xs="0" :sm="0" :md="10" :lg="10" :xl="10" class="left-container">
|
||||||
:sm="0"
|
|
||||||
:md="10"
|
|
||||||
:lg="10"
|
|
||||||
:xl="10"
|
|
||||||
class="left-container"
|
|
||||||
v-if="screenWidth && screenWidth >= 990"
|
|
||||||
>
|
|
||||||
<div class="login-image"></div>
|
<div class="login-image"></div>
|
||||||
</el-col>
|
</el-col>
|
||||||
<el-col :xs="24" :sm="24" :md="14" :lg="14" :xl="14" class="right-container flex-center">
|
<el-col :xs="24" :sm="24" :md="14" :lg="14" :xl="14" class="right-container flex-center">
|
||||||
@ -21,18 +14,18 @@
|
|||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
<script setup lang="ts">
|
<script setup lang="ts">
|
||||||
import { ref, onMounted } from 'vue'
|
// import { ref, onMounted } from 'vue'
|
||||||
import type { Ref } from 'vue'
|
// import type { Ref } from 'vue'
|
||||||
defineOptions({ name: 'LoginLayout' })
|
defineOptions({ name: 'LoginLayout' })
|
||||||
const screenWidth: Ref<number | null> = ref(null)
|
// const screenWidth: Ref<number | null> = ref(null)
|
||||||
onMounted(() => {
|
// onMounted(() => {
|
||||||
screenWidth.value = document.body.clientWidth
|
// screenWidth.value = document.body.clientWidth
|
||||||
window.onresize = () => {
|
// window.onresize = () => {
|
||||||
return (() => {
|
// return (() => {
|
||||||
screenWidth.value = document.body.clientWidth
|
// screenWidth.value = document.body.clientWidth
|
||||||
})()
|
// })()
|
||||||
}
|
// }
|
||||||
})
|
// })
|
||||||
</script>
|
</script>
|
||||||
<style lang="scss" scope>
|
<style lang="scss" scope>
|
||||||
.login-warp {
|
.login-warp {
|
||||||
|
|||||||
Loading…
Reference in New Issue
Block a user