Merge branch 'helm-chart-release' into helm-chart

pull/1337/head
zhangxinhui02 2025-10-31 10:12:43 +08:00
commit fbd4b71ad5
No known key found for this signature in database
GPG Key ID: 22C23383864A313F
32 changed files with 1516 additions and 0 deletions

View File

@ -0,0 +1,70 @@
stages:
- initialize-maibot-git-repo
- build
- package
# 查询并将麦麦仓库的工作区置为最后一个tag的版本
initialize-maibot-git-repo:
stage: initialize-maibot-git-repo
image: reg.mikumikumi.xyz/base/git:latest
cache:
key: git-repo
policy: push
paths:
- target-repo/
script:
- git clone https://github.com/MaiM-with-u/MaiBot.git target-repo/
- cd target-repo/
- export MAIBOT_VERSION=$(git describe --tags --abbrev=0)
- echo "Current version is ${MAIBOT_VERSION}"
- git reset --hard ${MAIBOT_VERSION}
- echo ${MAIBOT_VERSION} > MAIBOT_VERSION
- git clone https://github.com/MaiM-with-u/maim_message maim_message
- git clone https://github.com/MaiM-with-u/MaiMBot-LPMM.git MaiMBot-LPMM
- ls -al
# 构建最后一个tag的麦麦本体的镜像
build-core:
stage: build
image: reg.mikumikumi.xyz/base/kaniko-builder:latest
cache:
key: git-repo
policy: pull
paths:
- target-repo/
script:
- cd target-repo/
- export BUILD_CONTEXT=$(pwd)
- ls -al
- export BUILD_DESTINATION="reg.mikumikumi.xyz/maibot/maibot:tag-$(cat MAIBOT_VERSION)"
- build
# 将Helm Chart版本作为tag构建并推送镜像
build-adapter-cm-generator:
stage: build
image: reg.mikumikumi.xyz/base/kaniko-builder:latest
rules:
- changes:
- helm-chart/adapter-cm-generator/**
script:
- export BUILD_CONTEXT=helm-chart/adapter-cm-generator
- export TMP_DST=reg.mikumikumi.xyz/maibot/adapter-cm-generator
- export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep '^version:' | cut -d' ' -f2)
- export BUILD_ARGS="--destination ${TMP_DST}:${CHART_VERSION} --destination ${TMP_DST}:latest"
- build
# 打包并推送helm chart
package-helm-chart:
stage: package
image: reg.mikumikumi.xyz/mirror/helm:latest
rules:
- changes:
- helm-chart/files/**
- helm-chart/templates/**
- helm-chart/Chart.yaml
- helm-chart/values.yaml
script:
- export CHART_VERSION=$(cat helm-chart/Chart.yaml | grep '^version:' | cut -d' ' -f2)
- helm registry login reg.mikumikumi.xyz --username ${CI_REGISTRY_USER} --password ${CI_REGISTRY_PASSWORD}
- helm package helm-chart
- helm push maibot-${CHART_VERSION}.tgz oci://reg.mikumikumi.xyz/maibot

View File

@ -0,0 +1,2 @@
adapter-cm-generator
.gitlab-ci.yml

View File

@ -0,0 +1,6 @@
apiVersion: v2
name: maibot
description: "Maimai Bot, a cyber friend dedicated to group chats"
type: application
version: 0.10.3-beta
appVersion: 0.10.3-beta

View File

@ -0,0 +1,87 @@
# MaiBot Helm Chart
这是麦麦的Helm Chart可以方便地将麦麦部署在Kubernetes集群中。
当前Helm Chart对应的麦麦版本可以在`Chart.yaml`中查看`appVersion`项。
## 可用的Helm Chart版本列表
| Helm Chart版本 | 对应的MaiBot版本 |
|----------------|--------------|
| 0.10.3-beta | 0.10.3-beta |
| 0.10.0-alpha.0 | 0.10.0-alpha |
## Values项说明
`values.yaml`分为几个大部分。
1. EULA & PRIVACY: 用户必须同意这里的协议才能成功部署麦麦。
2. `adapter`: 麦麦的Adapter的部署配置。
3. `core`: 麦麦本体的部署配置。
4. `statistics_dashboard`: 麦麦的运行统计看板部署配置。
麦麦每隔一段时间会自动输出html格式的运行统计报告此统计报告可以部署为看板。
出于隐私考虑,默认禁用。
5. `napcat`: Napcat的部署配置。
考虑到复用外部Napcat实例的情况Napcat部署已被解耦。用户可选是否要部署Napcat。
默认会捆绑部署Napcat。
6. `sqlite_web`: sqlite-web的部署配置。
通过sqlite-web可以在网页上操作麦麦的数据库方便调试。不部署对麦麦的运行无影响。
此服务如果暴露在公网会十分危险,默认不会部署。
7. `config`: 这里填写麦麦各部分组件的运行配置文件。
这里填写的配置文件需要严格遵守yaml文件的缩进格式。
- `adapter_config`: 对应adapter的`config.toml`。
此配置文件中对于`host`和`port`的配置会被上面`adapter.service`中的配置覆盖,因此不需要改动。
- `core_model_config`: 对应core的`model_config.toml`。
- `core_bot_config`: 对应core的`bot_config.toml`。
## 部署说明
使用此Helm Chart的一些注意事项。
### 修改麦麦配置
麦麦的配置文件会通过ConfigMap资源注入各个组件内。
对于通过Helm Chart部署的麦麦如果需要修改配置不应该直接修改这些ConfigMap否则下次Helm更新可能会覆盖掉所有配置。
最佳实践是重新配置Helm Chart的values然后通过`helm upgrade`更新实例。
### 动态生成的ConfigMap
adapter的ConfigMap是每次部署/更新Helm安装实例时动态生成的。
动态生成的原因:
- core服务的DNS名称是动态的无法在adapter服务的配置文件中提前确定。
- 一些与k8s现有资源冲突的配置需要被重置。
因此首次部署时ConfigMap的生成会需要一些时间部分Pod会无法启动等待几分钟即可。
### 运行统计看板与core的挂载冲突
如果启用了运行统计看板那么statistics_dashboard会与core共同挂载statistics_dashboard存储卷用于同步html文件。
如果k8s集群有多个节点且statistics_dashboard与core未调度到同一节点那么就需要statistics_dashboard的PVC访问模式具备`ReadWriteMany`访问模式。
不是所有存储卷的底层存储都支持`ReadWriteMany`访问模式。
如果你的存储底层无法支持`ReadWriteMany`访问模式,你可以通过`nodeSelector`配置将statistics_dashboard与core调度到同一节点来避免问题。
*如果启用了`sqlite-web`,那么上述问题也同样适用于`sqlite-web`与`core`,需要注意。*

View File

@ -0,0 +1,10 @@
# 此镜像用于在部署helm chart时动态生成adapter的配置文件
FROM python:3.11-slim
WORKDIR /app
COPY . /app
RUN pip3 install --no-cache-dir -i https://mirrors.ustc.edu.cn/pypi/simple -r requirements.txt
ENTRYPOINT ["python3", "adapter-cm-generator.py"]

View File

@ -0,0 +1,43 @@
#!/bin/python3
# 这个脚本的作用是在部署helm chart时动态生成adapter的配置文件保存在configmap中
# 需要动态生成的原因是core服务的DNS名称是动态的无法在adapter服务的配置文件中提前确定
# 一些与k8s现有资源冲突的配置也会在这里重置
import os
import toml
import base64
from kubernetes import client, config
config.load_incluster_config()
v1 = client.CoreV1Api()
# 读取部署的关键信息
namespace = os.getenv("NAMESPACE")
release_name = os.getenv("RELEASE_NAME")
data_b64 = os.getenv("DATA_B64")
# 解析并覆盖关键配置
# 这里被覆盖的配置应当在helm chart中针对对应的k8s资源来灵活修改
data = toml.loads(base64.b64decode(data_b64).decode("utf-8"))
data.setdefault('napcat_server', {})
data['napcat_server']['host'] = '0.0.0.0'
data['napcat_server']['port'] = 8095
data.setdefault('maibot_server', {})
data['maibot_server']['host'] = f'{release_name}-maibot-core' # 根据release名称动态拼接core服务的DNS名称
data['maibot_server']['port'] = 8000
# 创建/修改configmap
cm_name = f'{release_name}-maibot-adapter'
cm = client.V1ConfigMap(
metadata=client.V1ObjectMeta(name=cm_name),
data={'config.toml': toml.dumps(data)}
)
try:
v1.create_namespaced_config_map(namespace, cm)
print(f"ConfigMap `{cm_name}` created successfully")
except client.exceptions.ApiException as e:
if e.status == 409: # 已存在,更新
v1.replace_namespaced_config_map(cm_name, namespace, cm)
print(f"ConfigMap `{cm_name}` replaced successfully")
else:
raise

View File

@ -0,0 +1,2 @@
toml~=0.10.2
kubernetes~=33.1.0

View File

@ -0,0 +1,33 @@
#!/bin/sh
# 此脚本用于覆盖core容器的默认启动命令
# 由于k8s与docker-compose的卷挂载方式有所不同需要利用此脚本为一些文件和目录提前创建好软链接
# /MaiMBot/data是麦麦数据的实际挂载路径
# /MaiMBot/statistics是统计数据的实际挂载路径
set -e
echo "[VolumeLinker]Preparing volume..."
# 初次启动,在存储卷中检查并创建关键文件和目录
mkdir -p /MaiMBot/data/plugins
mkdir -p /MaiMBot/data/logs
if [ ! -d "/MaiMBot/statistics" ]
then
echo "[VolumeLinker] Statistics volume disabled."
else
touch /MaiMBot/statistics/index.html
fi
# 删除空的插件目录,准备创建软链接
rm -rf /MaiMBot/plugins
# 创建软链接,从存储卷链接到实际位置
ln -s /MaiMBot/data/plugins /MaiMBot/plugins
ln -s /MaiMBot/data/logs /MaiMBot/logs
if [ -f "/MaiMBot/statistics/index.html" ]
then
ln -s /MaiMBot/statistics/index.html /MaiMBot/maibot_statistics.html
fi
# 启动麦麦
echo "[VolumeLinker]Starting MaiBot..."
exec python bot.py

View File

@ -0,0 +1,3 @@
MaiBot has been successfully deployed.
MaiBot on GitHub: https://github.com/MaiM-with-u/MaiBot

View File

@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-maibot-adapter
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.adapter.persistence.accessModes }}
accessModes:
{{ toYaml .Values.adapter.persistence.accessModes | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ .Values.adapter.persistence.size }}
{{- if .Values.adapter.persistence.storageClass }}
storageClassName: {{ .Values.adapter.persistence.storageClass | default nil }}
{{- end }}

View File

@ -0,0 +1,19 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-maibot-adapter
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-adapter
spec:
ports:
- name: napcat-ws
port: {{ .Values.adapter.service.port }}
protocol: TCP
targetPort: 8095
{{- if eq .Values.adapter.service.type "NodePort" }}
nodePort: {{ .Values.adapter.service.nodePort | default nil }}
{{- end }}
selector:
app: {{ .Release.Name }}-maibot-adapter
type: {{ .Values.adapter.service.type }}

View File

@ -0,0 +1,62 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-maibot-adapter
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-adapter
spec:
serviceName: {{ .Release.Name }}-maibot-adapter
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}-maibot-adapter
template:
metadata:
labels:
app: {{ .Release.Name }}-maibot-adapter
spec:
containers:
- name: adapter
env:
- name: TZ
value: Asia/Shanghai
image: {{ .Values.adapter.image.repository | default "unclas/maimbot-adapter" }}:{{ .Values.adapter.image.tag | default "main-20250922131146" }}
imagePullPolicy: {{ .Values.adapter.image.pullPolicy }}
ports:
- containerPort: 8095
name: napcat-ws
protocol: TCP
{{- if .Values.adapter.resources }}
resources:
{{ toYaml .Values.adapter.resources | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /adapters/data
name: data
- mountPath: /adapters/config.toml
name: config
readOnly: true
subPath: config.toml
{{- if .Values.adapter.image.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.adapter.image.pullSecrets | nindent 8 }}
{{- end }}
{{- if .Values.adapter.nodeSelector }}
nodeSelector:
{{ toYaml .Values.adapter.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.adapter.tolerations }}
tolerations:
{{ toYaml .Values.adapter.tolerations | nindent 8 }}
{{- end }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-adapter
- configMap:
items:
- key: config.toml
path: config.toml
name: {{ .Release.Name }}-maibot-adapter
name: config

View File

@ -0,0 +1,13 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-maibot-core
namespace: {{ .Release.Namespace }}
data:
.env: |
HOST=0.0.0.0
PORT=8000
model_config.toml: |
{{ .Values.config.core_model_config | nindent 4 }}
bot_config.toml: |
{{ .Values.config.core_bot_config | nindent 4 }}

View File

@ -0,0 +1,16 @@
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-maibot-core
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.core.persistence.accessModes }}
accessModes:
{{ toYaml .Values.core.persistence.accessModes | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ .Values.core.persistence.size }}
{{- if .Values.core.persistence.storageClass }}
storageClassName: {{ .Values.core.persistence.storageClass | default nil }}
{{- end }}

View File

@ -0,0 +1,16 @@
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-maibot-core
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-core
spec:
ports:
- name: adapter-ws
port: 8000
protocol: TCP
targetPort: 8000
selector:
app: {{ .Release.Name }}-maibot-core
type: ClusterIP

View File

@ -0,0 +1,101 @@
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-maibot-core
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-core
spec:
serviceName: {{ .Release.Name }}-maibot-core
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}-maibot-core
template:
metadata:
labels:
app: {{ .Release.Name }}-maibot-core
spec:
containers:
- name: core
command: # 为了在k8s中初始化存储卷这里替换启动命令为指定脚本
- sh
args:
- /MaiMBot/volume-linker.sh
env:
- name: TZ
value: Asia/Shanghai
- name: EULA_AGREE
value: 99f08e0cab0190de853cb6af7d64d4de
- name: PRIVACY_AGREE
value: 9943b855e72199d0f5016ea39052f1b6
image: {{ .Values.core.image.repository | default "reg.mikumikumi.xyz/maibot/maibot" }}:{{ .Values.core.image.tag | default "tag-0.10.3-beta" }}
imagePullPolicy: {{ .Values.core.image.pullPolicy }}
ports:
- containerPort: 8000
name: adapter-ws
protocol: TCP
{{- if .Values.core.resources }}
resources:
{{ toYaml .Values.core.resources | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /MaiMBot/data
name: data
- mountPath: /MaiMBot/volume-linker.sh
name: scripts
readOnly: true
subPath: volume-linker.sh
- mountPath: /MaiMBot/.env
name: config
readOnly: true
subPath: .env
- mountPath: /MaiMBot/config/model_config.toml
name: config
readOnly: true
subPath: model_config.toml
- mountPath: /MaiMBot/config/bot_config.toml
name: config
readOnly: true
subPath: bot_config.toml
{{- if .Values.statistics_dashboard.enabled }}
- mountPath: /MaiMBot/statistics
name: statistics
{{- end }}
{{- if .Values.core.image.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.core.image.pullSecrets | nindent 8 }}
{{- end }}
{{- if .Values.core.nodeSelector }}
nodeSelector:
{{ toYaml .Values.core.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.core.tolerations }}
tolerations:
{{ toYaml .Values.core.tolerations | nindent 8 }}
{{- end }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-core
- configMap:
items:
- key: volume-linker.sh
path: volume-linker.sh
name: {{ .Release.Name }}-maibot-scripts
name: scripts
- configMap:
items:
- key: .env
path: .env
- key: model_config.toml
path: model_config.toml
- key: bot_config.toml
path: bot_config.toml
name: {{ .Release.Name }}-maibot-core
name: config
{{- if .Values.statistics_dashboard.enabled }}
- name: statistics
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-statistics-dashboard
{{- end }}

View File

@ -0,0 +1,26 @@
{{- if and .Values.napcat.enabled .Values.napcat.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}-maibot-napcat
namespace: {{ .Release.Namespace }}
{{- if .Values.napcat.ingress.annotations }}
annotations:
{{ toYaml .Values.napcat.ingress.annotations | nindent 4 }}
{{- end }}
labels:
app: {{ .Release.Name }}-maibot-napcat
spec:
ingressClassName: {{ .Values.napcat.ingress.className }}
rules:
- host: {{ .Values.napcat.ingress.host }}
http:
paths:
- backend:
service:
name: {{ .Release.Name }}-maibot-napcat
port:
number: {{ .Values.napcat.service.port }}
path: {{ .Values.napcat.ingress.path }}
pathType: {{ .Values.napcat.ingress.pathType }}
{{- end }}

View File

@ -0,0 +1,18 @@
{{- if .Values.napcat.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-maibot-napcat
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.napcat.persistence.accessModes }}
accessModes:
{{ toYaml .Values.napcat.persistence.accessModes | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ .Values.napcat.persistence.size }}
{{- if .Values.napcat.persistence.storageClass }}
storageClassName: {{ .Values.napcat.persistence.storageClass | default nil }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,21 @@
{{- if .Values.napcat.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-maibot-napcat
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-napcat
spec:
ports:
- name: webui
port: {{ .Values.napcat.service.port }}
protocol: TCP
targetPort: 6099
{{- if eq .Values.napcat.service.type "NodePort" }}
nodePort: {{ .Values.napcat.service.nodePort | default nil }}
{{- end }}
selector:
app: {{ .Release.Name }}-maibot-napcat
type: {{ .Values.napcat.service.type }}
{{- end }}

View File

@ -0,0 +1,72 @@
{{- if .Values.napcat.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-maibot-napcat
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-napcat
spec:
serviceName: {{ .Release.Name }}-maibot-napcat
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}-maibot-napcat
template:
metadata:
labels:
app: {{ .Release.Name }}-maibot-napcat
spec:
containers:
- name: napcat
env:
- name: NAPCAT_GID
value: "{{ .Values.napcat.permission.gid }}"
- name: NAPCAT_UID
value: "{{ .Values.napcat.permission.uid }}"
- name: TZ
value: Asia/Shanghai
image: {{ .Values.napcat.image.repository | default "mlikiowa/napcat-docker" }}:{{ .Values.napcat.image.tag | default "v4.8.116" }}
imagePullPolicy: {{ .Values.napcat.image.pullPolicy }}
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 6099
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 60
successThreshold: 1
timeoutSeconds: 10
ports:
- containerPort: 6099
name: webui
protocol: TCP
{{- if .Values.napcat.resources }}
resources:
{{ toYaml .Values.napcat.resources | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /app/napcat/config
name: napcat
subPath: config
- mountPath: /app/.config/QQ
name: napcat
subPath: data
{{- if .Values.napcat.image.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.napcat.image.pullSecrets | nindent 8 }}
{{- end }}
{{- if .Values.napcat.nodeSelector }}
nodeSelector:
{{ toYaml .Values.napcat.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.napcat.tolerations }}
tolerations:
{{ toYaml .Values.napcat.tolerations | nindent 8 }}
{{- end }}
volumes:
- name: napcat
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-napcat
{{- end }}

View File

@ -0,0 +1,30 @@
# 动态生成adapter配置文件的configmap的job仅会在部署时运行一次
apiVersion: batch/v1
kind: Job
metadata:
name: {{ .Release.Name }}-maibot-adapter-cm-generator
namespace: {{ .Release.Namespace }}
annotations:
"helm.sh/hook": post-install,post-upgrade
"helm.sh/hook-delete-policy": before-hook-creation,hook-succeeded
spec:
backoffLimit: 2
template:
spec:
serviceAccountName: {{ .Release.Name }}-maibot-adapter-cm-generator
restartPolicy: Never
containers:
- name: adapter-cm-generator
image: {{ .Values.adapter.cm_generator.image.repository | default "reg.mikumikumi.xyz/maibot/adapter-cm-generator" }}:{{ .Values.adapter.cm_generator.image.tag | default "0.10.3-beta" }}
workingDir: /app
env:
- name: PYTHONUNBUFFERED
value: "1"
- name: NAMESPACE
valueFrom:
fieldRef:
fieldPath: metadata.namespace
- name: RELEASE_NAME
value: {{ .Release.Name }}
- name: DATA_B64
value: {{ .Values.config.adapter_config | b64enc }} # 将配置文件编码为base64从环境变量注入

View File

@ -0,0 +1,30 @@
# 动态生成adapter配置文件的configmap所需要的rbac授权
apiVersion: v1
kind: ServiceAccount
metadata:
name: {{ .Release.Name }}-maibot-adapter-cm-generator
namespace: {{ .Release.Namespace }}
---
apiVersion: rbac.authorization.k8s.io/v1
kind: Role
metadata:
name: {{ .Release.Name }}-maibot-adapter-cm-gen-role
namespace: {{ .Release.Namespace }}
rules:
- apiGroups: [""]
resources: ["configmaps"]
verbs: ["get", "list", "create", "update", "patch"]
---
apiVersion: rbac.authorization.k8s.io/v1
kind: RoleBinding
metadata:
name: {{ .Release.Name }}-maibot-adapter-cm-gen-role-binding
namespace: {{ .Release.Namespace }}
subjects:
- kind: ServiceAccount
name: {{ .Release.Name }}-maibot-adapter-cm-generator
namespace: {{ .Release.Namespace }}
roleRef:
kind: Role
name: {{ .Release.Name }}-maibot-adapter-cm-gen-role
apiGroup: rbac.authorization.k8s.io

View File

@ -0,0 +1,8 @@
# 检查EULA和PRIVACY
{{- if not .Values.EULA_AGREE }}
{{- fail "You must accept the EULA by setting 'EULA_AGREE: true'. EULA: https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md" }}
{{- end }}
{{- if not .Values.PRIVACY_AGREE }}
{{- fail "You must accept the Privacy Policy by setting 'PRIVACY_AGREE: true'. Privacy Policy: https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md" }}
{{- end }}

View File

@ -0,0 +1,9 @@
apiVersion: v1
kind: ConfigMap
metadata:
name: {{ .Release.Name }}-maibot-scripts
namespace: {{ .Release.Namespace }}
data:
# core
volume-linker.sh: |
{{ .Files.Get "files/volume-linker.sh" | nindent 4 }}

View File

@ -0,0 +1,26 @@
{{- if and .Values.sqlite_web.enabled .Values.sqlite_web.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}-maibot-sqlite-web
namespace: {{ .Release.Namespace }}
{{- if .Values.sqlite_web.ingress.annotations }}
annotations:
{{ toYaml .Values.sqlite_web.ingress.annotations | nindent 4 }}
{{- end }}
labels:
app: {{ .Release.Name }}-maibot-sqlite-web
spec:
ingressClassName: {{ .Values.sqlite_web.ingress.className }}
rules:
- host: {{ .Values.sqlite_web.ingress.host }}
http:
paths:
- backend:
service:
name: {{ .Release.Name }}-maibot-sqlite-web
port:
number: {{ .Values.sqlite_web.service.port }}
path: {{ .Values.sqlite_web.ingress.path }}
pathType: {{ .Values.sqlite_web.ingress.pathType }}
{{- end }}

View File

@ -0,0 +1,21 @@
{{- if .Values.sqlite_web.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-maibot-sqlite-web
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-sqlite-web
spec:
ports:
- name: webui
port: {{ .Values.sqlite_web.service.port }}
protocol: TCP
targetPort: 8080
{{- if eq .Values.sqlite_web.service.type "NodePort" }}
nodePort: {{ .Values.sqlite_web.service.nodePort | default nil }}
{{- end }}
selector:
app: {{ .Release.Name }}-maibot-sqlite-web
type: {{ .Values.sqlite_web.service.type }}
{{- end }}

View File

@ -0,0 +1,64 @@
{{- if .Values.sqlite_web.enabled }}
apiVersion: apps/v1
kind: StatefulSet
metadata:
name: {{ .Release.Name }}-maibot-sqlite-web
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-sqlite-web
spec:
serviceName: {{ .Release.Name }}-maibot-sqlite-web
replicas: 1
selector:
matchLabels:
app: {{ .Release.Name }}-maibot-sqlite-web
template:
metadata:
labels:
app: {{ .Release.Name }}-maibot-sqlite-web
spec:
containers:
- name: sqlite-web
env:
- name: SQLITE_DATABASE
value: /data/MaiMBot/MaiBot.db
image: {{ .Values.sqlite_web.image.repository | default "coleifer/sqlite-web" }}:{{ .Values.sqlite_web.image.tag | default "latest" }}
imagePullPolicy: {{ .Values.sqlite_web.image.pullPolicy }}
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 8080
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 60
successThreshold: 1
timeoutSeconds: 10
ports:
- containerPort: 8080
name: webui
protocol: TCP
{{- if .Values.sqlite_web.resources }}
resources:
{{ toYaml .Values.sqlite_web.resources | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /data/MaiMBot
name: data
{{- if .Values.sqlite_web.image.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.sqlite_web.image.pullSecrets | nindent 8 }}
{{- end }}
{{- if .Values.sqlite_web.nodeSelector }}
nodeSelector:
{{ toYaml .Values.sqlite_web.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.sqlite_web.tolerations }}
tolerations:
{{ toYaml .Values.sqlite_web.tolerations | nindent 8 }}
{{- end }}
volumes:
- name: data
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-core
{{- end }}

View File

@ -0,0 +1,61 @@
{{- if .Values.statistics_dashboard.enabled }}
apiVersion: apps/v1
kind: Deployment
metadata:
name: {{ .Release.Name }}-maibot-statistics-dashboard
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-statistics-dashboard
spec:
replicas: {{ .Values.statistics_dashboard.replicaCount }}
selector:
matchLabels:
app: {{ .Release.Name }}-maibot-statistics-dashboard
template:
metadata:
labels:
app: {{ .Release.Name }}-maibot-statistics-dashboard
spec:
containers:
- name: nginx
image: {{ .Values.statistics_dashboard.image.repository | default "nginx" }}:{{ .Values.statistics_dashboard.image.tag | default "latest" }}
imagePullPolicy: {{ .Values.statistics_dashboard.image.pullPolicy }}
livenessProbe:
failureThreshold: 3
httpGet:
path: /
port: 80
scheme: HTTP
initialDelaySeconds: 60
periodSeconds: 10
successThreshold: 1
timeoutSeconds: 1
ports:
- containerPort: 80
name: dashboard
protocol: TCP
{{- if .Values.statistics_dashboard.resources }}
resources:
{{ toYaml .Values.statistics_dashboard.resources | nindent 12 }}
{{- end }}
volumeMounts:
- mountPath: /usr/share/nginx/html
name: statistics
readOnly: true
{{- if .Values.statistics_dashboard.image.pullSecrets }}
imagePullSecrets:
{{ toYaml .Values.statistics_dashboard.image.pullSecrets | nindent 8 }}
{{- end }}
{{- if .Values.statistics_dashboard.nodeSelector }}
nodeSelector:
{{ toYaml .Values.statistics_dashboard.nodeSelector | nindent 8 }}
{{- end }}
{{- if .Values.statistics_dashboard.tolerations }}
tolerations:
{{ toYaml .Values.statistics_dashboard.tolerations | nindent 8 }}
{{- end }}
volumes:
- name: statistics
persistentVolumeClaim:
claimName: {{ .Release.Name }}-maibot-statistics-dashboard
{{- end }}

View File

@ -0,0 +1,26 @@
{{- if and .Values.statistics_dashboard.enabled .Values.statistics_dashboard.ingress.enabled }}
apiVersion: networking.k8s.io/v1
kind: Ingress
metadata:
name: {{ .Release.Name }}-maibot-statistics-dashboard
namespace: {{ .Release.Namespace }}
{{- if .Values.statistics_dashboard.ingress.annotations }}
annotations:
{{ toYaml .Values.statistics_dashboard.ingress.annotations | nindent 4 }}
{{- end }}
labels:
app: {{ .Release.Name }}-maibot-statistics-dashboard
spec:
ingressClassName: {{ .Values.statistics_dashboard.ingress.className }}
rules:
- host: {{ .Values.statistics_dashboard.ingress.host }}
http:
paths:
- backend:
service:
name: {{ .Release.Name }}-maibot-statistics-dashboard
port:
number: {{ .Values.statistics_dashboard.service.port }}
path: {{ .Values.statistics_dashboard.ingress.path }}
pathType: {{ .Values.statistics_dashboard.ingress.pathType }}
{{- end }}

View File

@ -0,0 +1,18 @@
{{- if .Values.statistics_dashboard.enabled }}
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: {{ .Release.Name }}-maibot-statistics-dashboard
namespace: {{ .Release.Namespace }}
spec:
{{- if .Values.statistics_dashboard.persistence.accessModes }}
accessModes:
{{ toYaml .Values.statistics_dashboard.persistence.accessModes | nindent 4 }}
{{- end }}
resources:
requests:
storage: {{ .Values.statistics_dashboard.persistence.size }}
{{- if .Values.statistics_dashboard.persistence.storageClass }}
storageClassName: {{ .Values.statistics_dashboard.persistence.storageClass | default nil }}
{{- end }}
{{- end }}

View File

@ -0,0 +1,21 @@
{{- if .Values.statistics_dashboard.enabled }}
apiVersion: v1
kind: Service
metadata:
name: {{ .Release.Name }}-maibot-statistics-dashboard
namespace: {{ .Release.Namespace }}
labels:
app: {{ .Release.Name }}-maibot-statistics-dashboard
spec:
ports:
- name: dashboard
port: {{ .Values.statistics_dashboard.service.port }}
protocol: TCP
targetPort: 80
{{- if eq .Values.statistics_dashboard.service.type "NodePort" }}
nodePort: {{ .Values.statistics_dashboard.service.nodePort | default nil }}
{{- end }}
selector:
app: {{ .Release.Name }}-maibot-statistics-dashboard
type: {{ .Values.statistics_dashboard.service.type }}
{{- end }}

View File

@ -0,0 +1,566 @@
# 只有同意了EULA和PRIVACY协议才可以部署麦麦
# 配置以下的选项为true表示你同意了EULA和PRIVACY条款
# https://github.com/MaiM-with-u/MaiBot/blob/main/EULA.md
# https://github.com/MaiM-with-u/MaiBot/blob/main/PRIVACY.md
EULA_AGREE: false
PRIVACY_AGREE: false
# 麦麦Adapter的部署配置
adapter:
image:
repository: # 默认 unclas/maimbot-adapter
tag: # 默认 main-20250922131146
pullPolicy: IfNotPresent
pullSecrets: [ ]
resources: { }
nodeSelector: { }
tolerations: [ ]
# 配置adapter的napcat websocket service
# adapter会启动一个websocket服务端用于与napcat通信
# 这里的选项可以帮助你自定义服务端口
# 默认不使用NodePort。如果通过NodePort将服务端口映射到公网可能会被恶意客户端连接请自行使用中间件鉴权
service:
type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的websocket端口映射到物理节点的端口
port: 8095 # websocket监听端口ClusterIP的端口
nodePort: # 仅在设置NodePort类型时有效不指定则会随机分配端口
persistence:
storageClass:
accessModes:
- ReadWriteOnce
size: 1Gi
# adapter的动态生成configmap的Job的配置
cm_generator:
image:
repository: # 默认 reg.mikumikumi.xyz/maibot/adapter-cm-generator
tag: # 默认 0.10.3-beta
pullPolicy: IfNotPresent
pullSecrets: [ ]
# 麦麦本体的部署配置
core:
image:
repository: # 默认 reg.mikumikumi.xyz/maibot/maibot
tag: # 默认 tag-0.10.3-beta
pullPolicy: IfNotPresent
pullSecrets: [ ]
resources: { }
nodeSelector: { }
tolerations: [ ]
persistence:
storageClass:
accessModes:
- ReadWriteOnce
size: 10Gi
# 麦麦的运行统计看板配置
# 麦麦每隔一段时间会自动输出html格式的运行统计报告此统计报告可以作为静态网页访问
# 此功能默认禁用。如果你认为报告可以被公开访问(报告包含联系人/群组名称、模型token花费信息等则可以启用此功能
# 如果启用此功能,你也可以考虑使用中间件进行鉴权,保护隐私信息
statistics_dashboard:
enabled: false # 是否启用运行统计看板
replicaCount: 1
image:
repository: # 默认 nginx
tag: # 默认 latest
pullPolicy: IfNotPresent
pullSecrets: [ ]
resources: { }
nodeSelector: { }
tolerations: [ ]
service:
type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的服务端口映射到物理节点的端口
port: 80 # 服务端口
nodePort: # 仅在设置NodePort类型时有效不指定则会随机分配端口
ingress:
enabled: false
className: nginx
annotations: { }
host: maim-statistics.example.com # 访问运行统计看板的域名
path: /
pathType: Prefix
persistence:
storageClass:
# 如果你希望运行统计看板服务与麦麦本体运行在不同的节点多活部署那么需要ReadWriteMany访问模式
# 注意ReadWriteMany特性需要存储类底层支持
accessModes:
- ReadWriteOnce
size: 100Mi
# napcat的部署配置
# napcat部署完毕后务必修改默认密码
napcat:
# 考虑到复用外部napcat实例的情况napcat部署已被解耦
# 如果你有外部部署的napcat则可以修改下面的enabled为false本次不会重复部署napcat
# 如果没有外部部署的napcat默认会捆绑部署napcat不需要修改此项
enabled: true
image:
repository: # 默认 mlikiowa/napcat-docker
tag: # 默认 v4.8.116
pullPolicy: IfNotPresent
pullSecrets: [ ]
resources: { }
nodeSelector: { }
tolerations: [ ]
# napcat进程的权限默认不是特权用户
permission:
uid: 1000
gid: 1000
# 配置napcat web面板的service
service:
type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的服务端口映射到物理节点的端口
port: 6099 # 服务端口
nodePort: # 仅在设置NodePort类型时有效不指定则会随机分配端口
# 配置napcat web面板的ingress
ingress:
enabled: false # 是否启用
className: nginx
annotations: { }
host: napcat.example.com # 暴露napcat web面板使用的域名
path: /
pathType: Prefix
persistence:
storageClass:
accessModes:
- ReadWriteOnce
size: 5Gi
# sqlite-web的部署配置
sqlite_web:
# 通过sqlite-web可以在网页上操作麦麦的数据库方便调试。不部署对麦麦的运行无影响
# 默认不会捆绑部署sqlite-web如果你需要部署请修改下面的enabled为true
# sqlite-web服务无鉴权暴露在公网上十分危险推荐使用集群ClusterIP内网访问
# !!!如果一定要暴露在公网,请自行使用中间件鉴权!!!
enabled: false
image:
repository: # 默认 coleifer/sqlite-web
tag: # 默认 latest
pullPolicy: IfNotPresent
pullSecrets: [ ]
resources: { }
nodeSelector: { }
tolerations: [ ]
# 配置sqlite-web面板的service
# 默认不使用NodePort。如果使用NodePort暴露到公网请自行使用中间件鉴权
service:
type: ClusterIP # ClusterIP / NodePort 指定NodePort可以将内网的服务端口映射到物理节点的端口
port: 8080 # 服务端口
nodePort: # 仅在设置NodePort类型时有效不指定则会随机分配端口
# 配置sqlite-web面板的ingress
# 默认不使用ingress。如果使用ingress暴露到公网请自行使用中间件鉴权
ingress:
enabled: false # 是否启用
className: nginx
annotations: { }
host: maim-sqlite.example.com # 暴露websocket使用的域名
path: /
pathType: Prefix
# 麦麦各部分组件的运行配置文件
config:
# adapter的config.toml
adapter_config: |
[inner]
version = "0.1.2" # 版本号
# 请勿修改版本号,除非你知道自己在做什么
[nickname] # 现在没用
nickname = ""
[napcat_server] # Napcat连接的ws服务设置
token = "" # Napcat设定的访问令牌若无则留空
heartbeat_interval = 30 # 与Napcat设置的心跳相同按秒计
[chat] # 黑白名单功能
group_list_type = "whitelist" # 群组名单类型可选为whitelist, blacklist
group_list = [] # 群组名单
# 当group_list_type为whitelist时只有群组名单中的群组可以聊天
# 当group_list_type为blacklist时群组名单中的任何群组无法聊天
private_list_type = "whitelist" # 私聊名单类型可选为whitelist, blacklist
private_list = [] # 私聊名单
# 当private_list_type为whitelist时只有私聊名单中的用户可以聊天
# 当private_list_type为blacklist时私聊名单中的任何用户无法聊天
ban_user_id = [] # 全局禁止名单(全局禁止名单中的用户无法进行任何聊天)
ban_qq_bot = false # 是否屏蔽QQ官方机器人
enable_poke = true # 是否启用戳一戳功能
[voice] # 发送语音设置
use_tts = false # 是否使用tts语音请确保你配置了tts并有对应的adapter
[debug]
level = "INFO" # 日志等级DEBUG, INFO, WARNING, ERROR, CRITICAL
# core的model_config.toml
core_model_config: |
[inner]
version = "1.7.0"
# 配置文件版本号迭代规则同bot_config.toml
[[api_providers]] # API服务提供商可以配置多个
name = "DeepSeek" # API服务商名称可随意命名在models的api-provider中需使用这个命名
base_url = "https://api.deepseek.com/v1" # API服务商的BaseURL
api_key = "your-api-key-here" # API密钥请替换为实际的API密钥
client_type = "openai" # 请求客户端(可选,默认值为"openai"使用gimini等Google系模型时请配置为"gemini"
max_retry = 2 # 最大重试次数单个模型API调用失败最多重试的次数
timeout = 30 # API请求超时时间单位
retry_interval = 10 # 重试间隔时间(单位:秒)
[[api_providers]] # 阿里 百炼 API服务商配置
name = "BaiLian"
base_url = "https://dashscope.aliyuncs.com/compatible-mode/v1"
api_key = "your-bailian-key"
client_type = "openai"
max_retry = 2
timeout = 15
retry_interval = 5
[[api_providers]] # 特殊Google的Gimini使用特殊API与OpenAI格式不兼容需要配置client为"gemini"
name = "Google"
base_url = "https://api.google.com/v1"
api_key = "your-google-api-key-1"
client_type = "gemini"
max_retry = 2
timeout = 30
retry_interval = 10
[[api_providers]] # SiliconFlow的API服务商配置
name = "SiliconFlow"
base_url = "https://api.siliconflow.cn/v1"
api_key = "your-siliconflow-api-key"
client_type = "openai"
max_retry = 2
timeout = 60
retry_interval = 10
[[models]] # 模型(可以配置多个)
model_identifier = "deepseek-chat" # 模型标识符API服务商提供的模型标识符
name = "deepseek-v3" # 模型名称(可随意命名,在后面中需使用这个命名)
api_provider = "DeepSeek" # API服务商名称对应在api_providers中配置的服务商名称
price_in = 2.0 # 输入价格用于API调用统计单位元/ M token可选若无该字段默认值为0
price_out = 8.0 # 输出价格用于API调用统计单位元/ M token可选若无该字段默认值为0
#force_stream_mode = true # 强制流式输出模式若模型不支持非流式输出请取消该注释启用强制流式输出若无该字段默认值为false
[[models]]
model_identifier = "deepseek-ai/DeepSeek-V3"
name = "siliconflow-deepseek-v3"
api_provider = "SiliconFlow"
price_in = 2.0
price_out = 8.0
[[models]]
model_identifier = "Qwen/Qwen3-8B"
name = "qwen3-8b"
api_provider = "SiliconFlow"
price_in = 0
price_out = 0
[models.extra_params] # 可选的额外参数配置
enable_thinking = false # 不启用思考
[[models]]
model_identifier = "Qwen/Qwen3-30B-A3B-Instruct-2507"
name = "qwen3-30b"
api_provider = "SiliconFlow"
price_in = 0.7
price_out = 2.8
[[models]]
model_identifier = "Qwen/Qwen2.5-VL-72B-Instruct"
name = "qwen2.5-vl-72b"
api_provider = "SiliconFlow"
price_in = 4.13
price_out = 4.13
[[models]]
model_identifier = "FunAudioLLM/SenseVoiceSmall"
name = "sensevoice-small"
api_provider = "SiliconFlow"
price_in = 0
price_out = 0
[[models]]
model_identifier = "BAAI/bge-m3"
name = "bge-m3"
api_provider = "SiliconFlow"
price_in = 0
price_out = 0
[model_task_config.utils] # 在麦麦的一些组件中使用的模型,例如表情包模块,取名模块,关系模块,麦麦的情绪变化等,是麦麦必须的模型
model_list = ["siliconflow-deepseek-v3","qwen3-30b"] # 使用的模型列表,每个子项对应上面的模型名称(name)
temperature = 0.2 # 模型温度新V3建议0.1-0.3
max_tokens = 800 # 最大输出token数
[model_task_config.utils_small] # 在麦麦的一些组件中使用的小模型,消耗量较大,建议使用速度较快的小模型
model_list = ["qwen3-8b","qwen3-30b"]
temperature = 0.7
max_tokens = 800
[model_task_config.tool_use] #工具调用模型,需要使用支持工具调用的模型
model_list = ["qwen3-30b"]
temperature = 0.7
max_tokens = 800
[model_task_config.replyer] # 首要回复模型,还用于表达器和表达方式学习
model_list = ["siliconflow-deepseek-v3"]
temperature = 0.3 # 模型温度新V3建议0.1-0.3
max_tokens = 800
[model_task_config.planner] #决策:负责决定麦麦该什么时候回复的模型
model_list = ["siliconflow-deepseek-v3"]
temperature = 0.3
max_tokens = 800
[model_task_config.vlm] # 图像识别模型
model_list = ["qwen2.5-vl-72b"]
max_tokens = 800
[model_task_config.voice] # 语音识别模型
model_list = ["sensevoice-small"]
#嵌入模型
[model_task_config.embedding]
model_list = ["bge-m3"]
#------------LPMM知识库模型------------
[model_task_config.lpmm_entity_extract] # 实体提取模型
model_list = ["siliconflow-deepseek-v3"]
temperature = 0.2
max_tokens = 800
[model_task_config.lpmm_rdf_build] # RDF构建模型
model_list = ["siliconflow-deepseek-v3"]
temperature = 0.2
max_tokens = 800
[model_task_config.lpmm_qa] # 问答模型
model_list = ["qwen3-30b"]
temperature = 0.7
max_tokens = 800
# core的bot_config.toml
core_bot_config: |
[inner]
version = "6.14.3"
#----以下是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
#如果你想要修改配置文件请递增version的值
#如果新增项目请阅读src/config/official_configs.py中的说明
#
# 版本格式:主版本号.次版本号.修订号,版本号递增规则如下:
# 主版本号MMC版本更新
# 次版本号:配置文件内容大更新
# 修订号:配置文件内容小更新
#----以上是给开发人员阅读的,如果你只是部署了麦麦,不需要阅读----
[bot]
platform = "qq"
qq_account = "1145141919810" # 麦麦的QQ账号
nickname = "麦麦" # 麦麦的昵称
alias_names = ["麦叠", "牢麦"] # 麦麦的别名
[personality]
# 建议120字以内描述人格特质 和 身份特征
personality = "是一个女大学生,现在在读大二,会刷贴吧。"
#アイデンティティがない 生まれないらららら
# 描述麦麦说话的表达风格,表达习惯,如要修改,可以酌情新增内容
reply_style = "请回复的平淡一些,简短一些,说中文,不要刻意突出自身学科背景。可以参考贴吧,知乎和微博的回复风格。"
# 情感特征,影响情绪的变化情况
emotion_style = "情绪较为稳定,但遭遇特定事件的时候起伏较大"
# 麦麦的兴趣,会影响麦麦对什么话题进行回复
interest = "对技术相关话题,游戏和动漫相关话题感兴趣,也对日常话题感兴趣,不喜欢太过沉重严肃的话题"
# 麦麦的说话规则,行为风格:
plan_style = """请你根据聊天内容,用户的最新消息和以下标准选择合适的动作:
1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
2.如果相同的内容已经被执行,请不要重复执行
3.请控制你的发言频率,不要太过频繁的发言
4.如果有人对你感到厌烦,请减少回复
5.如果有人对你进行攻击,或者情绪激动,请你以合适的方法应对"""
# 麦麦识图规则,不建议修改
visual_style = "请用中文描述这张图片的内容。如果有文字请把文字描述概括出来请留意其主题直观感受输出为一段平文本最多30字请注意不要分点就输出一段文本"
# 麦麦私聊的说话规则,行为风格:
private_plan_style = """请你根据聊天内容,用户的最新消息和以下标准选择合适的动作:
1.思考**所有**的可用的action中的**每个动作**是否符合当下条件,如果动作使用条件符合聊天内容就使用
2.如果相同的内容已经被执行,请不要重复执行
3.某句话如果已经被回复过,不要重复回复"""
[expression]
# 表达学习配置
learning_list = [ # 表达学习配置列表,支持按聊天流配置
["", "enable", "enable", "1.0"], # 全局配置使用表达启用学习学习强度1.0
["qq:1919810:group", "enable", "enable", "1.5"], # 特定群聊配置使用表达启用学习学习强度1.5
["qq:114514:private", "enable", "disable", "0.5"], # 特定私聊配置使用表达禁用学习学习强度0.5
# 格式说明:
# 第一位: chat_stream_id空字符串表示全局配置
# 第二位: 是否使用学到的表达 ("enable"/"disable")
# 第三位: 是否学习表达 ("enable"/"disable")
# 第四位: 学习强度(浮点数),影响学习频率,最短学习时间间隔 = 300/学习强度(秒)
# 学习强度越高,学习越频繁;学习强度越低,学习越少
]
expression_groups = [
# ["*"], # 全局共享组所有chat_id共享学习到的表达方式取消注释以启用全局共享
["qq:1919810:private","qq:114514:private","qq:1111111:group"], # 特定互通组相同组的chat_id会共享学习到的表达方式
# 格式说明:
# ["*"] - 启用全局共享,所有聊天流共享表达方式
# ["qq:123456:private","qq:654321:group"] - 特定互通组组内chat_id共享表达方式
# 注意如果为群聊则需要设置为group如果设置为私聊则需要设置为private
]
[chat] #麦麦的聊天设置
talk_value = 1
mentioned_bot_reply = true # 是否启用提及必回复
max_context_size = 20 # 上下文长度
[relationship]
enable_relationship = true # 是否启用关系系统
[tool]
enable_tool = true # 是否启用回复工具
[mood]
enable_mood = true # 是否启用情绪系统
mood_update_threshold = 1 # 情绪更新阈值,越高,更新越慢
[emoji]
emoji_chance = 0.6 # 麦麦激活表情包动作的概率
max_reg_num = 100 # 表情包最大注册数量
do_replace = true # 开启则在达到最大数量时删除(替换)表情包,关闭则达到最大数量时不会继续收集表情包
check_interval = 10 # 检查表情包(注册,破损,删除)的时间间隔(分钟)
steal_emoji = true # 是否偷取表情包,让麦麦可以将一些表情包据为己有
content_filtration = false # 是否启用表情包过滤,只有符合该要求的表情包才会被保存
filtration_prompt = "符合公序良俗" # 表情包过滤要求,只有符合该要求的表情包才会被保存
[voice]
enable_asr = false # 是否启用语音识别,启用后麦麦可以识别语音消息,启用该功能需要配置语音识别模型[model_task_config.voice]
[message_receive]
# 以下是消息过滤,可以根据规则过滤特定消息,将不会读取这些消息
ban_words = [
# "403","张三"
]
ban_msgs_regex = [
# 需要过滤的消息(原始消息)匹配的正则表达式,匹配到的消息将被过滤,若不了解正则表达式请勿修改
#"https?://[^\\s]+", # 匹配https链接
#"\\d{4}-\\d{2}-\\d{2}", # 匹配日期
]
[lpmm_knowledge] # lpmm知识库配置
enable = false # 是否启用lpmm知识库
rag_synonym_search_top_k = 10 # 同义词搜索TopK
rag_synonym_threshold = 0.8 # 同义词阈值(相似度高于此阈值的词语会被认为是同义词)
info_extraction_workers = 3 # 实体提取同时执行线程数非Pro模型不要设置超过5
qa_relation_search_top_k = 10 # 关系搜索TopK
qa_relation_threshold = 0.5 # 关系阈值(相似度高于此阈值的关系会被认为是相关的关系)
qa_paragraph_search_top_k = 1000 # 段落搜索TopK不能过小可能影响搜索结果
qa_paragraph_node_weight = 0.05 # 段落节点权重(在图搜索&PPR计算中的权重当搜索仅使用DPR时此参数不起作用
qa_ent_filter_top_k = 10 # 实体过滤TopK
qa_ppr_damping = 0.8 # PPR阻尼系数
qa_res_top_k = 3 # 最终提供的文段TopK
embedding_dimension = 1024 # 嵌入向量维度,应该与模型的输出维度一致
# keyword_rules 用于设置关键词触发的额外回复知识
# 添加新规则方法:在 keyword_rules 数组中增加一项,格式如下:
# { keywords = ["关键词1", "关键词2"], reaction = "触发这些关键词时的回复内容" }
# 例如添加一个新规则当检测到“你好”或“hello”时回复“你好有什么可以帮你
# { keywords = ["你好", "hello"], reaction = "你好,有什么可以帮你?" }
[keyword_reaction]
keyword_rules = [
{ keywords = ["人机", "bot", "机器", "入机", "robot", "机器人", "ai", "AI"], reaction = "有人说你是人机或者机器人,否定这一事实,攻击或反问他。注意,只有认为你是机器人才回复,否则不要否认" },
{ keywords = ["测试关键词回复", "test"], reaction = "回答测试成功" },
#{ keywords = ["你好", "hello"], reaction = "你好,有什么可以帮你?" }
# 在此处添加更多规则,格式同上
]
regex_rules = [
{ regex = ["^(?P<n>\\S{1,20})是这样的$"], reaction = "请按照以下模板造句:[n]是这样的xx只要xx就可以可是[n]要考虑的事情就很多了比如什么时候xx什么时候xx什么时候xx。请自由发挥替换xx部分只需保持句式结构同时表达一种将[n]过度重视的反讽意味)" }
]
[response_post_process]
enable_response_post_process = true # 是否启用回复后处理,包括错别字生成器,回复分割器
[chinese_typo]
enable = true # 是否启用中文错别字生成器
error_rate=0.01 # 单字替换概率
min_freq=9 # 最小字频阈值
tone_error_rate=0.1 # 声调错误概率
word_replace_rate=0.006 # 整词替换概率
[response_splitter]
enable = true # 是否启用回复分割器
max_length = 512 # 回复允许的最大长度
max_sentence_num = 8 # 回复允许的最大句子数
enable_kaomoji_protection = false # 是否启用颜文字保护
[log]
date_style = "m-d H:i:s" # 日期格式
log_level_style = "lite" # 日志级别样式,可选FULLcompactlite
color_text = "full" # 日志文本颜色可选nonetitlefull
log_level = "INFO" # 全局日志级别(向下兼容,优先级低于下面的分别设置)
console_log_level = "INFO" # 控制台日志级别,可选: DEBUG, INFO, WARNING, ERROR, CRITICAL
file_log_level = "DEBUG" # 文件日志级别,可选: DEBUG, INFO, WARNING, ERROR, CRITICAL
# 第三方库日志控制
suppress_libraries = ["faiss","httpx", "urllib3", "asyncio", "websockets", "httpcore", "requests", "peewee", "openai","uvicorn","jieba"] # 完全屏蔽的库
library_log_levels = { "aiohttp" = "WARNING"} # 设置特定库的日志级别
[debug]
show_prompt = false # 是否显示prompt
[maim_message]
auth_token = [] # 认证令牌用于API验证为空则不启用验证
# 以下项目若要使用需要打开use_custom并单独配置maim_message的服务器
use_custom = false # 是否启用自定义的maim_message服务器注意这需要设置新的端口不能与.env重复
host="127.0.0.1"
port=8090
mode="ws" # 支持ws和tcp两种模式
use_wss = false # 是否使用WSS安全连接只支持ws模式
cert_file = "" # SSL证书文件路径仅在use_wss=true时有效
key_file = "" # SSL密钥文件路径仅在use_wss=true时有效
[telemetry] #发送统计信息,主要是看全球有多少只麦麦
enable = true
[experimental] #实验性功能
none = false # 暂无