From b07a9bd3b30ff754698a4f9d52fe788a1729a529 Mon Sep 17 00:00:00 2001 From: z30057876 Date: Thu, 13 Feb 2025 16:54:42 +0800 Subject: [PATCH 1/6] =?UTF-8?q?=E4=BF=AE=E8=A1=A5file=5Fcopy=E9=80=BB?= =?UTF-8?q?=E8=BE=91?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- assets/.env.example | 2 +- deploy/secret_helper/file_copy.py | 28 +++++++++++++++++----------- 2 files changed, 18 insertions(+), 12 deletions(-) diff --git a/assets/.env.example b/assets/.env.example index 931d9c99..f9958ea4 100644 --- a/assets/.env.example +++ b/assets/.env.example @@ -83,7 +83,7 @@ LLM_MAX_TOKENS=8192 LLM_TEMPERATURE=0.7 # 小模型接口(用于参数提取等程序功能) -SCHEDULER_TYPE= +SCHEDULER_BACKEND= SCHEDULER_MODEL= SCHEDULER_URL= SCHEDULER_API_KEY= diff --git a/deploy/secret_helper/file_copy.py b/deploy/secret_helper/file_copy.py index dd416185..71b80a52 100644 --- a/deploy/secret_helper/file_copy.py +++ b/deploy/secret_helper/file_copy.py @@ -9,16 +9,29 @@ from typing import Any def chown_chmod(path: Path, mode_number: int, uid: int, gid: int) -> None: """Change ownership and permissions""" - path.chmod(mode_number) os.chown(str(path), uid, gid) # type: ignore[] + path.chmod(mode_number) for file in path.rglob("*"): os.chown(str(file), uid, gid) # type: ignore[] file.chmod(mode_number) +def copy_file(file: Path, out_path: Path, secrets: dict[str, str]) -> None: + print(f"copying: {file} to {out_path}") + with file.open("r", encoding="utf-8") as f: + data = f.read() + if secrets: + for key, value in secrets.items(): + data = data.replace(r"${" + key + "}", value) + with out_path.open("w", encoding="utf-8") as f: + f.write(data) -def copy_single_file(from_path: Path, to_path: Path, secrets: dict[str, str]) -> None: +def copy_single_item(from_path: Path, to_path: Path, secrets: dict[str, str]) -> None: """Copy a single file""" + if from_path.is_file(): + print(f"found: {from_path}") + copy_file(from_path, to_path, secrets) + for file in from_path.rglob("*"): print(f"found: {file}") if any(p for p in file.parts if p.startswith(".")): @@ -26,14 +39,7 @@ def copy_single_file(from_path: Path, to_path: Path, secrets: dict[str, str]) -> continue out_path = to_path / file.relative_to(from_path) if file.is_file(): - print(f"copying: {file} to {out_path}") - with file.open("r", encoding="utf-8") as f: - data = f.read() - if secrets: - for key, value in secrets.items(): - data = data.replace(r"${" + key + "}", value) - with out_path.open("w", encoding="utf-8") as f: - f.write(data) + copy_file(file, out_path, secrets) else: out_path.mkdir(parents=True, exist_ok=True) @@ -60,7 +66,7 @@ def copy(from_path_str: str, to_path_str: str, mode: dict[str, Any]) -> None: raise FileNotFoundError # 递归复制文件 - copy_single_file(from_path, to_path, secrets) + copy_single_item(from_path, to_path, secrets) # 设置权限 mode_number = int(mode["mode"], 8) -- Gitee From d0091bd1a89b4f74a5f0e8958e7adb03f06ae238 Mon Sep 17 00:00:00 2001 From: z30057876 Date: Thu, 13 Feb 2025 16:55:40 +0800 Subject: [PATCH 2/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3authhub=20chart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/chart/authhub/Chart.yaml | 2 +- .../authhub/configs/backend/copy-config.yml | 6 +++--- .../backend/authhub-backend-config.yaml | 4 ++-- .../templates/backend/authhub-backend.yaml | 10 ++++++++-- .../authhub/templates/mysql/mysql-config.yaml | 4 ++-- .../authhub/templates/mysql/mysql-storage.yaml | 4 ++-- deploy/chart/authhub/templates/mysql/mysql.yaml | 8 ++++---- deploy/chart/authhub/templates/secrets.yaml | 17 ++++++++++++++--- .../templates/web/authhub-web-config.yaml | 4 ++-- .../authhub/templates/web/authhub-web.yaml | 6 +++--- 10 files changed, 41 insertions(+), 24 deletions(-) diff --git a/deploy/chart/authhub/Chart.yaml b/deploy/chart/authhub/Chart.yaml index 695d79c1..613a6c25 100644 --- a/deploy/chart/authhub/Chart.yaml +++ b/deploy/chart/authhub/Chart.yaml @@ -3,4 +3,4 @@ name: authhub-chart description: AuthHub Helm部署包 type: application version: 0.9.3 -appVersion: "1.16.0" +appVersion: "0.9.3" diff --git a/deploy/chart/authhub/configs/backend/copy-config.yml b/deploy/chart/authhub/configs/backend/copy-config.yml index 5df98a45..74cd5019 100644 --- a/deploy/chart/authhub/configs/backend/copy-config.yml +++ b/deploy/chart/authhub/configs/backend/copy-config.yml @@ -2,6 +2,6 @@ copy: - from: /config to: /config-rw mode: - uid: 1000 - gid: 1000 - mode: "0o750" \ No newline at end of file + uid: 0 + gid: 0 + mode: "0o650" \ No newline at end of file diff --git a/deploy/chart/authhub/templates/backend/authhub-backend-config.yaml b/deploy/chart/authhub/templates/backend/authhub-backend-config.yaml index bb91d55a..0164dcbb 100644 --- a/deploy/chart/authhub/templates/backend/authhub-backend-config.yaml +++ b/deploy/chart/authhub/templates/backend/authhub-backend-config.yaml @@ -1,4 +1,4 @@ -{{- if .Values.authhub.backend.enabled }} +{{- if .Values.authhub.backend.enabled -}} apiVersion: v1 kind: ConfigMap metadata: @@ -11,4 +11,4 @@ data: {{ tpl (.Files.Get "configs/backend/authhub.yml") . | indent 4 }} copy-config.yml: |- {{ tpl (.Files.Get "configs/backend/copy-config.yml") . | indent 4 }} -{{- end }} +{{- end -}} diff --git a/deploy/chart/authhub/templates/backend/authhub-backend.yaml b/deploy/chart/authhub/templates/backend/authhub-backend.yaml index 83a475cc..296aa3c8 100644 --- a/deploy/chart/authhub/templates/backend/authhub-backend.yaml +++ b/deploy/chart/authhub/templates/backend/authhub-backend.yaml @@ -1,4 +1,4 @@ -{{- if .Values.authhub.backend.enabled }} +{{- if .Values.authhub.backend.enabled -}} --- apiVersion: v1 kind: Service @@ -53,6 +53,12 @@ spec: failureThreshold: 5 initialDelaySeconds: 60 periodSeconds: 90 + resources: + requests: + cpu: 0.1 + memory: 128Mi + limits: + {{ toYaml .Values.authhub.backend.resourceLimits | nindent 14 }} initContainers: - name: authhub-backend-copy-secret image: {{ default "hub.oepkgs.net/neocopilot/secret_inject:x86" .Values.authhub.secret_inject.image }} @@ -88,4 +94,4 @@ spec: - name: euler-copilot-database-vl secret: secretName: euler-copilot-database -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/authhub/templates/mysql/mysql-config.yaml b/deploy/chart/authhub/templates/mysql/mysql-config.yaml index 57e2dab9..9a92389a 100644 --- a/deploy/chart/authhub/templates/mysql/mysql-config.yaml +++ b/deploy/chart/authhub/templates/mysql/mysql-config.yaml @@ -1,4 +1,4 @@ -{{- if .Values.authhub.mysql.enabled }} +{{- if .Values.authhub.mysql.enabled -}} apiVersion: v1 kind: ConfigMap metadata: @@ -7,4 +7,4 @@ metadata: data: init.sql: |- {{ tpl (.Files.Get "configs/mysql/init.sql") . | indent 4 }} -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/authhub/templates/mysql/mysql-storage.yaml b/deploy/chart/authhub/templates/mysql/mysql-storage.yaml index 8197ac34..0677d68a 100644 --- a/deploy/chart/authhub/templates/mysql/mysql-storage.yaml +++ b/deploy/chart/authhub/templates/mysql/mysql-storage.yaml @@ -1,4 +1,4 @@ -{{- if .Values.authhub.mysql.enabled }} +{{- if .Values.authhub.mysql.enabled -}} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -13,4 +13,4 @@ spec: resources: requests: storage: {{ default "10Gi" .Values.authhub.mysql.persistentVolumeSize }} -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/authhub/templates/mysql/mysql.yaml b/deploy/chart/authhub/templates/mysql/mysql.yaml index 5e5db762..ba20e6ca 100644 --- a/deploy/chart/authhub/templates/mysql/mysql.yaml +++ b/deploy/chart/authhub/templates/mysql/mysql.yaml @@ -1,4 +1,4 @@ -{{- if .Values.authhub.mysql.enabled }} +{{- if .Values.authhub.mysql.enabled -}} --- apiVersion: v1 kind: Service @@ -75,9 +75,9 @@ spec: resources: requests: cpu: 0.1 - memory: 256Mi + memory: 384Mi limits: - {{- toYaml .Values.authhub.mysql.resourceLimits | nindent 14 }} + {{ toYaml .Values.authhub.mysql.resourceLimits | nindent 14 }} restartPolicy: Always volumes: - name: mysql-data @@ -86,4 +86,4 @@ spec: - name: mysql-init configMap: name: mysql-config -{{- end }} +{{- end -}} diff --git a/deploy/chart/authhub/templates/secrets.yaml b/deploy/chart/authhub/templates/secrets.yaml index aca33aa2..62a3e433 100644 --- a/deploy/chart/authhub/templates/secrets.yaml +++ b/deploy/chart/authhub/templates/secrets.yaml @@ -1,5 +1,16 @@ -{{- $authhubSecret := (lookup "v1" "Secret" .Release.Namespace "authhub-secret") }} -{{- if not $authhubSecret}} +{{- $authhubSecret := (lookup "v1" "Secret" .Release.Namespace "authhub-secret") -}} +{{- if $authhubSecret -}} +apiVersion: v1 +kind: Secret +metadata: + name: authhub-secret + namespace: {{ .Release.Namespace }} + annotations: + helm.sh/resource-policy: keep +type: Opaque +stringData: + mysql-password: {{ $authhubSecret.data.mysql-password | b64dec }} +{{- else -}} apiVersion: v1 kind: Secret metadata: @@ -10,4 +21,4 @@ metadata: type: Opaque stringData: mysql-password: {{ randAlphaNum 20 }} -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/authhub/templates/web/authhub-web-config.yaml b/deploy/chart/authhub/templates/web/authhub-web-config.yaml index 0d1cdf15..3d342fb6 100644 --- a/deploy/chart/authhub/templates/web/authhub-web-config.yaml +++ b/deploy/chart/authhub/templates/web/authhub-web-config.yaml @@ -1,4 +1,4 @@ -{{- if .Values.authhub.web.enabled }} +{{- if .Values.authhub.web.enabled -}} apiVersion: v1 kind: ConfigMap metadata: @@ -41,4 +41,4 @@ data: proxy_set_header Request-Header $http_request_header; } } -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/authhub/templates/web/authhub-web.yaml b/deploy/chart/authhub/templates/web/authhub-web.yaml index 86528dd9..8f58f016 100644 --- a/deploy/chart/authhub/templates/web/authhub-web.yaml +++ b/deploy/chart/authhub/templates/web/authhub-web.yaml @@ -1,4 +1,4 @@ -{{- if .Values.authhub.web.enabled }} +{{- if .Values.authhub.web.enabled -}} --- apiVersion: v1 kind: Service @@ -78,9 +78,9 @@ spec: cpu: 0.05 memory: 64Mi limits: - {{- toYaml .Values.authhub.web.resourceLimits | nindent 14 }} + {{ toYaml .Values.authhub.web.resourceLimits | nindent 14 }} volumes: - name: web-config configMap: name: authhub-web-config -{{- end }} +{{- end -}} -- Gitee From c8d080832aec058a97107151cf8c2f7b05044068 Mon Sep 17 00:00:00 2001 From: z30057876 Date: Thu, 13 Feb 2025 16:56:21 +0800 Subject: [PATCH 3/6] =?UTF-8?q?=E4=BF=AE=E6=AD=A3databases=20chart?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- deploy/chart/databases/Chart.yaml | 4 ++-- .../templates/minio/minio-storage.yaml | 4 ++-- .../databases/templates/minio/minio.yaml | 6 +++--- .../templates/mongo/mongo-config.yaml | 4 ++-- .../templates/mongo/mongo-storage.yaml | 4 ++-- .../databases/templates/mongo/mongo.yaml | 6 +++--- .../templates/pgsql/pgsql-config.yaml | 4 ++-- .../templates/pgsql/pgsql-storage.yaml | 4 ++-- .../databases/templates/pgsql/pgsql.yaml | 8 ++++---- .../databases/templates/redis/redis.yaml | 6 +++--- deploy/chart/databases/templates/secrets.yaml | 20 ++++++++++++++++--- 11 files changed, 42 insertions(+), 28 deletions(-) diff --git a/deploy/chart/databases/Chart.yaml b/deploy/chart/databases/Chart.yaml index 0ca5c32d..dd995ba8 100644 --- a/deploy/chart/databases/Chart.yaml +++ b/deploy/chart/databases/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: euler-copilot-databases description: Euler Copilot 数据库 Helm部署包 type: application -version: 0.9.1 -appVersion: "1.16.0" +version: 0.9.3 +appVersion: "0.9.3" diff --git a/deploy/chart/databases/templates/minio/minio-storage.yaml b/deploy/chart/databases/templates/minio/minio-storage.yaml index aa5061d8..d70fdad4 100644 --- a/deploy/chart/databases/templates/minio/minio-storage.yaml +++ b/deploy/chart/databases/templates/minio/minio-storage.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.databases.minio.enabled }} +{{- if and .Values.databases.minio.enabled -}} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -13,4 +13,4 @@ spec: resources: requests: storage: {{ default "10Gi" .Values.storage.minio }} -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/databases/templates/minio/minio.yaml b/deploy/chart/databases/templates/minio/minio.yaml index ab616c7d..83d7239d 100644 --- a/deploy/chart/databases/templates/minio/minio.yaml +++ b/deploy/chart/databases/templates/minio/minio.yaml @@ -1,4 +1,4 @@ -{{- if .Values.databases.minio.enabled }} +{{- if .Values.databases.minio.enabled -}} --- apiVersion: v1 kind: Service @@ -99,9 +99,9 @@ spec: cpu: 0.25 memory: 256Mi limits: - {{- toYaml .Values.databases.minio.resourceLimits | nindent 14 }} + {{ toYaml .Values.databases.minio.resourceLimits | nindent 14 }} volumes: - name: minio-data persistentVolumeClaim: claimName: minio-storage -{{- end }} +{{- end -}} diff --git a/deploy/chart/databases/templates/mongo/mongo-config.yaml b/deploy/chart/databases/templates/mongo/mongo-config.yaml index 1dba95d1..9c9594fd 100644 --- a/deploy/chart/databases/templates/mongo/mongo-config.yaml +++ b/deploy/chart/databases/templates/mongo/mongo-config.yaml @@ -1,4 +1,4 @@ -{{- if .Values.databases.mongo.enabled }} +{{- if .Values.databases.mongo.enabled -}} apiVersion: v1 kind: ConfigMap metadata: @@ -20,4 +20,4 @@ data: echo "初始化MongoDB集群成功!" exit 0 fi -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/databases/templates/mongo/mongo-storage.yaml b/deploy/chart/databases/templates/mongo/mongo-storage.yaml index 0adcab70..db5c313f 100644 --- a/deploy/chart/databases/templates/mongo/mongo-storage.yaml +++ b/deploy/chart/databases/templates/mongo/mongo-storage.yaml @@ -1,4 +1,4 @@ -{{- if .Values.databases.mongo.enabled }} +{{- if .Values.databases.mongo.enabled -}} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -13,4 +13,4 @@ spec: resources: requests: storage: {{ default "10Gi" .Values.storage.mongo }} -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/databases/templates/mongo/mongo.yaml b/deploy/chart/databases/templates/mongo/mongo.yaml index 1d058a91..c8750ee5 100644 --- a/deploy/chart/databases/templates/mongo/mongo.yaml +++ b/deploy/chart/databases/templates/mongo/mongo.yaml @@ -1,4 +1,4 @@ -{{- if .Values.databases.mongo.enabled }} +{{- if .Values.databases.mongo.enabled -}} --- apiVersion: v1 kind: Service @@ -90,7 +90,7 @@ spec: cpu: 0.25 memory: 256Mi limits: - {{- toYaml .Values.databases.mongo.resourceLimits | nindent 14 }} + {{ toYaml .Values.databases.mongo.resourceLimits | nindent 14 }} restartPolicy: Always volumes: - name: mongo-data @@ -99,4 +99,4 @@ spec: - name: mongo-init configMap: name: mongo-config -{{- end }} +{{- end -}} diff --git a/deploy/chart/databases/templates/pgsql/pgsql-config.yaml b/deploy/chart/databases/templates/pgsql/pgsql-config.yaml index 9c7c4d66..1f73664c 100644 --- a/deploy/chart/databases/templates/pgsql/pgsql-config.yaml +++ b/deploy/chart/databases/templates/pgsql/pgsql-config.yaml @@ -1,4 +1,4 @@ -{{- if .Values.databases.pgsql.enabled }} +{{- if .Values.databases.pgsql.enabled -}} apiVersion: v1 kind: ConfigMap metadata: @@ -10,4 +10,4 @@ data: CREATE EXTENSION vector; CREATE TEXT SEARCH CONFIGURATION zhparser (PARSER = zhparser); ALTER TEXT SEARCH CONFIGURATION zhparser ADD MAPPING FOR n,v,a,i,e,l WITH simple; -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/databases/templates/pgsql/pgsql-storage.yaml b/deploy/chart/databases/templates/pgsql/pgsql-storage.yaml index ca72ea10..5b5a16a3 100644 --- a/deploy/chart/databases/templates/pgsql/pgsql-storage.yaml +++ b/deploy/chart/databases/templates/pgsql/pgsql-storage.yaml @@ -1,4 +1,4 @@ -{{- if and .Values.databases.pgsql.enabled }} +{{- if and .Values.databases.pgsql.enabled -}} apiVersion: v1 kind: PersistentVolumeClaim metadata: @@ -13,4 +13,4 @@ spec: resources: requests: storage: {{ default "10Gi" .Values.storage.pgsql }} -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/databases/templates/pgsql/pgsql.yaml b/deploy/chart/databases/templates/pgsql/pgsql.yaml index 9d5e06c3..9a94aff2 100644 --- a/deploy/chart/databases/templates/pgsql/pgsql.yaml +++ b/deploy/chart/databases/templates/pgsql/pgsql.yaml @@ -1,4 +1,4 @@ -{{- if .Values.databases.pgsql.enabled }} +{{- if .Values.databases.pgsql.enabled -}} --- apiVersion: v1 kind: Service @@ -71,9 +71,9 @@ spec: resources: requests: cpu: 0.25 - memory: 256Mi + memory: 512Mi limits: - {{- toYaml .Values.databases.pgsql.resourceLimits | nindent 14 }} + {{ toYaml .Values.databases.pgsql.resourceLimits | nindent 14 }} volumes: - name: pgsql-data persistentVolumeClaim: @@ -81,4 +81,4 @@ spec: - name: pgsql-init configMap: name: pgsql-config -{{- end }} +{{- end -}} diff --git a/deploy/chart/databases/templates/redis/redis.yaml b/deploy/chart/databases/templates/redis/redis.yaml index 6c1ab951..dbabf932 100644 --- a/deploy/chart/databases/templates/redis/redis.yaml +++ b/deploy/chart/databases/templates/redis/redis.yaml @@ -1,4 +1,4 @@ -{{- if .Values.databases.redis.enabled }} +{{- if .Values.databases.redis.enabled -}} --- apiVersion: v1 kind: Service @@ -68,10 +68,10 @@ spec: cpu: 0.1 memory: 64Mi limits: - {{- toYaml .Values.databases.redis.resourceLimits | nindent 14 }} + {{ toYaml .Values.databases.redis.resourceLimits | nindent 14 }} restartPolicy: Always volumes: - name: redis-tmp emptyDir: medium: Memory -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/databases/templates/secrets.yaml b/deploy/chart/databases/templates/secrets.yaml index 5dff217d..36f99378 100644 --- a/deploy/chart/databases/templates/secrets.yaml +++ b/deploy/chart/databases/templates/secrets.yaml @@ -1,5 +1,19 @@ -{{- $databaseSecret := (lookup "v1" "Secret" .Release.Namespace "euler-copilot-database") }} -{{- if not $databaseSecret}} +{{- $databaseSecret := (lookup "v1" "Secret" .Release.Namespace "euler-copilot-database") -}} +{{- if $databaseSecret -}} +apiVersion: v1 +kind: Secret +metadata: + name: euler-copilot-database + namespace: {{ .Release.Namespace }} + annotations: + helm.sh/resource-policy: keep +type: Opaque +stringData: + redis-password: {{ $databaseSecret.data.redis-password | b64dec }} + mongo-password: {{ $databaseSecret.data.mongo-password | b64dec }} + minio-password: {{ $databaseSecret.data.minio-password | b64dec }} + pgsql-password: {{ $databaseSecret.data.pgsql-password | b64dec }} +{{- else -}} apiVersion: v1 kind: Secret metadata: @@ -13,4 +27,4 @@ stringData: mongo-password: {{ randAlphaNum 20 }} minio-password: {{ randAlphaNum 20 }} pgsql-password: {{ randAlphaNum 20 }} -{{- end }} \ No newline at end of file +{{- end -}} -- Gitee From 04c38ac7a3648694d2a63852a48059f2ddd03acf Mon Sep 17 00:00:00 2001 From: z30057876 Date: Thu, 13 Feb 2025 16:56:58 +0800 Subject: [PATCH 4/6] euler-copilot chart 0.9.4 --- deploy/chart/euler_copilot/Chart.yaml | 4 +- .../euler_copilot/configs/framework/.env | 91 ++--- .../configs/framework/copy-config.yaml | 7 + .../chart/euler_copilot/configs/rag-web/.env | 4 +- deploy/chart/euler_copilot/configs/rag/.env | 40 +- .../configs/rag/copy-config.yaml | 19 + .../euler_copilot/configs/vectorize/.env | 9 - deploy/chart/euler_copilot/configs/web/.env | 4 +- .../euler_copilot/templates/cornjob.yaml | 0 ...work-secret.yaml => framework-config.yaml} | 13 +- .../framework/framework-service.yaml | 17 - .../framework/framework-storage.yaml | 30 ++ ...amework-deployment.yaml => framework.yaml} | 122 ++++-- .../templates/rag-web/rag-web-config.yaml | 6 +- .../templates/rag-web/rag-web-ingress.yaml | 19 - .../templates/rag-web/rag-web-service.yaml | 18 - .../{rag-web-deployment.yaml => rag-web.yaml} | 64 +++- .../rag/{rag-secret.yaml => rag-config.yaml} | 13 +- .../templates/rag/rag-deployment.yaml | 56 --- .../templates/rag/rag-service.yaml | 17 - .../euler_copilot/templates/rag/rag.yaml | 118 ++++++ .../euler_copilot/templates/secrets.yaml | 32 ++ .../templates/serviceaccount.yaml | 0 .../vectorize/vectorize-deployment.yaml | 97 ----- .../templates/vectorize/vectorize-secret.yaml | 11 - .../vectorize/vectorize-service.yaml | 17 - .../templates/web/web-config.yaml | 6 +- .../templates/web/web-ingress.yaml | 19 - .../templates/web/web-service.yaml | 17 - .../web/{web-deployment.yaml => web.yaml} | 61 ++- deploy/chart/euler_copilot/values.yaml | 352 +++++++----------- 31 files changed, 612 insertions(+), 671 deletions(-) create mode 100644 deploy/chart/euler_copilot/configs/framework/copy-config.yaml create mode 100644 deploy/chart/euler_copilot/configs/rag/copy-config.yaml delete mode 100644 deploy/chart/euler_copilot/configs/vectorize/.env create mode 100644 deploy/chart/euler_copilot/templates/cornjob.yaml rename deploy/chart/euler_copilot/templates/framework/{framework-secret.yaml => framework-config.yaml} (39%) delete mode 100644 deploy/chart/euler_copilot/templates/framework/framework-service.yaml create mode 100644 deploy/chart/euler_copilot/templates/framework/framework-storage.yaml rename deploy/chart/euler_copilot/templates/framework/{framework-deployment.yaml => framework.yaml} (32%) delete mode 100644 deploy/chart/euler_copilot/templates/rag-web/rag-web-ingress.yaml delete mode 100644 deploy/chart/euler_copilot/templates/rag-web/rag-web-service.yaml rename deploy/chart/euler_copilot/templates/rag-web/{rag-web-deployment.yaml => rag-web.yaml} (43%) rename deploy/chart/euler_copilot/templates/rag/{rag-secret.yaml => rag-config.yaml} (61%) delete mode 100644 deploy/chart/euler_copilot/templates/rag/rag-deployment.yaml delete mode 100644 deploy/chart/euler_copilot/templates/rag/rag-service.yaml create mode 100644 deploy/chart/euler_copilot/templates/rag/rag.yaml create mode 100644 deploy/chart/euler_copilot/templates/secrets.yaml create mode 100644 deploy/chart/euler_copilot/templates/serviceaccount.yaml delete mode 100644 deploy/chart/euler_copilot/templates/vectorize/vectorize-deployment.yaml delete mode 100644 deploy/chart/euler_copilot/templates/vectorize/vectorize-secret.yaml delete mode 100644 deploy/chart/euler_copilot/templates/vectorize/vectorize-service.yaml delete mode 100644 deploy/chart/euler_copilot/templates/web/web-ingress.yaml delete mode 100644 deploy/chart/euler_copilot/templates/web/web-service.yaml rename deploy/chart/euler_copilot/templates/web/{web-deployment.yaml => web.yaml} (52%) diff --git a/deploy/chart/euler_copilot/Chart.yaml b/deploy/chart/euler_copilot/Chart.yaml index 5e8f9826..b48072c2 100644 --- a/deploy/chart/euler_copilot/Chart.yaml +++ b/deploy/chart/euler_copilot/Chart.yaml @@ -2,5 +2,5 @@ apiVersion: v2 name: euler-copilot description: Euler Copilot Helm部署包 type: application -version: 0.9.1 -appVersion: "1.16.0" +version: 0.9.3 +appVersion: "0.9.3" diff --git a/deploy/chart/euler_copilot/configs/framework/.env b/deploy/chart/euler_copilot/configs/framework/.env index 365f9c1d..ac40de31 100644 --- a/deploy/chart/euler_copilot/configs/framework/.env +++ b/deploy/chart/euler_copilot/configs/framework/.env @@ -6,20 +6,29 @@ COOKIE_MODE=domain WEB_FRONT_URL={{ .Values.euler_copilot.framework.web_url }} # Redis -REDIS_HOST=redis-db-{{ .Values.globals.databases.app_name }}.{{ .Values.globals.databases.app_namespace }}.svc.cluster.local +REDIS_HOST=redis-db.{{ .Release.Namespace }}.svc.cluster.local REDIS_PORT=6379 -REDIS_PWD={{ .Values.globals.databases.passwords.redis }} +REDIS_PWD=${redis-password} # OIDC +{{- $loginType := .Values.login.type | default "authhub" -}} +{{- if eq $loginType "bypass" }} DISABLE_LOGIN=False -DEFAULT_USER= -OIDC_APP_ID={{ .Values.euler_copilot.framework.login.oidc.client_id }} -OIDC_APP_SECRET={{ .Values.euler_copilot.framework.login.oidc.client_secret }} -OIDC_USER_URL={{ .Values.euler_copilot.framework.login.oidc.user_url }} -OIDC_TOKEN_URL={{ .Values.euler_copilot.framework.login.oidc.token_url }} -OIDC_REFRESH_TOKEN_URL={{ .Values.euler_copilot.framework.login.oidc.refresh_token_url }} -OIDC_REDIRECT_URL={{ .Values.euler_copilot.framework.login.oidc.redirect }} -EULER_LOGIN_API={{ .Values.euler_copilot.framework.login.oidc.euler_copilot_front }} +DEFAULT_USER= {{ .Values.login.uid }} +{{- else if eq $loginType "authhub" }} +OIDC_USER_URL=http://authhub-backend-service.{{ .Release.Namespace }}.svc.cluster.local:11120/oauth2/introspect +OIDC_TOKEN_URL=http://authhub-backend-service.{{ .Release.Namespace }}.svc.cluster.local:11120/oauth2/token +OIDC_REFRESH_TOKEN_URL=http://authhub-backend-service.{{ .Release.Namespace }}.svc.cluster.local:11120/oauth2/refresh-token +OIDC_REDIRECT_URL="https://{{ default "authhub.eulercopilot.local" .Values.domain.authhub }}/oauth2/authorize?client_id=${clientId}&redirect_uri=https://{{ default "www.eulercopilot.local" .Values.domain.euler_copilot }}/api/auth/login&scope=openid offline_access&access_type=offline&response_type=code&prompt=consent&state=235345&nonce=loser" +{{- else }} +OIDC_USER_URL={{ .Values.login.oidc.user_url }} +OIDC_TOKEN_URL={{ .Values.login.oidc.token_url }} +OIDC_REFRESH_TOKEN_URL={{ .Values.login.oidc.refresh_url }} +OIDC_REDIRECT_URL={{ .Values.login.oidc.redirect }} +{{- end }} +OIDC_APP_ID=${clientId} +OIDC_APP_SECRET=${clientSecret} +EULER_LOGIN_API=https://{{ default "www.eulercopilot.local" .Values.domain.euler_copilot }}/api/auth/login OIDC_ACCESS_TOKEN_EXPIRE_TIME=1440 OIDC_REFRESH_TOKEN_EXPIRE_TIME=1440 SESSION_TTL=30 @@ -27,19 +36,17 @@ SESSION_TTL=30 # Logging LOG="stdout" -# Vectorize -{{- if .Values.euler_copilot.framework.vectorize.use_internal }} -VECTORIZE_HOST="http://vectorize-agent-service-{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local:8001" -{{- else }} -VECTORIZE_HOST="{{ .Values.euler_copilot.framework.vectorize.url }}" -{{- end }} +# Embedding +EMBEDDING_URL={{ .Values.models.embedding.url }} +EMBEDDING_KEY={{ .Values.models.embedding.key }} +EMBEDDING_MODEL={{ .Values.models.embedding.name }} # RAG -RAG_HOST="http://rag-service-{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local:9988" +RAG_HOST="http://rag-service.{{ .Release.Namespace }}.svc.cluster.local:9988" # FastAPI -DOMAIN={{ .Values.globals.domain }} -JWT_KEY={{ .Values.euler_copilot.framework.jwtKey }} +DOMAIN={{ default "www.eulercopilot.local" .Values.domain.euler_copilot }} +JWT_KEY=${jwtKey} # 风控 DETECT_TYPE= @@ -48,43 +55,39 @@ DETECT_TYPE= ENABLE_CSRF=False # MongoDB -MONGODB_HOST=mongo-db-{{ .Values.globals.databases.app_name }}.{{ .Values.globals.databases.app_namespace }}.svc.cluster.local +MONGODB_HOST=mongo-db.{{ .Release.Namespace }}.svc.cluster.local MONGODB_PORT=27017 MONGODB_USER=euler_copilot -MONGODB_PWD={{ .Values.globals.databases.passwords.mongo }} +MONGODB_PWD=${mongo-password} MONGODB_DATABASE=euler_copilot # PostgreSQL -POSTGRES_HOST=pgsql-db-{{ .Values.globals.databases.app_name }}.{{ .Values.globals.databases.app_namespace }}.svc.cluster.local:5432 +POSTGRES_HOST=pgsql-db.{{ .Release.Namespace }}.svc.cluster.local:5432 POSTGRES_DATABASE=postgres POSTGRES_USER=postgres -POSTGRES_PWD={{ .Values.globals.databases.passwords.postgres }} +POSTGRES_PWD=${pgsql-password} # MinIO -MINIO_ENDPOINT=minio-service-{{ .Values.globals.databases.app_name }}.{{ .Values.globals.databases.app_namespace }}.svc.cluster.local:9000 -MINIO_ACCESS_KEY={{ .Values.globals.databases.passwords.minio.access_key }} -MINIO_SECRET_KEY={{ .Values.globals.databases.passwords.minio.secret_key }} +MINIO_ENDPOINT=minio-service.{{ .Release.Namespace }}.svc.cluster.local:9000 +MINIO_ACCESS_KEY=minioadmin +MINIO_SECRET_KEY=${minio-password} # Security -HALF_KEY1={{ .Values.euler_copilot.framework.half_keys.key1 }} -HALF_KEY2={{ .Values.euler_copilot.framework.half_keys.key2 }} -HALF_KEY3={{ .Values.euler_copilot.framework.half_keys.key3 }} - -# 模型类型 -MODEL=openai -# QA模型配置 -LLM_MODEL={{ .Values.globals.llm.model }} -LLM_URL={{ .Values.globals.llm.url }}/v1 -LLM_KEY={{ .Values.globals.llm.key }} -# 参数模型配置 -SCHEDULER_BACKEND={{ .Values.globals.scheduler.backend }} -SCHEDULER_MODEL={{ .Values.globals.scheduler.model }} -SCHEDULER_URL={{ .Values.globals.scheduler.url }} -SCHEDULER_API_KEY={{ .Values.globals.scheduler.key }} +HALF_KEY1=${halfKey1} +HALF_KEY2=${halfKey2} +HALF_KEY3=${halfKey3} + +# 问答模型配置 +LLM_MODEL={{ .Values.models.answer.name }} +LLM_URL={{ .Values.models.answer.url }}/v1 +LLM_KEY={{ .Values.models.answer.key }} +# FunctionCall模型配置 +SCHEDULER_BACKEND={{ default "ollama" .Values.models.functioncall.backend }} +SCHEDULER_MODEL={{ default .Values.models.answer.name .Values.models.functioncall.name }} +SCHEDULER_URL={{ default .Values.models.answer.url .Values.models.functioncall.url }} +SCHEDULER_API_KEY={{ default .Values.models.answer.key .Values.models.functioncall.key }} +SCHEDULER_MAX_TOKENS={{default .Values.models.answer.max_tokens .Values.models.functioncall.max_tokens }} # Agent PLUGIN_DIR=/euler-copilot-frame/apps/plugin SQL_URL= - -# 其他 -GITEE_WHITELIST= diff --git a/deploy/chart/euler_copilot/configs/framework/copy-config.yaml b/deploy/chart/euler_copilot/configs/framework/copy-config.yaml new file mode 100644 index 00000000..4198e2fe --- /dev/null +++ b/deploy/chart/euler_copilot/configs/framework/copy-config.yaml @@ -0,0 +1,7 @@ +copy: + - from: /config/.env + to: /config-rw/.env + mode: + uid: 1001 + gid: 1001 + mode: "0o650" \ No newline at end of file diff --git a/deploy/chart/euler_copilot/configs/rag-web/.env b/deploy/chart/euler_copilot/configs/rag-web/.env index 0e7e54c5..77fedc8d 100644 --- a/deploy/chart/euler_copilot/configs/rag-web/.env +++ b/deploy/chart/euler_copilot/configs/rag-web/.env @@ -1,3 +1,3 @@ PROD=enabled -SERVER_NAME={{ .Values.euler_copilot.rag_web.ingress.domain }} -DATA_CHAIN_BACEND_URL=http://rag-service-{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local:9988 +SERVER_NAME={{ default "witchaind.eulercopilot.local" .Values.domain.witchaind }} +DATA_CHAIN_BACEND_URL=http://rag-service.{{ .Release.Namespace }}.svc.cluster.local:9988 diff --git a/deploy/chart/euler_copilot/configs/rag/.env b/deploy/chart/euler_copilot/configs/rag/.env index 9f36cc1f..79f7b3b7 100644 --- a/deploy/chart/euler_copilot/configs/rag/.env +++ b/deploy/chart/euler_copilot/configs/rag/.env @@ -7,31 +7,29 @@ SSL_ENABLE=false LOG_METHOD=stdout # Postgres -DATABASE_URL=postgresql+asyncpg://postgres:{{ .Values.globals.databases.passwords.postgres }}@pgsql-db-{{ .Values.globals.databases.app_name }}.{{ .Values.globals.databases.app_namespace }}.svc.cluster.local:5432/postgres +DATABASE_URL=postgresql+asyncpg://postgres:${pgsql-password}@pgsql-db.{{ .Release.Namespace }}.svc.cluster.local:5432/postgres # MinIO -MINIO_ENDPOINT=minio-service-{{ .Values.globals.databases.app_name }}.{{ .Values.globals.databases.app_namespace }}.svc.cluster.local:9000 -MINIO_ACCESS_KEY={{ .Values.globals.databases.passwords.minio.access_key }} -MINIO_SECRET_KEY={{ .Values.globals.databases.passwords.minio.secret_key }} -MINIO_SECURE={{ .Values.globals.databases.passwords.minio.secure }} +MINIO_ENDPOINT=minio-service.{{ .Release.Namespace }}.svc.cluster.local:9000 +MINIO_ACCESS_KEY=minioadmin +MINIO_SECRET_KEY=${minio-password} +MINIO_SECURE=false # Redis -REDIS_HOST=redis-db-{{ .Values.globals.databases.app_name }}.{{ .Values.globals.databases.app_namespace }}.svc.cluster.local +REDIS_HOST=redis-db.{{ .Release.Namespace }}.svc.cluster.local REDIS_PORT=6379 -REDIS_PWD={{ .Values.globals.databases.passwords.redis }} +REDIS_PWD=${redis-password} # Task TASK_RETRY_TIME=3 # Embedding Service -{{- if .Values.euler_copilot.rag.vectorize.use_internal }} -REMOTE_EMBEDDING_ENDPOINT=http://vectorize-agent-service-{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local:8001/embedding -{{- else }} -REMOTE_EMBEDDING_ENDPOINT={{ .Values.euler_copilot.rag.vectorize.url }} -{{- end }} +EMBEDDING_ENDPOINT={{ .Values.models.embedding.url }}/embeddings +EMBEDDING_KEY={{ .Values.models.embedding.key }} +EMBEDDING_MODEL={{ .Values.models.embedding.name }} # Token -CSRF_KEY={{ .Values.euler_copilot.rag.security.csrf_key }} +CSRF_KEY=${csrfKey} SESSION_TTL=1440 # PROMPT_PATH @@ -40,13 +38,13 @@ PROMPT_PATH=/rag-service/data_chain/common/prompt.yaml STOP_WORDS_PATH=/rag-service/data_chain/common/stop_words.txt #Security -HALF_KEY1={{ .Values.euler_copilot.rag.security.half_key_1 }} -HALF_KEY2={{ .Values.euler_copilot.rag.security.half_key_2 }} -HALF_KEY3={{ .Values.euler_copilot.rag.security.half_key_3 }} +HALF_KEY1=${halfKey1} +HALF_KEY2=${halfKey2} +HALF_KEY3=${halfKey3} #LLM config -MODEL_NAME={{ .Values.globals.llm.model }} -OPENAI_API_BASE={{ .Values.globals.llm.url }}/v1 -OPENAI_API_KEY={{ .Values.globals.llm.key }} -REQUEST_TIMEOUT=120 -MAX_TOKENS={{ .Values.globals.llm.max_tokens }} +MODEL_NAME={{ .Values.models.answer.name }} +OPENAI_API_BASE={{ .Values.models.answer.url }}/v1 +OPENAI_API_KEY={{ default "" .Values.models.answer.key }} +REQUEST_TIMEOUT=60 +MAX_TOKENS={{ default 2048 .Values.models.answer.max_tokens }} diff --git a/deploy/chart/euler_copilot/configs/rag/copy-config.yaml b/deploy/chart/euler_copilot/configs/rag/copy-config.yaml new file mode 100644 index 00000000..6cbc9f12 --- /dev/null +++ b/deploy/chart/euler_copilot/configs/rag/copy-config.yaml @@ -0,0 +1,19 @@ +copy: + - from: /config/.env + to: /config-rw/.env + mode: + uid: 1001 + gid: 1001 + mode: "0o650" + - from: /config/prompt.yaml + to: /config-rw/prompt.yaml + mode: + uid: 1001 + gid: 1001 + mode: "0o650" + - from: /config/stop_words.txt + to: /config-rw/stop_words.txt + mode: + uid: 1001 + gid: 1001 + mode: "0o650" diff --git a/deploy/chart/euler_copilot/configs/vectorize/.env b/deploy/chart/euler_copilot/configs/vectorize/.env deleted file mode 100644 index 80b898bf..00000000 --- a/deploy/chart/euler_copilot/configs/vectorize/.env +++ /dev/null @@ -1,9 +0,0 @@ -UVICORN_IP=0.0.0.0 -UVICORN_PORT=8001 - -LOG=stdout - -DEVICE=cpu -EMBEDDING_MODEL={{ .Values.euler_copilot.vectorize.model.embedding }} -RERANK_MODEL={{ .Values.euler_copilot.vectorize.model.rerank }} -MODEL_BASE_DIR=/vectorize-agent/models/ \ No newline at end of file diff --git a/deploy/chart/euler_copilot/configs/web/.env b/deploy/chart/euler_copilot/configs/web/.env index 38fb235d..6a480d4a 100644 --- a/deploy/chart/euler_copilot/configs/web/.env +++ b/deploy/chart/euler_copilot/configs/web/.env @@ -1,3 +1,3 @@ PROD=enabled -SERVER_NAME={{ .Values.euler_copilot.web.ingress.domain }} -FRAMEWORK_URL=http://framework-service-{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local:8002 \ No newline at end of file +SERVER_NAME={{ default "www.eulercopilot.local" .Values.domain.euler_copilot }} +FRAMEWORK_URL=http://framework-service.{{ .Release.Namespace }}.svc.cluster.local:8002 \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/cornjob.yaml b/deploy/chart/euler_copilot/templates/cornjob.yaml new file mode 100644 index 00000000..e69de29b diff --git a/deploy/chart/euler_copilot/templates/framework/framework-secret.yaml b/deploy/chart/euler_copilot/templates/framework/framework-config.yaml similarity index 39% rename from deploy/chart/euler_copilot/templates/framework/framework-secret.yaml rename to deploy/chart/euler_copilot/templates/framework/framework-config.yaml index b84fd580..1cab8899 100644 --- a/deploy/chart/euler_copilot/templates/framework/framework-secret.yaml +++ b/deploy/chart/euler_copilot/templates/framework/framework-config.yaml @@ -1,11 +1,12 @@ -{{- if .Values.euler_copilot.framework.enabled }} +{{- if .Values.euler_copilot.framework.enabled -}} apiVersion: v1 -kind: Secret +kind: ConfigMap metadata: - name: framework-secret-{{ .Release.Name }} + name: framework-config namespace: {{ .Release.Namespace }} -type: Opaque -stringData: +data: .env: |- {{ tpl (.Files.Get "configs/framework/.env") . | indent 4 }} -{{- end }} \ No newline at end of file + copy-config.yaml: |- +{{ tpl (.Files.Get "configs/framework/copy-config.yaml") . | indent 4 }} +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/framework/framework-service.yaml b/deploy/chart/euler_copilot/templates/framework/framework-service.yaml deleted file mode 100644 index 0f6b91fa..00000000 --- a/deploy/chart/euler_copilot/templates/framework/framework-service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{- if .Values.euler_copilot.framework.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: framework-service-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.euler_copilot.framework.service.type }} - selector: - app: framework-{{ .Release.Name }} - ports: - - port: 8002 - targetPort: 8002 - {{- if (and (eq .Values.euler_copilot.framework.service.type "") .Values.euler_copilot.framework.service.nodePort) }} - nodePort: {{ .Values.euler_copilot.framework.service.nodePort }} - {{- end }} -{{- end }} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/framework/framework-storage.yaml b/deploy/chart/euler_copilot/templates/framework/framework-storage.yaml new file mode 100644 index 00000000..03997162 --- /dev/null +++ b/deploy/chart/euler_copilot/templates/framework/framework-storage.yaml @@ -0,0 +1,30 @@ +{{- if .Values.euler_copilot.framework.enabled -}} +--- +apiVersion: v1 +kind: PersistentVolume +metadata: + name: framework-semantics + namespace: {{ .Release.Namespace }} +spec: + storageClassName: {{ default "local-path" .Values.globals.storageClass }} + capacity: + storage: {{ default "5Gi" .Values.storage.framework_semantics.size }} + accessModes: + - ReadWriteOnce + hostPath: + path: {{ default "/home/eulercopilot/semantics" .Values.storage.framework_semantics.path }} + +--- +apiVersion: v1 +kind: PersistentVolumeClaim +metadata: + name: framework-semantics-claim + namespace: {{ .Release.Namespace }} +spec: + storageClassName: {{ default "local-path" .Values.globals.storageClass }} + accessModes: + - ReadWriteOnce + resources: + requests: + storage: {{ default "5Gi" .Values.storage.framework_semantics.size }} +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/framework/framework-deployment.yaml b/deploy/chart/euler_copilot/templates/framework/framework.yaml similarity index 32% rename from deploy/chart/euler_copilot/templates/framework/framework-deployment.yaml rename to deploy/chart/euler_copilot/templates/framework/framework.yaml index 111c5bae..5c04487f 100644 --- a/deploy/chart/euler_copilot/templates/framework/framework-deployment.yaml +++ b/deploy/chart/euler_copilot/templates/framework/framework.yaml @@ -1,29 +1,45 @@ -{{- if .Values.euler_copilot.framework.enabled }} +{{- if .Values.euler_copilot.framework.enabled -}} +--- +apiVersion: v1 +kind: Service +metadata: + name: framework-service + namespace: {{ .Release.Namespace }} +spec: + type: {{ default "ClusterIP" .Values.euler_copilot.framework.service.type }} + selector: + app: framework + ports: + - port: 8002 + targetPort: 8002 + nodePort: {{ default nil .Values.euler_copilot.framework.service.nodePort }} + +--- apiVersion: apps/v1 kind: Deployment metadata: - name: framework-deploy-{{ .Release.Name }} + name: framework-deploy namespace: {{ .Release.Namespace }} labels: - app: framework-{{ .Release.Name }} + app: framework spec: selector: matchLabels: - app: framework-{{ .Release.Name }} + app: framework template: metadata: annotations: - checksum/secret: {{ include (print $.Template.BasePath "/framework/framework-secret.yaml") . | sha256sum }} + checksum/secret: {{ include (print $.Template.BasePath "/framework/framework-config.yaml") . | sha256sum }} labels: - app: framework-{{ .Release.Name }} + app: framework spec: automountServiceAccountToken: false securityContext: fsGroup: 1001 containers: - name: framework - image: "{{if ne ( .Values.euler_copilot.framework.image.registry | toString ) ""}}{{ .Values.euler_copilot.framework.image.registry }}{{ else }}{{ .Values.globals.imageRegistry }}{{ end }}/{{ .Values.euler_copilot.framework.image.name }}:{{ .Values.euler_copilot.framework.image.tag | toString }}" - imagePullPolicy: {{ if ne ( .Values.euler_copilot.framework.image.imagePullPolicy | toString ) "" }}{{ .Values.euler_copilot.framework.image.imagePullPolicy }}{{ else }}{{ .Values.globals.imagePullPolicy }}{{ end }} + image: {{ default "hub.oepkgs.net/neocopilot/euler-copilot-framework:0.9.3-x86" .Values.euler_copilot.framework.image }} + imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8002 protocol: TCP @@ -42,13 +58,13 @@ spec: value: "enable" volumeMounts: - mountPath: /euler-copilot-frame/config - name: framework-shared-secret-volume + name: framework-shared - mountPath: /tmp name: framework-tmp-volume - mountPath: /euler-copilot-frame/apps/plugin - name: framework-plugins + name: framework-semantics-vl securityContext: - readOnlyRootFilesystem: {{ .Values.euler_copilot.framework.readOnly }} + readOnlyRootFilesystem: {{ default false .Values.euler_copilot.framework.readOnly }} capabilities: drop: - ALL @@ -57,39 +73,71 @@ spec: runAsNonRoot: true allowPrivilegeEscalation: false resources: - {{- toYaml .Values.euler_copilot.framework.resources | nindent 12 }} + requests: + cpu: 0.2 + memory: 512Mi + limits: + {{ toYaml .Values.euler_copilot.framework.resourceLimits | nindent 14 }} initContainers: - - name: framework-copy-secret - image: "{{if ne ( .Values.euler_copilot.init.image.registry | toString ) ""}}{{ .Values.euler_copilot.init.image.registry }}{{ else }}{{ .Values.globals.imageRegistry }}{{ end }}/{{ .Values.euler_copilot.init.image.name }}:{{ .Values.euler_copilot.init.image.tag | toString }}" - restartPolicy: Always - imagePullPolicy: {{ if ne ( .Values.euler_copilot.init.image.imagePullPolicy | toString ) "" }}{{ .Values.euler_copilot.init.image.imagePullPolicy }}{{ else }}{{ .Values.globals.imagePullPolicy }}{{ end }} - env: - - name: CHECK_URL - value: http://framework-service-{{ .Release.Name }}.{{ .Release.Namespace }}.svc.cluster.local:8002/health_check - - name: INTERVAL - value: "60" - - name: CONFIG_FILES - value: ".env" + - name: framework-copy + image: {{ default "hub.oepkgs.net/neocopilot/secret_inject:x86" .Values.euler_copilot.secret_inject.image }} + imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} volumeMounts: - - mountPath: /config - name: framework-secret-volume + - mountPath: /config/.env + name: framework-config + subPath: .env + - mountPath: /app/config.yaml + name: framework-config + subPath: copy-config.yaml - mountPath: /config-rw - name: framework-shared-secret-volume + name: framework-shared + - mountPath: /secrets/redis-password + name: database-secrets + subPath: redis-password + - mountPath: /secrets/mongo-password + name: database-secrets + subPath: mongo-password + - mountPath: /secrets/minio-password + name: database-secrets + subPath: minio-password + - mountPath: /secrets/pgsql-password + name: database-secrets + subPath: pgsql-password + - mountPath: /secrets/halfKey1 + name: system-secrets + subPath: halfKey1 + - mountPath: /secrets/halfKey2 + name: system-secrets + subPath: halfKey2 + - mountPath: /secrets/halfKey3 + name: system-secrets + subPath: halfKey3 + - mountPath: /secrets/jwtKey + name: system-secrets + subPath: jwtKey + - mountPath: /secrets/clientId + name: system-secrets + subPath: clientId + - mountPath: /secrets/clientSecret + name: system-secrets + subPath: clientSecret volumes: - - name: framework-secret-volume + - name: framework-config + configMap: + name: framework-config + - name: framework-semantics-vl + persistentVolumeClaim: + claimName: framework-semantics-claim + - name: database-secrets + secret: + secretName: euler-copilot-database + - name: system-secrets secret: - secretName: framework-secret-{{ .Release.Name }} - items: - - key: .env - path: .env - - name: framework-plugins - hostPath: - path: {{ .Values.euler_copilot.framework.volume.plugin_dir }} - type: Directory + secretName: euler-copilot-system - name: framework-tmp-volume emptyDir: medium: Memory - - name: framework-shared-secret-volume + - name: framework-shared emptyDir: medium: Memory -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/rag-web/rag-web-config.yaml b/deploy/chart/euler_copilot/templates/rag-web/rag-web-config.yaml index bd35c8c1..ebd01c6d 100644 --- a/deploy/chart/euler_copilot/templates/rag-web/rag-web-config.yaml +++ b/deploy/chart/euler_copilot/templates/rag-web/rag-web-config.yaml @@ -1,10 +1,10 @@ -{{- if .Values.euler_copilot.rag_web.enabled }} +{{- if .Values.euler_copilot.rag_web.enabled -}} apiVersion: v1 kind: ConfigMap metadata: - name: rag-web-config-{{ .Release.Name }} + name: rag-web-config namespace: {{ .Release.Namespace }} data: .env: |- {{ tpl (.Files.Get "configs/rag-web/.env") . | indent 4 }} -{{- end }} +{{- end -}} diff --git a/deploy/chart/euler_copilot/templates/rag-web/rag-web-ingress.yaml b/deploy/chart/euler_copilot/templates/rag-web/rag-web-ingress.yaml deleted file mode 100644 index 20e16873..00000000 --- a/deploy/chart/euler_copilot/templates/rag-web/rag-web-ingress.yaml +++ /dev/null @@ -1,19 +0,0 @@ -{{- if .Values.euler_copilot.rag_web.ingress.enabled }} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: rag-web-ingress-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} -spec: - rules: - - host: {{ .Values.euler_copilot.rag_web.ingress.domain }} - http: - paths: - - path: {{ .Values.euler_copilot.rag_web.ingress.prefix }} - pathType: Prefix - backend: - service: - name: rag-web-service-{{ .Release.Name }} - port: - number: 9888 -{{- end }} diff --git a/deploy/chart/euler_copilot/templates/rag-web/rag-web-service.yaml b/deploy/chart/euler_copilot/templates/rag-web/rag-web-service.yaml deleted file mode 100644 index d93f60bf..00000000 --- a/deploy/chart/euler_copilot/templates/rag-web/rag-web-service.yaml +++ /dev/null @@ -1,18 +0,0 @@ -{{- if .Values.euler_copilot.rag_web.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: rag-web-service-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.euler_copilot.rag_web.service.type }} - selector: - app: rag-web-{{ .Release.Name }} - ports: - - port: 9888 - targetPort: 9888 - {{- if (and (eq .Values.euler_copilot.rag_web.service.type "NodePort") .Values.euler_copilot.rag_web.service.nodePort) }} - nodePort: {{ .Values.euler_copilot.rag_web.service.nodePort }} - {{- end }} -{{- end }} - diff --git a/deploy/chart/euler_copilot/templates/rag-web/rag-web-deployment.yaml b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml similarity index 43% rename from deploy/chart/euler_copilot/templates/rag-web/rag-web-deployment.yaml rename to deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml index 12f41723..c5ebfaeb 100644 --- a/deploy/chart/euler_copilot/templates/rag-web/rag-web-deployment.yaml +++ b/deploy/chart/euler_copilot/templates/rag-web/rag-web.yaml @@ -1,26 +1,63 @@ -{{- if .Values.euler_copilot.rag_web.enabled }} +{{- if .Values.euler_copilot.rag_web.enabled -}} +--- +apiVersion: v1 +kind: Service +metadata: + name: rag-web-service + namespace: {{ .Release.Namespace }} +spec: + type: {{ default "ClusterIP" .Values.euler_copilot.rag_web.service.type }} + selector: + app: rag-web + ports: + - port: 9888 + targetPort: 9888 + nodePort: {{ default nil .Values.euler_copilot.rag_web.service.nodePort }} + +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: rag-web-ingress + namespace: {{ .Release.Namespace }} +spec: + rules: + - host: {{ default "witchaind.eulercopilot.local" .Values.domain.witchaind }} + http: + paths: + - path: {{ default "/" .Values.euler_copilot.rag_web.ingress.prefix }} + pathType: Prefix + backend: + service: + name: rag-web-service + port: + number: 9888 + +--- apiVersion: apps/v1 kind: Deployment metadata: - name: rag-web-deploy-{{ .Release.Name }} + name: rag-web-deploy namespace: {{ .Release.Namespace }} labels: - app: rag-web-{{ .Release.Name }} + app: rag-web spec: - replicas: {{ .Values.globals.replicaCount }} + replicas: {{ default 1 .Values.globals.replicaCount }} selector: matchLabels: - app: rag-web-{{ .Release.Name }} + app: rag-web template: metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/rag-web/rag-web-config.yaml") . | sha256sum }} labels: - app: rag-web-{{ .Release.Name }} + app: rag-web spec: automountServiceAccountToken: false containers: - name: rag-web - image: "{{if ne ( .Values.euler_copilot.rag_web.image.registry | toString ) ""}}{{ .Values.euler_copilot.rag_web.image.registry }}{{ else }}{{ .Values.globals.imageRegistry }}{{ end }}/{{ .Values.euler_copilot.rag_web.image.name }}:{{ .Values.euler_copilot.rag_web.image.tag | toString }}" - imagePullPolicy: {{ if ne ( .Values.euler_copilot.rag_web.image.imagePullPolicy | toString ) "" }}{{ .Values.euler_copilot.rag_web.image.imagePullPolicy }}{{ else }}{{ .Values.globals.imagePullPolicy }}{{ end }} + image: {{ default "hub.oepkgs.net/neocopilot/data_chain_web:0.9.3-x86" .Values.euler_copilot.rag_web.image }} + imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 9888 protocol: TCP @@ -44,16 +81,19 @@ spec: name: rag-web-env-volume subPath: .env resources: - {{- toYaml .Values.euler_copilot.rag_web.resources | nindent 12 }} - restartPolicy: Always + requests: + cpu: 0.05 + memory: 64Mi + limits: + {{ toYaml .Values.euler_copilot.rag_web.resourceLimits | nindent 14 }} volumes: - name: rag-web-config-volume emptyDir: medium: Memory - name: rag-web-env-volume configMap: - name: rag-web-config-{{ .Release.Name }} + name: rag-web-config - name: rag-web-tmp emptyDir: medium: Memory -{{- end }} +{{- end -}} diff --git a/deploy/chart/euler_copilot/templates/rag/rag-secret.yaml b/deploy/chart/euler_copilot/templates/rag/rag-config.yaml similarity index 61% rename from deploy/chart/euler_copilot/templates/rag/rag-secret.yaml rename to deploy/chart/euler_copilot/templates/rag/rag-config.yaml index 2ba83939..9ac1c758 100644 --- a/deploy/chart/euler_copilot/templates/rag/rag-secret.yaml +++ b/deploy/chart/euler_copilot/templates/rag/rag-config.yaml @@ -1,15 +1,16 @@ -{{- if .Values.euler_copilot.rag.enabled }} +{{- if .Values.euler_copilot.rag.enabled -}} apiVersion: v1 -kind: Secret +kind: ConfigMap metadata: - name: rag-secret-{{ .Release.Name }} + name: rag-config namespace: {{ .Release.Namespace }} -type: Opaque -stringData: +data: .env: |- {{ tpl (.Files.Get "configs/rag/.env") . | indent 4}} prompt.yaml: |- {{ tpl (.Files.Get "configs/rag/prompt.yaml") . | indent 4}} stop_words.txt: |- {{ tpl (.Files.Get "configs/rag/stop_words.txt") . | indent 4}} -{{- end }} \ No newline at end of file + copy-config.yaml: |- +{{ tpl (.Files.Get "configs/rag/copy-config.yaml") . | indent 4}} +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/rag/rag-deployment.yaml b/deploy/chart/euler_copilot/templates/rag/rag-deployment.yaml deleted file mode 100644 index 1b92d756..00000000 --- a/deploy/chart/euler_copilot/templates/rag/rag-deployment.yaml +++ /dev/null @@ -1,56 +0,0 @@ -{{- if .Values.euler_copilot.rag.enabled }} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: rag-deploy-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} - labels: - app: rag-{{ .Release.Name }} -spec: - replicas: {{ .Values.globals.replicaCount }} - selector: - matchLabels: - app: rag-{{ .Release.Name }} - template: - metadata: - annotations: - checksum/secret: {{ include (print $.Template.BasePath "/rag/rag-secret.yaml") . | sha256sum }} - labels: - app: rag-{{ .Release.Name }} - spec: - automountServiceAccountToken: false - containers: - - name: rag - image: "{{ if ne (.Values.euler_copilot.rag.image.registry | toString ) "" }}{{ .Values.euler_copilot.rag.image.registry }}{{ else }}{{ .Values.globals.imageRegistry }}{{ end }}/{{ .Values.euler_copilot.rag.image.name }}:{{ .Values.euler_copilot.rag.image.tag | toString }}" - imagePullPolicy: {{ if ne (.Values.euler_copilot.rag.image.imagePullPolicy | toString) "" }}{{ .Values.euler_copilot.rag.image.imagePullPolicy }}{{ else }}{{ .Values.globals.imagePullPolicy }}{{ end }} - ports: - - containerPort: 9988 - protocol: TCP - livenessProbe: - httpGet: - path: /health_check - port: 9988 - scheme: HTTP - failureThreshold: 5 - initialDelaySeconds: 60 - periodSeconds: 90 - env: - - name: TZ - value: "Asia/Shanghai" - volumeMounts: - - mountPath: /docker-entrypoint-initdb.d/init.sql - name: rag-config - - mountPath: /rag-service/data_chain/common - name: rag-common - resources: - {{- toYaml .Values.euler_copilot.rag.resources | nindent 12 }} - restartPolicy: Always - volumes: - - name: rag-config - secret: - secretName: rag-secret-{{ .Release.Name }} - - name: rag-common - secret: - secretName: rag-secret-{{ .Release.Name }} -{{- end }} - diff --git a/deploy/chart/euler_copilot/templates/rag/rag-service.yaml b/deploy/chart/euler_copilot/templates/rag/rag-service.yaml deleted file mode 100644 index 4086612d..00000000 --- a/deploy/chart/euler_copilot/templates/rag/rag-service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{- if .Values.euler_copilot.rag.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: rag-service-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.euler_copilot.rag.service.type }} - selector: - app: rag-{{ .Release.Name }} - ports: - - port: 9988 - targetPort: 9988 - {{- if (and (eq .Values.euler_copilot.rag.service.type "NodePort") .Values.euler_copilot.rag.service.nodePort) }} - nodePort: {{ .Values.euler_copilot.rag.service.nodePort }} - {{- end }} -{{- end }} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/rag/rag.yaml b/deploy/chart/euler_copilot/templates/rag/rag.yaml new file mode 100644 index 00000000..1c443b45 --- /dev/null +++ b/deploy/chart/euler_copilot/templates/rag/rag.yaml @@ -0,0 +1,118 @@ +{{- if .Values.euler_copilot.rag.enabled -}} +--- +apiVersion: v1 +kind: Service +metadata: + name: rag-service + namespace: {{ .Release.Namespace }} +spec: + type: {{ default "ClusterIP" .Values.euler_copilot.rag.service.type }} + selector: + app: rag + ports: + - port: 9988 + targetPort: 9988 + nodePort: {{ default nil .Values.euler_copilot.rag.service.nodePort }} + +--- +apiVersion: apps/v1 +kind: Deployment +metadata: + name: rag-deploy + namespace: {{ .Release.Namespace }} + labels: + app: rag +spec: + replicas: {{ default 1 .Values.globals.replicaCount }} + selector: + matchLabels: + app: rag + template: + metadata: + annotations: + checksum/config: {{ include (print $.Template.BasePath "/rag/rag-config.yaml") . | sha256sum }} + labels: + app: rag + spec: + automountServiceAccountToken: false + containers: + - name: rag + image: {{ default "hub.oepkgs.net/neocopilot/data_chain_agent:0.9.3-x86" .Values.euler_copilot.rag.image }} + imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} + ports: + - containerPort: 9988 + protocol: TCP + livenessProbe: + httpGet: + path: /health_check + port: 9988 + scheme: HTTP + failureThreshold: 5 + initialDelaySeconds: 60 + periodSeconds: 90 + env: + - name: TZ + value: "Asia/Shanghai" + volumeMounts: + - mountPath: /rag-service/data_chain/common + name: rag-shared + resources: + requests: + cpu: 0.25 + memory: 512Mi + limits: + {{ toYaml .Values.euler_copilot.rag.resourceLimits | nindent 14 }} + initContainers: + - name: rag-copy-secret + image: {{ default "hub.oepkgs.net/neocopilot/secret_inject:x86" .Values.euler_copilot.secret_inject.image }} + imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} + volumeMounts: + - mountPath: /config/.env + name: rag-config-vl + subPath: .env + - mountPath: /config/stop_words.txt + name: rag-config-vl + subPath: stop_words.txt + - mountPath: /config/prompt.yaml + name: rag-config-vl + subPath: prompt.yaml + - mountPath: /app/config.yaml + name: rag-config-vl + subPath: copy-config.yaml + - mountPath: /config-rw + name: rag-shared + - mountPath: /secrets/redis-password + name: database-secret + subPath: redis-password + - mountPath: /secrets/minio-password + name: database-secret + subPath: minio-password + - mountPath: /secrets/pgsql-password + name: database-secret + subPath: pgsql-password + - mountPath: /secrets/halfKey1 + name: system-secret + subPath: halfKey1 + - mountPath: /secrets/halfKey2 + name: system-secret + subPath: halfKey2 + - mountPath: /secrets/halfKey3 + name: system-secret + subPath: halfKey3 + - mountPath: /secrets/csrfKey + name: system-secret + subPath: csrfKey + volumes: + - name: rag-config-vl + configMap: + name: rag-config + - name: database-secret + secret: + secretName: euler-copilot-database + - name: system-secret + secret: + secretName: euler-copilot-system + - name: rag-shared + emptyDir: + medium: Memory +{{- end -}} diff --git a/deploy/chart/euler_copilot/templates/secrets.yaml b/deploy/chart/euler_copilot/templates/secrets.yaml new file mode 100644 index 00000000..db56b807 --- /dev/null +++ b/deploy/chart/euler_copilot/templates/secrets.yaml @@ -0,0 +1,32 @@ +{{- $systemSecret := (lookup "v1" "Secret" .Release.Namespace "euler-copilot-system") -}} +{{- if $systemSecret -}} +apiVersion: v1 +kind: Secret +metadata: + name: euler-copilot-system + namespace: {{ .Release.Namespace }} +type: Opaque +stringData: + jwtKey: {{ $systemSecret.data.jwtKey | b64dec }} + halfKey1: {{ $systemSecret.data.halfKey1 | b64dec }} + halfKey2: {{ $systemSecret.data.halfKey2 | b64dec }} + halfKey3: {{ $systemSecret.data.halfKey3 | b64dec }} + csrfKey: {{ $systemSecret.data.csrfKey | b64dec }} + clientId: {{ $systemSecret.data.clientId | b64dec }} + clientSecret: {{ $systemSecret.data.clientSecret | b64dec }} +{{- else -}} +apiVersion: v1 +kind: Secret +metadata: + name: euler-copilot-system + namespace: {{ .Release.Namespace }} +type: Opaque +stringData: + jwtKey: {{ randAlphaNum 32 | b64enc }} + halfKey1: {{ randAlphaNum 32 }} + halfKey2: {{ randAlphaNum 32 }} + halfKey3: {{ randAlphaNum 32 }} + csrfKey: {{ randAlphaNum 32 }} + clientId: {{ .Values.login.client.id }} + clientSecret: {{ .Values.login.client.secret }} +{{- end -}} diff --git a/deploy/chart/euler_copilot/templates/serviceaccount.yaml b/deploy/chart/euler_copilot/templates/serviceaccount.yaml new file mode 100644 index 00000000..e69de29b diff --git a/deploy/chart/euler_copilot/templates/vectorize/vectorize-deployment.yaml b/deploy/chart/euler_copilot/templates/vectorize/vectorize-deployment.yaml deleted file mode 100644 index ebe7d7b5..00000000 --- a/deploy/chart/euler_copilot/templates/vectorize/vectorize-deployment.yaml +++ /dev/null @@ -1,97 +0,0 @@ -{{- if .Values.euler_copilot.vectorize.enabled }} -apiVersion: apps/v1 -kind: Deployment -metadata: - name: vectorize-deploy-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} - labels: - app: vectorize-{{ .Release.Name }} -spec: - selector: - matchLabels: - app: vectorize-{{ .Release.Name }} - template: - metadata: - annotations: - checksum/secret: {{ include (print $.Template.BasePath "/vectorize/vectorize-secret.yaml") . | sha256sum }} - labels: - app: vectorize-{{ .Release.Name }} - spec: - automountServiceAccountToken: false - securityContext: - fsGroup: 1001 - containers: - - name: vectorize - image: "{{ if ne ( .Values.euler_copilot.vectorize.image.registry | toString) "" }}{{ .Values.euler_copilot.vectorize.image.registry }}{{ else }}{{ .Values.globals.imageRegistry }}{{ end }}/{{ .Values.euler_copilot.vectorize.image.name }}:{{ .Values.euler_copilot.vectorize.image.tag | toString }}" - imagePullPolicy: {{ if ne (.Values.euler_copilot.vectorize.image.imagePullPolicy | toString) "" }}{{ .Values.euler_copilot.vectorize.image.imagePullPolicy }}{{ else }}{{ .Values.globals.imagePullPolicy }}{{ end }} - ports: - - containerPort: 8001 - protocol: TCP - livenessProbe: - httpGet: - path: /health_check/ping - port: 8001 - scheme: HTTP - failureThreshold: 5 - initialDelaySeconds: 60 - periodSeconds: 90 - env: - - name: TZ - value: "Asia/Shanghai" - - name: HF_HOME - value: "/tmp" - - name: PROD - value: "enabled" - volumeMounts: - - mountPath: /vectorize-agent/config - name: vectorize-shared-secret-volume - - mountPath: /vectorize-agent/models - name: vectorize-models - - mountPath: /tmp - name: vectorize-tmp-volume - securityContext: - readOnlyRootFilesystem: {{ .Values.euler_copilot.vectorize.readOnly }} - capabilities: - drop: - - ALL - runAsUser: 1001 - runAsGroup: 1001 - runAsNonRoot: true - allowPrivilegeEscalation: false - resources: - {{- toYaml .Values.euler_copilot.vectorize.resources | nindent 12 }} - initContainers: - - name: vectorize-copy-secret - image: "{{ if ne ( .Values.euler_copilot.init.image.registry | toString ) "" }}{{ .Values.euler_copilot.init.image.registry }}{{ else }}{{ .Values.globals.imageRegistry }}{{ end }}/{{ .Values.euler_copilot.init.image.name }}:{{ .Values.euler_copilot.init.image.tag | toString }}" - restartPolicy: Always - imagePullPolicy: {{ if ne ( .Values.euler_copilot.init.image.imagePullPolicy | toString ) "" }}{{ .Values.euler_copilot.init.image.imagePullPolicy }}{{ else }}{{ .Values.globals.imagePullPolicy }}{{ end }} - env: - - name: CHECK_URL - value: "http://vectorize-agent-service-{{ .Release.Name }}.euler-copilot.svc.cluster.local:8001/health_check/ping" - - name: INTERVAL - value: "60" - - name: CONFIG_FILES - value: ".env" - volumeMounts: - - mountPath: /config - name: vectorize-secret-volume - - mountPath: /config-rw - name: vectorize-shared-secret-volume - volumes: - - name: vectorize-secret-volume - secret: - secretName: vectorize-secret-{{ .Release.Name }} - items: - - key: .env - path: .env - - name: vectorize-models - hostPath: - path: {{ .Values.euler_copilot.vectorize.volume.models }} - type: Directory - - name: vectorize-shared-secret-volume - emptyDir: - medium: Memory - - name: vectorize-tmp-volume - emptyDir: - medium: Memory -{{- end }} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/vectorize/vectorize-secret.yaml b/deploy/chart/euler_copilot/templates/vectorize/vectorize-secret.yaml deleted file mode 100644 index 84f2e603..00000000 --- a/deploy/chart/euler_copilot/templates/vectorize/vectorize-secret.yaml +++ /dev/null @@ -1,11 +0,0 @@ -{{- if .Values.euler_copilot.vectorize.enabled }} -apiVersion: v1 -kind: Secret -metadata: - name: vectorize-secret-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} -type: Opaque -stringData: - .env: |- -{{ tpl (.Files.Get "configs/vectorize/.env") . | indent 4 }} -{{- end }} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/vectorize/vectorize-service.yaml b/deploy/chart/euler_copilot/templates/vectorize/vectorize-service.yaml deleted file mode 100644 index c27cbd96..00000000 --- a/deploy/chart/euler_copilot/templates/vectorize/vectorize-service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{- if .Values.euler_copilot.vectorize.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: vectorize-agent-service-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.euler_copilot.vectorize.service.type }} - selector: - app: vectorize-{{ .Release.Name }} - ports: - - port: 8001 - targetPort: 8001 - {{- if (and (eq .Values.euler_copilot.vectorize.service.type "NodePort") .Values.euler_copilot.vectorize.service.nodePort) }} - nodePort: {{ .Values.euler_copilot.vectorize.service.nodePort }} - {{- end }} -{{- end }} diff --git a/deploy/chart/euler_copilot/templates/web/web-config.yaml b/deploy/chart/euler_copilot/templates/web/web-config.yaml index 089344a9..ee47374a 100644 --- a/deploy/chart/euler_copilot/templates/web/web-config.yaml +++ b/deploy/chart/euler_copilot/templates/web/web-config.yaml @@ -1,10 +1,10 @@ -{{- if .Values.euler_copilot.web.enabled }} +{{- if .Values.euler_copilot.web.enabled -}} apiVersion: v1 kind: ConfigMap metadata: - name: web-config-{{ .Release.Name }} + name: web-config namespace: {{ .Release.Namespace }} data: .env: |- {{ tpl (.Files.Get "configs/web/.env") . | indent 4 }} -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/web/web-ingress.yaml b/deploy/chart/euler_copilot/templates/web/web-ingress.yaml deleted file mode 100644 index 46eca47c..00000000 --- a/deploy/chart/euler_copilot/templates/web/web-ingress.yaml +++ /dev/null @@ -1,19 +0,0 @@ -{{- if .Values.euler_copilot.web.ingress.enabled }} -apiVersion: networking.k8s.io/v1 -kind: Ingress -metadata: - name: web-ingress-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} -spec: - rules: - - host: {{ .Values.globals.domain }} - http: - paths: - - path: {{ .Values.euler_copilot.web.ingress.prefix }} - pathType: Prefix - backend: - service: - name: web-service-{{ .Release.Name }} - port: - number: 8080 -{{- end }} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/web/web-service.yaml b/deploy/chart/euler_copilot/templates/web/web-service.yaml deleted file mode 100644 index 43f70fef..00000000 --- a/deploy/chart/euler_copilot/templates/web/web-service.yaml +++ /dev/null @@ -1,17 +0,0 @@ -{{- if .Values.euler_copilot.web.enabled }} -apiVersion: v1 -kind: Service -metadata: - name: web-service-{{ .Release.Name }} - namespace: {{ .Release.Namespace }} -spec: - type: {{ .Values.euler_copilot.web.service.type }} - selector: - app: web-{{ .Release.Name }} - ports: - - port: 8080 - targetPort: 8080 - {{- if (and (eq .Values.euler_copilot.web.service.type "NodePort") .Values.euler_copilot.web.service.nodePort) }} - nodePort: {{ .Values.euler_copilot.web.service.nodePort }} - {{- end }} -{{- end }} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/templates/web/web-deployment.yaml b/deploy/chart/euler_copilot/templates/web/web.yaml similarity index 52% rename from deploy/chart/euler_copilot/templates/web/web-deployment.yaml rename to deploy/chart/euler_copilot/templates/web/web.yaml index 05d8f3b7..f77ffd49 100644 --- a/deploy/chart/euler_copilot/templates/web/web-deployment.yaml +++ b/deploy/chart/euler_copilot/templates/web/web.yaml @@ -1,29 +1,64 @@ -{{- if .Values.euler_copilot.web.enabled }} +{{- if .Values.euler_copilot.web.enabled -}} +--- +apiVersion: v1 +kind: Service +metadata: + name: web-service + namespace: {{ .Release.Namespace }} +spec: + type: {{ default "ClusterIP" .Values.euler_copilot.web.service.type }} + selector: + app: web + ports: + - port: 8080 + targetPort: 8080 + nodePort: {{ default nil .Values.euler_copilot.web.service.nodePort }} + +--- +apiVersion: networking.k8s.io/v1 +kind: Ingress +metadata: + name: web-ingress + namespace: {{ .Release.Namespace }} +spec: + rules: + - host: {{ default "www.eulercopilot.local" .Values.domain.euler_copilot }} + http: + paths: + - path: {{ default "/" .Values.euler_copilot.web.ingress.prefix }} + pathType: Prefix + backend: + service: + name: web-service + port: + number: 8080 + +--- apiVersion: apps/v1 kind: Deployment metadata: - name: web-deploy-{{ .Release.Name }} + name: web-deploy namespace: {{ .Release.Namespace }} labels: - app: web-{{ .Release.Name }} + app: web spec: selector: matchLabels: - app: web-{{ .Release.Name }} + app: web template: metadata: annotations: checksum/config: {{ include (print $.Template.BasePath "/web/web-config.yaml") . | sha256sum }} labels: - app: web-{{ .Release.Name }} + app: web spec: automountServiceAccountToken: false securityContext: fsGroup: 1001 containers: - name: web - image: "{{ if ne ( .Values.euler_copilot.web.image.registry | toString ) ""}}{{ .Values.euler_copilot.web.image.registry }}{{ else }}{{ .Values.globals.imageRegistry }}{{ end }}/{{ .Values.euler_copilot.web.image.name }}:{{ .Values.euler_copilot.web.image.tag | toString }}" - imagePullPolicy: {{ if ne ( .Values.euler_copilot.web.image.imagePullPolicy | toString ) "" }}{{ .Values.euler_copilot.web.image.imagePullPolicy }}{{ else }}{{ .Values.globals.imagePullPolicy }}{{ end }} + image: {{ default "hub.oepkgs.net/neocopilot/euler-copilot-web:0.9.3-x86" .Values.euler_copilot.web.image }} + imagePullPolicy: {{ default "IfNotPresent" .Values.globals.imagePullPolicy }} ports: - containerPort: 8080 protocol: TCP @@ -47,9 +82,13 @@ spec: name: web-env-volume subPath: .env resources: - {{- toYaml .Values.euler_copilot.web.resources | nindent 12 }} + requests: + cpu: 0.05 + memory: 64Mi + limits: + {{ toYaml .Values.euler_copilot.web.resourceLimits | nindent 14 }} securityContext: - readOnlyRootFilesystem: {{ .Values.euler_copilot.web.readOnly }} + readOnlyRootFilesystem: {{ default false .Values.euler_copilot.web.readOnly }} capabilities: drop: - ALL @@ -64,8 +103,8 @@ spec: medium: Memory - name: web-env-volume configMap: - name: web-config-{{ .Release.Name }} + name: web-config - name: web-tmp emptyDir: medium: Memory -{{- end }} \ No newline at end of file +{{- end -}} \ No newline at end of file diff --git a/deploy/chart/euler_copilot/values.yaml b/deploy/chart/euler_copilot/values.yaml index 6aceafd2..a8d2c038 100644 --- a/deploy/chart/euler_copilot/values.yaml +++ b/deploy/chart/euler_copilot/values.yaml @@ -1,267 +1,169 @@ # 全局设置 globals: - # [必填] 镜像仓库 - imageRegistry: "hub.oepkgs.net/neocopilot" - # [必填] 镜像拉取策略 - imagePullPolicy: IfNotPresent - # 用于问答和推理的大模型(OpenAI兼容) - llm: - # [必填] 模型URL - url: "" - # [必填] 模型 API Key - key: "" - # [必填] 模型名称 - model: "" - # [必填] 模型最大token数 - max_tokens: 8096 - # 用于Function Call的模型 - scheduler: - # [必填] 推理框架类型,可以是vllm、sglang、ollama - backend: vllm - # [必填] 模型地址 - url: "" - # [必填] 模型 API Key - key: "" + # 镜像拉取策略, 默认为IfNotPresent + imagePullPolicy: + # 存储类;默认为local-path + storageClass: + +# 模型设置 +models: + # 用于问答的大模型;需要为OpenAI兼容接口 + answer: + # [必填] 接口URL;需要带上“v1”等后缀 + url: + # [必填] 接口API Key;默认置空 + key: # [必填] 模型名称 - model: "" - # 数据库设置 - databases: - # [必填] database helm安装时的app name - app_name: "databases" - # [必填] database helm安装时的namespace - app_namespace: "euler_copilot" - # 数据库密码 - passwords: - # [必填] Mongo数据库的密码 - mongo: "admin123" - # [必填] Redis数据库的密码 - redis: "admin123" - # [必填] PostgreSQL数据库密码 - postgres: "admin123" - # MinIO连接信息 - minio: - # [必填] MinIO AK - access_key: "minioadmin" - # [必填] MinIO SK - secret_key: "admin123" - # [必填] MinIO 是否启用安全连接 - secure: false + name: + # [必填] 模型最大上下文数;建议>=8192 + ctx_length: 8192 + # 模型最大输出长度,建议>=2048 + max_tokens: 2048 + # 用于Function Call的模型;建议使用特定推理框架 + functioncall: + # 推理框架类型,默认为ollama + # 可用的框架类型:["vllm", "sglang", "ollama", "openai"] + backend: + # 模型地址;不填则与问答模型一致 + url: + # API Key;不填则与问答模型一致 + key: + # 模型名称;不填则与问答模型一致 + model: + # 模型最大上下文数;不填则与问答模型一致 + ctx_length: + # 模型最大输出长度;不填则与问答模型一致 + max_tokens: + # 用于数据向量化(Embedding)的模型 + embedding: + # [必填] Embedding URL;需要带上“v1”等后缀 + url: + # [必填] Embedding 模型API Key + key: + # [必填] Embedding 模型名称 + name: + +# 登录设置 +login: + # 登录类型;默认为authhub + # 可用的类型:["authhub", "oidc", "linux", "bypass"] + type: + # 固定UID设置,仅在type为bypass时有效 + uid: + # 客户端ID设置,仅在type为authhub和oidc时有效 + client: + # [必填] 客户端ID + id: + # [必填] 客户端密钥 + secret: + # OIDC设置,仅在type为oidc时有效 + oidc: + # OIDC AccessToken获取地址 + token_url: + # OIDC UserToken获取地址 + user_url: + # OIDC RefreshToken地址 + refresh_url: + # OIDC登录跳转地址 + redirect: + +# 域名设置 +domain: + # 用于WitchainD的域名;默认为witchaind.eulercopilot.local + witchaind: + # 用于EulerCopilot的域名;默认为www.eulercopilot.local + euler_copilot: + # 部署authhub时使用的域名;默认为suthhub.eulercopilot.local + authhub: + +# 存储设置 +storage: + # 语义接口 + framework_semantics: + # 语义接口地址 + path: + # 语义接口存储大小,默认为5GB + size: euler_copilot: - # 配置文件安全复制工具 - init: - # 镜像设置 - image: - # 镜像仓库。留空则使用全局设置。 - registry: "" - # [必填] 镜像名 - name: secret_inject - # [必填] 镜像标签,为x86或arm - tag: x86 - # 拉取策略。留空则使用全局设置。 - imagePullPolicy: "" - - vectorize: - # [必填] 是否部署Vectorize模型服务工具 - enabled: true - # 镜像设置 - image: - # 镜像仓库。留空则使用全局设置。 - registry: "" - # [必填] 镜像名 - name: euler-copilot-vectorize-agent - # [必填] 镜像标签, 为0.9.3-x86或0.9.3-arm - tag: "0.9.3-x86" - # 拉取策略。留空则使用全局设置。 - imagePullPolicy: "" - # [必填] 容器根目录只读 - readOnly: true - # 性能限制设置 - resources: {} - # Volume设置 - volume: - # [必填] Embedding模型的位置 - models: "/home/EulerCopilot/models" - # Service设置 - service: - # [必填] Service类型,ClusterIP或NodePort - type: ClusterIP - # 当类型为nodePort时,填写主机的端口号 - nodePort: "" - # 模型名称 - model: - # [必填] Embedding模型名称 - embedding: bge-mixed-model - # [必填] 检索模型名称 - rerank: bge-reranker-large + # 配置文件工具 + secret_inject: + # 镜像设置;默认为hub.oepkgs.net/neocopilot/secret_inject:x86 + # 镜像标签:["x86", "arm"] + image: "hub.oepkgs.net/neocopilot/secret_inject:dev" framework: # [必填] 是否部署Framework后端框架服务 enabled: true - # 镜像设置 + # 镜像设置;默认为hub.oepkgs.net/neocopilot/euler-copilot-framework:0.9.3-x86 + # 镜像标签:["0.9.3-x86", "0.9.3-arm"] image: - # 镜像仓库。留空则使用全局设置。 - registry: "" - # [必填] 镜像名 - name: euler-copilot-framework - # [必填] 镜像标签,为0.9.3-x86或0.9.3-arm - tag: "0.9.3-x86" - # 拉取策略。留空则使用全局设置 - imagePullPolicy: "" - # [必填] 容器根目录只读 - readOnly: false + # 容器根目录只读 + readOnly: # 性能限制设置 - resources: {} + resourceLimits: {} # Service设置 service: - # [必填] Service类型,ClusterIP或NodePort - type: ClusterIP + # Service类型,例如NodePorts + type: # 当类型为nodePort时,填写主机的端口号 - nodePort: "" - # Volume设置 - volume: - # [必填] 插件包路径 - plugin_dir: "" # 修改为实际的插件文件夹地址 - # [必填] Vectorize服务地址 - vectorize: - # [必填] 是否使用内部Vectorize服务 - use_internal: true - # Vectorize服务url - url: "" - # [必填] JWT Key - jwtKey: 13e46d8963c997814f996c3294ccc92d - # 加密密钥设置 - half_keys: - # [必填] 加密密钥1 - key1: "123456" - # [必填] 加密密钥2 - key2: "123456" - # [必填] 加密密钥3 - key3: "123456" - # [必填] Web前端地址,需要添加http/https前缀 - web_url: "" - # 登录设置 - login: - # [必填] 是否启用登录 - enabled: true - # [enabled为false时必填] 若不启用登录,则需要手动填写默认登录的用户ID - user_id: "" - # OIDC 设置 - oidc: - # [enabled为true时必填] OIDC 客户端ID - client_id: "" - # [enabled为true时必填] OIDC 客户端密钥 - client_secret: "" - # [enabled为true时必填] OIDC Token获取地址 - token_url: http://authhub-backend-service-authhub.euler-copilot.svc.cluster.local:11120/oauth2/token - # [enabled为true时必填] OIDC 用户信息地址 - user_url: http://authhub-backend-service-authhub.euler-copilot.svc.cluster.local:11120/oauth2/introspect - # [enabled为true时必填] OIDC 刷新Token地址 - refresh_token_url: http://authhub-backend-service-authhub.euler-copilot.svc.cluster.local:11120/oauth2/refresh-token - # [enabled为true时必填] EulerCopilot主页地址; 替换为 EulerCopilot 实际的域名 - euler_copilot_front: https:///api/auth/login - # [enabled为true时必填] OIDC登录跳转地址:请将修改为authhub实际域名, 替换为实际的Client ID,将替换为EulerCopilot域名 - redirect: https:///oauth2/authorize?client_id=&redirect_uri=https:///api/auth/login&scope=openid offline_access&access_type=offline&response_type=code&prompt=consent&state=235345&nonce=loser + nodePort: web: # [必填] 是否部署Web前端用户界面 enabled: true - # 镜像设置 + # 镜像设置;默认为hub.oepkgs.net/neocopilot/euler-copilot-web:0.9.3-x86 + # 镜像标签:["0.9.3-x86", "0.9.3-arm"] image: - # 镜像仓库。留空则使用全局设置。 - registry: "" - # [必填] 镜像名 - name: euler-copilot-web - # [必填] 镜像标签,为0.9.3-x86或0.9.3-arm - tag: "0.9.3-x86" - # 拉取策略。留空则使用全局设置 - imagePullPolicy: "" - # [必填] 容器根目录只读 - readOnly: true + # 容器根目录只读 + readOnly: # 性能限制设置 - resources: {} + resourceLimits: {} # Service设置 service: - # [必填] Service类型,ClusterIP或NodePort - type: ClusterIP - nodePort: "" + # Service类型,例如NodePort + type: + # 当类型为NodePort时,填写主机的端口号 + nodePort: # Ingress设置 ingress: - # [必填] 是否启用Ingress - enabled: true - # [必填] URI前缀 - prefix: / - # [必填] 部署域名 - # 需要修改为EulerCopilot域名。单节点部署时,服务基于Host进行区分,无法使用IP地址 - domain: "" + # URI前缀,默认为/ + prefix: rag_web: # [必填] 是否部署RAG Web前端用户界面 enabled: true - # 镜像设置 + # 镜像设置;默认为hub.oepkgs.net/neocopilot/data_chain_web:0.9.3-x86 + # 镜像标签:["0.9.3-x86", "0.9.3-arm"] image: - # 镜像仓库。留空则使用全局设置。 - registry: "" - # [必填] 镜像名 - name: data_chain_web - # [必填] 镜像标签,为0.9.3-x86或0.9.3-arm - tag: "0.9.3-x86" - # 拉取策略。留空则使用全局设置 - imagePullPolicy: "" - # [必填] 容器根目录只读 - readOnly: true + # 容器根目录只读 + readOnly: # 性能限制设置 - resources: {} + resourceLimits: {} # Service设置 service: - # [必填] Service类型,ClusterIP或NodePort - type: ClusterIP - nodePort: "" + # Service类型,例如NodePort + type: + # 当类型为NodePort时,填写主机的端口号 + nodePort: # Ingress设置 ingress: - # [必填] 是否启用Ingress - enabled: true - # [必填] URI前缀 - prefix: / - # [必填] 部署域名 - # 需要修改为WitchainD域名。单节点部署时,服务基于Host进行区分,无法使用IP地址 - domain: "" + # URI前缀;默认为/ + prefix: rag: # [必填] 是否部署RAG后端服务 enabled: true - # 镜像设置 + # 镜像设置;默认为hub.oepkgs.net/neocopilot/data_chain_back_end:0.9.3-x86 + # 镜像标签:["0.9.3-x86", "0.9.3-arm"] image: - # 镜像仓库。留空则使用全局设置。 - registry: "" - # [必填] 镜像名 - name: data_chain_back_end - # [必填] 镜像标签,为0.9.3-x86或0.9.3-arm - tag: "0.9.3-x86" - # 拉取策略。留空则使用全局设置 - imagePullPolicy: "" - # [必填] 容器根目录只读 - readOnly: true + # 容器根目录只读 + readOnly: # 性能限制设置 - resources: {} + resourceLimits: {} # Service设置 service: - # [必填] Service类型,ClusterIP或NodePort - type: ClusterIP - nodePort: "" - # [必填] Embedding模型URL - vectorize: - # [必填] 是否使用内部Vectorize服务 - use_internal: true - # Vectorize服务url - url: "" - # [必填] 密钥设置 - security: - # [必填] CSRF密钥 - csrf_key: "123456" - # [必填] 工作密钥1 - half_key_1: "123456" - # [必填] 工作密钥2 - half_key_2: "123456" - # [必填] 工作密钥3 - half_key_3: "123456" + # Service类型,例如NodePort + type: + # 当类型为NodePort时,填写主机的端口号 + nodePort: -- Gitee From e2c7ca59e8a7b30b1c6c109636c4525a7a9b3a70 Mon Sep 17 00:00:00 2001 From: z30057876 Date: Thu, 13 Feb 2025 16:57:20 +0800 Subject: [PATCH 5/6] =?UTF-8?q?=E9=85=8D=E7=BD=AE=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E6=9D=A1=E7=9B=AE?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/common/config.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/apps/common/config.py b/apps/common/config.py index 12da81e2..a3f3b742 100644 --- a/apps/common/config.py +++ b/apps/common/config.py @@ -80,7 +80,7 @@ class ConfigModel(BaseModel): LLM_MAX_TOKENS: int = Field(description="OpenAI API 最大Token数", default=8192) LLM_TEMPERATURE: float = Field(description="OpenAI API 温度", default=0.7) # 参数提取 - SCHEDULER_TYPE: Optional[str] = Field(description="参数猜解后端", default=None) + SCHEDULER_BACKEND: Optional[str] = Field(description="参数猜解后端", default=None) SCHEDULER_MODEL: Optional[str] = Field(description="参数猜解模型名", default=None) SCHEDULER_URL: Optional[str] = Field(description="参数猜解 URL地址", default=None) SCHEDULER_API_KEY: Optional[str] = Field(description="参数猜解 API密钥", default=None) -- Gitee From 5cac7cb17d870eb80666db8dc85f9bcb898acc07 Mon Sep 17 00:00:00 2001 From: z30057876 Date: Thu, 13 Feb 2025 16:58:41 +0800 Subject: [PATCH 6/6] =?UTF-8?q?Prompt=E6=94=B9=E5=8A=A8?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- apps/entities/plugin.py | 2 +- apps/llm/patterns/core.py | 4 +- apps/llm/patterns/domain.py | 5 +- apps/llm/patterns/executor.py | 91 ++++++++++++++++++----------------- apps/llm/patterns/facts.py | 9 ++-- apps/llm/patterns/json.py | 1 - apps/manager/session.py | 7 +-- 7 files changed, 60 insertions(+), 59 deletions(-) diff --git a/apps/entities/plugin.py b/apps/entities/plugin.py index 6c5a756b..0cf67656 100644 --- a/apps/entities/plugin.py +++ b/apps/entities/plugin.py @@ -75,7 +75,7 @@ class SysCallVars(BaseModel): class ExecutorBackground(BaseModel): """Executor的背景信息""" - conversation: list[dict[str, str]] = Field(description="当前Executor的背景信息") + conversation: list[dict[str, str]] = Field(description="当前Executor的上下文对话") facts: list[str] = Field(description="当前Executor的背景信息") thought: str = Field(description="之前Executor的思考内容", default="") diff --git a/apps/llm/patterns/core.py b/apps/llm/patterns/core.py index a19ba8df..fc245593 100644 --- a/apps/llm/patterns/core.py +++ b/apps/llm/patterns/core.py @@ -29,8 +29,8 @@ class CorePattern(ABC): if user_prompt is not None: self.user_prompt = user_prompt - if not self.system_prompt or not self.user_prompt: - err = "必须设置系统提示词和用户提示词!" + if not self.user_prompt: + err = "必须设置用户提示词!" raise ValueError(err) self.system_prompt = dedent(self.system_prompt).strip("\n") diff --git a/apps/llm/patterns/domain.py b/apps/llm/patterns/domain.py index 91238973..3036bda8 100644 --- a/apps/llm/patterns/domain.py +++ b/apps/llm/patterns/domain.py @@ -12,9 +12,6 @@ from apps.llm.reasoning import ReasoningLLM class Domain(CorePattern): """从问答中提取领域信息""" - system_prompt: str = "" - """系统提示词(暂不使用)""" - user_prompt: str = r""" 根据对话上文,提取推荐系统所需的关键词标签,要求: 1. 实体名词、技术术语、时间范围、地点、产品等关键信息均可作为关键词标签 @@ -53,7 +50,7 @@ class Domain(CorePattern): async def generate(self, task_id: str, **kwargs) -> list[str]: # noqa: ANN003 """从问答中提取领域信息""" - messages = [{"role": "system", "content": self.system_prompt}] + messages = [{"role": "system", "content": ""}] messages += kwargs["conversation"] messages += [{"role": "user", "content": self.user_prompt}] diff --git a/apps/llm/patterns/executor.py b/apps/llm/patterns/executor.py index 726d0f1f..f259e712 100644 --- a/apps/llm/patterns/executor.py +++ b/apps/llm/patterns/executor.py @@ -14,24 +14,22 @@ from apps.llm.reasoning import ReasoningLLM class ExecutorThought(CorePattern): """通过大模型生成Executor的思考内容""" - system_prompt: str = r""" - You are an intelligent assistant equipped with tools to access necessary information. - Your task is to: succinctly summarize the tool usage process, provide your insights, and propose the next logical action. - """ + system_prompt: str = "" """系统提示词""" user_prompt: str = r""" - You previously utilized a tool named "{tool_name}" which performs the function of "{tool_description}". \ - The tool's generated output is: `{tool_output}` (with "message" as the natural language content and "output" as structured data). + 你是一个可以使用工具的智能助手。请简明扼要地总结工具的使用过程,提供你的见解,并给出下一步的行动。 + + 你之前使用了一个名为"{tool_name}"的工具,该工具的功能是"{tool_description}"。\ + 工具生成的输出是:`{tool_output}`(其中"message"是自然语言内容,"output"是结构化数据)。 - Your earlier thoughts were: + 你之前的思考是: {last_thought} - The current question you seek to resolve is: + 你当前需要解决的问题是: {user_question} - Consider the above information thoroughly; articulate your thoughts methodically, step by step. - Begin. + 请综合以上信息,再次一步一步地进行思考,并给出见解和行动: """ """用户提示词""" @@ -50,7 +48,7 @@ class ExecutorThought(CorePattern): raise ValueError(err) from e messages = [ - {"role": "system", "content": self.system_prompt}, + {"role": "system", "content": ""}, {"role": "user", "content": self.user_prompt.format( last_thought=last_thought, user_question=user_question, @@ -61,7 +59,7 @@ class ExecutorThought(CorePattern): ] result = "" - async for chunk in ReasoningLLM().call(task_id, messages, streaming=False, temperature=1.0): + async for chunk in ReasoningLLM().call(task_id, messages, streaming=False, temperature=0.7): result += chunk return result @@ -74,17 +72,20 @@ class ExecutorBackground(CorePattern): """系统提示词""" user_prompt: str = r""" - 根据对话上文,生成一个完整的背景总结。这个总结将用于后续对话的上下文理解。 + 根据对话上文,结合给定的AI助手思考过程,生成一个完整的背景总结。这个总结将用于后续对话的上下文理解。 生成总结的要求如下: 1. 突出重要信息点,例如时间、地点、人物、事件等。 2. 下面给出的事实条目若与历史记录有关,则可以在生成总结时作为已知信息。 3. 确保信息准确性,不得编造信息。 4. 总结应少于1000个字。 + 思考过程(在标签中): + {thought} + 关键事实(在标签中): {facts} - 开始生成: + 现在,请开始生成背景总结: """ """用户提示词""" @@ -97,23 +98,25 @@ class ExecutorBackground(CorePattern): background: ExecutorBackgroundEntity = kwargs["background"] # 转化字符串 - message_str = "" + messages = [] for item in background.conversation: - message_str += f"[{item['role']}] {item['content']}\n" - facts_str = "" + messages += [{"role": item["role"], "content": item["content"]}] + + facts_str = "\n" for item in background.facts: facts_str += f"- {item}\n" + facts_str += "" + if not background.thought: - background.thought = "这是新的对话,我还没有思考过。" + background.thought = "\n这是新的对话,我还没有思考过。\n" + else: + background.thought = f"\n{background.thought}\n" - user_input = self.user_prompt.format( - conversation=message_str, - facts=facts_str, - thought=background.thought, - ) - messages = [ - {"role": "system", "content": self.system_prompt}, - {"role": "user", "content": user_input}, + messages += [ + {"role": "user", "content": self.user_prompt.format( + facts=facts_str, + thought=background.thought, + )}, ] result = "" @@ -126,24 +129,24 @@ class ExecutorBackground(CorePattern): class ExecutorResult(CorePattern): """使用大模型生成Executor的最终结果""" - system_prompt: str = r""" - 你是一个专业的智能助手,旨在根据背景信息等,回答用户的问题。 - - 要求: - - 使用中文回答问题,不要使用其他语言。 - - 提供的回答应当语气友好、通俗易懂,并包含尽可能完整的信息。 - """ + system_prompt: str = "" """系统提示词""" user_prompt: str = r""" + 你是AI智能助手,请回答用户的问题并满足以下要求: + 1. 使用中文回答问题,不要使用其他语言。 + 2. 回答应当语气友好、通俗易懂,并包含尽可能完整的信息。 + 3. 回答时应结合思考过程。 + 用户的问题是: {question} - 以下是一些供参考的背景信息: - {thought} - {final_output} + 思考过程(在标签中): + + {thought}{output} + - 现在,请根据以上信息,针对用户的问题提供准确而简洁的回答。 + 现在,请根据以上信息进行回答: """ """用户提示词""" @@ -160,10 +163,10 @@ class ExecutorResult(CorePattern): # 如果final_output不为空,则将final_output转换为字符串 if final_output: final_output_str = dedent(f""" - 你提供了{final_output['type']}类型数据:`{final_output['data']}`。\ - 这些数据已经使用恰当的办法向用户进行了展示,所以无需重复展示。\ - 当类型为“schema”时,证明用户的问题缺少回答所需的必要信息。\ - 我需要根据Schema的具体内容分析缺失哪些信息,并提示用户补充。 + 工具提供了{final_output['type']}类型数据:`{final_output['data']}`。\ + 这些数据已经使用恰当的办法向用户进行了展示,所以无需重复。\ + 若类型为“schema”,说明用户的问题缺少回答所需的必要信息。\ + 我需要根据schema的具体内容分析缺失哪些信息,并提示用户补充。 """) else: final_output_str = "" @@ -171,12 +174,12 @@ class ExecutorResult(CorePattern): user_input = self.user_prompt.format( question=question, thought=thought, - final_output=final_output_str, + output=final_output_str, ) messages = [ - {"role": "system", "content": self.system_prompt}, + {"role": "system", "content": ""}, {"role": "user", "content": user_input}, ] - async for chunk in ReasoningLLM().call(task_id, messages, streaming=True, temperature=1.0): + async for chunk in ReasoningLLM().call(task_id, messages, streaming=True, temperature=0.7): yield chunk diff --git a/apps/llm/patterns/facts.py b/apps/llm/patterns/facts.py index f665aa8d..665ef174 100644 --- a/apps/llm/patterns/facts.py +++ b/apps/llm/patterns/facts.py @@ -1,5 +1,4 @@ """事实提取""" -import json from typing import Any, ClassVar, Optional from apps.llm.patterns.core import CorePattern @@ -46,7 +45,7 @@ class Facts(CorePattern): } ``` - 输出结果: + 现在,请开始输出结果: """ """用户提示词""" @@ -75,8 +74,10 @@ class Facts(CorePattern): async def generate(self, task_id: str, **kwargs) -> list[str]: # noqa: ANN003 """事实提取""" messages = [ - {"role": "system", "content": self.system_prompt}, - {"role": "user", "content": self.user_prompt.format(message_json_str=json.dumps(kwargs["message"], ensure_ascii=False))}, + {"role": "system", "content": ""}, + {"role": "user", "content": kwargs["message"]["question"]}, + {"role": "assistant", "content": kwargs["message"]["answer"]}, + {"role": "user", "content": self.user_prompt}, ] result = "" async for chunk in ReasoningLLM().call(task_id, messages, streaming=False): diff --git a/apps/llm/patterns/json.py b/apps/llm/patterns/json.py index 46a94f77..c3c79c26 100644 --- a/apps/llm/patterns/json.py +++ b/apps/llm/patterns/json.py @@ -17,7 +17,6 @@ class Json(CorePattern): system_prompt: str = r""" Extract parameter data from conversations using given JSON Schema definitions. - Conversations tags: "" and "". Schema tags: "" and "". The output must be valid JSON without any additional formatting or comments. diff --git a/apps/manager/session.py b/apps/manager/session.py index e339a00b..ab7a63fa 100644 --- a/apps/manager/session.py +++ b/apps/manager/session.py @@ -136,7 +136,8 @@ class SessionManager: csrf_value = f"{session_id}{rand}" csrf_b64 = base64.b64encode(bytes.fromhex(csrf_value)) - hmac_processor = hmac.new(key=bytes.fromhex(config["JWT_KEY"]), msg=csrf_b64, digestmod=hashlib.sha256) + jwt_key = base64.b64decode(config["JWT_KEY"]) + hmac_processor = hmac.new(key=jwt_key, msg=csrf_b64, digestmod=hashlib.sha256) signature = base64.b64encode(hmac_processor.digest()) csrf_b64 = csrf_b64.decode("utf-8") @@ -171,8 +172,8 @@ class SessionManager: except Exception as e: LOGGER.error(f"Get csrf token from session error: {e}") - hmac_obj = hmac.new(key=bytes.fromhex(config["JWT_KEY"]), - msg=token_msg[0].encode("utf-8"), digestmod=hashlib.sha256) + jwt_key = base64.b64decode(config["JWT_KEY"]) + hmac_obj = hmac.new(key=jwt_key, msg=token_msg[0].encode("utf-8"), digestmod=hashlib.sha256) signature = hmac_obj.digest() current_signature = base64.b64decode(token_msg[1]) -- Gitee