Compare commits
49 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 0300cc96c4 | |||
| 24f72168dd | |||
| 1781cfcf29 | |||
| 49c9c21d57 | |||
|
|
a5a4412644 | ||
|
|
c4604a2989 | ||
|
|
2d97992690 | ||
|
|
3bf562d240 | ||
|
|
335b035490 | ||
|
|
babbf126aa | ||
|
|
6511d48d7b | ||
|
|
b885a76f5e | ||
|
|
96a8076246 | ||
|
|
1b6a7541de | ||
|
|
f3ac9f1675 | ||
|
|
6cdc1c76ac | ||
|
|
a2994f3905 | ||
|
|
5b0e17be2e | ||
|
|
de881414dc | ||
|
|
9822b9bfc9 | ||
|
|
53159ca24c | ||
|
|
fe13751624 | ||
|
|
9aee63f624 | ||
|
|
f299cf0145 | ||
|
|
bbf7843a66 | ||
|
|
dee9dd7b08 | ||
|
|
0781e8bd86 | ||
|
|
602bb1fce2 | ||
|
|
a9230fcf81 | ||
|
|
ebd2f6fabb | ||
|
|
16417c09a9 | ||
|
|
b73c2d2412 | ||
|
|
d52a8064db | ||
|
|
f4b35f4596 | ||
|
|
7f89c584c0 | ||
|
|
ef15f5894e | ||
|
|
99d6cb9f9f | ||
|
|
1534a0228e | ||
|
|
962b9d785a | ||
|
|
68919732db | ||
|
|
0c708da80d | ||
|
|
112a7dd70d | ||
|
|
927406b6c8 | ||
|
|
76ac16eb13 | ||
|
|
2dfb2cc519 | ||
|
|
a4d2cfe3e1 | ||
|
|
1585a4491c | ||
|
|
d35dfba895 | ||
|
|
a632bc7332 |
16
.env
16
.env
@ -1,11 +1,15 @@
|
||||
# LLM API Configuration
|
||||
LLM_API_URL=http://tianchat.zenithsafe.com:5001/v1
|
||||
LLM_API_KEY=app-k9WhnUvAPCVcSoPDEYVUxXgC
|
||||
LLM_API_URL=http://101.133.149.116:8777/v1
|
||||
LLM_API_KEY=app-7mh1IAGueaBodwdMflz8Omqv
|
||||
|
||||
LLMOurApiUrl=https://ark.cn-beijing.volces.com/api/v3/bots/chat/completions
|
||||
LLMOurApiKey=e999a241-6bf3-4ee0-99a8-e4de9b617f28
|
||||
|
||||
MiniMaxApiKey=eyJhbGciOiJSUzI1NiIsInR5cCI6IkpXVCJ9.eyJHcm91cE5hbWUiOiLkuIrmtbfpopzpgJTnp5HmioDmnInpmZDlhazlj7giLCJVc2VyTmFtZSI6IuadqOmqpSIsIkFjY291bnQiOiIiLCJTdWJqZWN0SUQiOiIxNzI4NzEyMzI0OTc5NjI2ODM5IiwiUGhvbmUiOiIxMzM4MTU1OTYxOCIsIkdyb3VwSUQiOiIxNzI4NzEyMzI0OTcxMjM4MjMxIiwiUGFnZU5hbWUiOiIiLCJNYWlsIjoiIiwiQ3JlYXRlVGltZSI6IjIwMjUtMDYtMTYgMTY6Mjk6NTkiLCJUb2tlblR5cGUiOjEsImlzcyI6Im1pbmltYXgifQ.D_JF0-nO89NdMZCYq4ocEyqxtZ9SeEdtMvbeSkZTWspt0XfX2QpPAVh-DI3MCPZTeSmjNWLf4fA_Th2zpVrj4UxWMbGKBeLZWLulNpwAHGMUTdqenuih3daCDPCzs0duhlFyQnZgGcEOGQ476HL72N2klujP8BUy_vfAh_Zv0po-aujQa5RxardDSOsbs49NTPEw0SQEXwaJ5bVmiZ5s-ysJ9pZWSEiyJ6SX9z3JeZHKj9DxHdOw5roZR8izo54e4IoqyLlzEfhOMW7P15-ffDH3M6HGiEmeBaGRYGAIciELjZS19ONNMKsTj-wXNGWtKG-sjAB1uuqkkT5Ul9Dunw
|
||||
MiniMaxApiURL=https://api.minimaxi.com/v1/t2a_v2
|
||||
APP_ID=1364994890450210816
|
||||
APP_KEY=b4839cb2-cb81-4472-a2c1-2abf31e4bb27
|
||||
APP_ID=1364966010532270080
|
||||
APP_KEY=a72c98fa-cbe3-449e-b004-36523437bc5d
|
||||
SIG_EXP=3600
|
||||
FILE_URL=http://172.17.0.1:6200/
|
||||
FILE_URL=http://120.92.112.77/gongzheng-backend/audio/
|
||||
# Server Configuration
|
||||
PORT=8080
|
||||
PORT=80
|
||||
24
.gitea/charts/Chart.yaml
Normal file
24
.gitea/charts/Chart.yaml
Normal file
@ -0,0 +1,24 @@
|
||||
apiVersion: v2
|
||||
name: homeland
|
||||
description: A Helm chart for Kubernetes
|
||||
|
||||
# A chart can be either an 'application' or a 'library' chart.
|
||||
#
|
||||
# Application charts are a collection of templates that can be packaged into versioned archives
|
||||
# to be deployed.
|
||||
#
|
||||
# Library charts provide useful utilities or functions for the chart developer. They're included as
|
||||
# a dependency of application charts to inject those utilities and functions into the rendering
|
||||
# pipeline. Library charts do not define any templates and therefore cannot be deployed.
|
||||
type: application
|
||||
|
||||
# This is the chart version. This version number should be incremented each time you make changes
|
||||
# to the chart and its templates, including the app version.
|
||||
# Versions are expected to follow Semantic Versioning (https://semver.org/)
|
||||
version: 0.1.0
|
||||
|
||||
# This is the version number of the application being deployed. This version number should be
|
||||
# incremented each time you make changes to the application. Versions are not expected to
|
||||
# follow Semantic Versioning. They should reflect the version the application is using.
|
||||
# It is recommended to use it with quotes.
|
||||
appVersion: "1.16.0"
|
||||
22
.gitea/charts/templates/NOTES.txt
Normal file
22
.gitea/charts/templates/NOTES.txt
Normal file
@ -0,0 +1,22 @@
|
||||
1. Get the application URL by running these commands:
|
||||
{{- if .Values.ingress.enabled }}
|
||||
{{- range $host := .Values.ingress.hosts }}
|
||||
{{- range .paths }}
|
||||
http{{ if $.Values.ingress.tls }}s{{ end }}://{{ $host.host }}{{ .path }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- else if contains "NodePort" .Values.service.type }}
|
||||
export NODE_PORT=$(kubectl get --namespace {{ .Release.Namespace }} -o jsonpath="{.spec.ports[0].nodePort}" services {{ include "homeland.fullname" . }})
|
||||
export NODE_IP=$(kubectl get nodes --namespace {{ .Release.Namespace }} -o jsonpath="{.items[0].status.addresses[0].address}")
|
||||
echo http://$NODE_IP:$NODE_PORT
|
||||
{{- else if contains "LoadBalancer" .Values.service.type }}
|
||||
NOTE: It may take a few minutes for the LoadBalancer IP to be available.
|
||||
You can watch the status of by running 'kubectl get --namespace {{ .Release.Namespace }} svc -w {{ include "homeland.fullname" . }}'
|
||||
export SERVICE_IP=$(kubectl get svc --namespace {{ .Release.Namespace }} {{ include "homeland.fullname" . }} --template "{{"{{ range (index .status.loadBalancer.ingress 0) }}{{.}}{{ end }}"}}")
|
||||
echo http://$SERVICE_IP:{{ .Values.service.port }}
|
||||
{{- else if contains "ClusterIP" .Values.service.type }}
|
||||
export POD_NAME=$(kubectl get pods --namespace {{ .Release.Namespace }} -l "app.kubernetes.io/name={{ include "homeland.name" . }},app.kubernetes.io/instance={{ .Release.Name }}" -o jsonpath="{.items[0].metadata.name}")
|
||||
export CONTAINER_PORT=$(kubectl get pod --namespace {{ .Release.Namespace }} $POD_NAME -o jsonpath="{.spec.containers[0].ports[0].containerPort}")
|
||||
echo "Visit http://127.0.0.1:8080 to use your application"
|
||||
kubectl --namespace {{ .Release.Namespace }} port-forward $POD_NAME 8080:$CONTAINER_PORT
|
||||
{{- end }}
|
||||
62
.gitea/charts/templates/_helpers.tpl
Normal file
62
.gitea/charts/templates/_helpers.tpl
Normal file
@ -0,0 +1,62 @@
|
||||
{{/*
|
||||
Expand the name of the chart.
|
||||
*/}}
|
||||
{{- define "homeland.name" -}}
|
||||
{{- default .Chart.Name .Values.nameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create a default fully qualified app name.
|
||||
We truncate at 63 chars because some Kubernetes name fields are limited to this (by the DNS naming spec).
|
||||
If release name contains chart name it will be used as a full name.
|
||||
*/}}
|
||||
{{- define "homeland.fullname" -}}
|
||||
{{- if .Values.fullnameOverride }}
|
||||
{{- .Values.fullnameOverride | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- $name := default .Chart.Name .Values.nameOverride }}
|
||||
{{- if contains $name .Release.Name }}
|
||||
{{- .Release.Name | trunc 63 | trimSuffix "-" }}
|
||||
{{- else }}
|
||||
{{- printf "%s-%s" .Release.Name $name | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create chart name and version as used by the chart label.
|
||||
*/}}
|
||||
{{- define "homeland.chart" -}}
|
||||
{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Common labels
|
||||
*/}}
|
||||
{{- define "homeland.labels" -}}
|
||||
helm.sh/chart: {{ include "homeland.chart" . }}
|
||||
{{ include "homeland.selectorLabels" . }}
|
||||
{{- if .Chart.AppVersion }}
|
||||
app.kubernetes.io/version: {{ .Chart.AppVersion | quote }}
|
||||
{{- end }}
|
||||
app.kubernetes.io/managed-by: {{ .Release.Service }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Selector labels
|
||||
*/}}
|
||||
{{- define "homeland.selectorLabels" -}}
|
||||
app.kubernetes.io/name: {{ include "homeland.name" . }}
|
||||
app.kubernetes.io/instance: {{ .Release.Name }}
|
||||
{{- end }}
|
||||
|
||||
{{/*
|
||||
Create the name of the service account to use
|
||||
*/}}
|
||||
{{- define "homeland.serviceAccountName" -}}
|
||||
{{- if .Values.serviceAccount.create }}
|
||||
{{- default (include "homeland.fullname" .) .Values.serviceAccount.name }}
|
||||
{{- else }}
|
||||
{{- default "default" .Values.serviceAccount.name }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
61
.gitea/charts/templates/deployment.yaml
Normal file
61
.gitea/charts/templates/deployment.yaml
Normal file
@ -0,0 +1,61 @@
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
metadata:
|
||||
name: {{ include "homeland.fullname" . }}
|
||||
labels:
|
||||
{{- include "homeland.labels" . | nindent 4 }}
|
||||
spec:
|
||||
{{- if not .Values.autoscaling.enabled }}
|
||||
replicas: {{ .Values.replicaCount }}
|
||||
{{- end }}
|
||||
selector:
|
||||
matchLabels:
|
||||
{{- include "homeland.selectorLabels" . | nindent 6 }}
|
||||
template:
|
||||
metadata:
|
||||
{{- with .Values.podAnnotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
labels:
|
||||
{{- include "homeland.selectorLabels" . | nindent 8 }}
|
||||
spec:
|
||||
{{- with .Values.imagePullSecrets }}
|
||||
imagePullSecrets:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
serviceAccountName: {{ include "homeland.serviceAccountName" . }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.podSecurityContext | nindent 8 }}
|
||||
containers:
|
||||
- name: {{ .Chart.Name }}
|
||||
securityContext:
|
||||
{{- toYaml .Values.securityContext | nindent 12 }}
|
||||
image: "{{ .Values.image.repository }}:{{ .Values.image.tag | default .Chart.AppVersion }}"
|
||||
imagePullPolicy: {{ .Values.image.pullPolicy }}
|
||||
ports:
|
||||
- name: http
|
||||
containerPort: {{ .Values.service.port }}
|
||||
protocol: TCP
|
||||
livenessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
readinessProbe:
|
||||
httpGet:
|
||||
path: /
|
||||
port: http
|
||||
resources:
|
||||
{{- toYaml .Values.resources | nindent 12 }}
|
||||
{{- with .Values.nodeSelector }}
|
||||
nodeSelector:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.affinity }}
|
||||
affinity:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
{{- with .Values.tolerations }}
|
||||
tolerations:
|
||||
{{- toYaml . | nindent 8 }}
|
||||
{{- end }}
|
||||
32
.gitea/charts/templates/hpa.yaml
Normal file
32
.gitea/charts/templates/hpa.yaml
Normal file
@ -0,0 +1,32 @@
|
||||
{{- if .Values.autoscaling.enabled }}
|
||||
apiVersion: autoscaling/v2
|
||||
kind: HorizontalPodAutoscaler
|
||||
metadata:
|
||||
name: {{ include "homeland.fullname" . }}
|
||||
labels:
|
||||
{{- include "homeland.labels" . | nindent 4 }}
|
||||
spec:
|
||||
scaleTargetRef:
|
||||
apiVersion: apps/v1
|
||||
kind: Deployment
|
||||
name: {{ include "homeland.fullname" . }}
|
||||
minReplicas: {{ .Values.autoscaling.minReplicas }}
|
||||
maxReplicas: {{ .Values.autoscaling.maxReplicas }}
|
||||
metrics:
|
||||
{{- if .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: cpu
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.autoscaling.targetCPUUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- if .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
||||
- type: Resource
|
||||
resource:
|
||||
name: memory
|
||||
target:
|
||||
type: Utilization
|
||||
averageUtilization: {{ .Values.autoscaling.targetMemoryUtilizationPercentage }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
61
.gitea/charts/templates/ingress.yaml
Normal file
61
.gitea/charts/templates/ingress.yaml
Normal file
@ -0,0 +1,61 @@
|
||||
{{- if .Values.ingress.enabled -}}
|
||||
{{- $fullName := include "homeland.fullname" . -}}
|
||||
{{- $svcPort := .Values.service.port -}}
|
||||
{{- if and .Values.ingress.className (not (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion)) }}
|
||||
{{- if not (hasKey .Values.ingress.annotations "kubernetes.io/ingress.class") }}
|
||||
{{- $_ := set .Values.ingress.annotations "kubernetes.io/ingress.class" .Values.ingress.className}}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- if semverCompare ">=1.19-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
apiVersion: networking.k8s.io/v1
|
||||
{{- else if semverCompare ">=1.14-0" .Capabilities.KubeVersion.GitVersion -}}
|
||||
apiVersion: networking.k8s.io/v1beta1
|
||||
{{- else -}}
|
||||
apiVersion: extensions/v1beta1
|
||||
{{- end }}
|
||||
kind: Ingress
|
||||
metadata:
|
||||
name: {{ $fullName }}
|
||||
labels:
|
||||
{{- include "homeland.labels" . | nindent 4 }}
|
||||
{{- with .Values.ingress.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
spec:
|
||||
{{- if and .Values.ingress.className (semverCompare ">=1.18-0" .Capabilities.KubeVersion.GitVersion) }}
|
||||
ingressClassName: {{ .Values.ingress.className }}
|
||||
{{- end }}
|
||||
{{- if .Values.ingress.tls }}
|
||||
tls:
|
||||
{{- range .Values.ingress.tls }}
|
||||
- hosts:
|
||||
{{- range .hosts }}
|
||||
- {{ . | quote }}
|
||||
{{- end }}
|
||||
secretName: {{ .secretName }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
rules:
|
||||
{{- range .Values.ingress.hosts }}
|
||||
- host: {{ .host | quote }}
|
||||
http:
|
||||
paths:
|
||||
{{- range .paths }}
|
||||
- path: {{ .path }}
|
||||
{{- if and .pathType (semverCompare ">=1.18-0" $.Capabilities.KubeVersion.GitVersion) }}
|
||||
pathType: {{ .pathType }}
|
||||
{{- end }}
|
||||
backend:
|
||||
{{- if semverCompare ">=1.19-0" $.Capabilities.KubeVersion.GitVersion }}
|
||||
service:
|
||||
name: {{ $fullName }}
|
||||
port:
|
||||
number: {{ $svcPort }}
|
||||
{{- else }}
|
||||
serviceName: {{ $fullName }}
|
||||
servicePort: {{ $svcPort }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
15
.gitea/charts/templates/service.yaml
Normal file
15
.gitea/charts/templates/service.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Service
|
||||
metadata:
|
||||
name: {{ include "homeland.fullname" . }}
|
||||
labels:
|
||||
{{- include "homeland.labels" . | nindent 4 }}
|
||||
spec:
|
||||
type: {{ .Values.service.type }}
|
||||
ports:
|
||||
- port: {{ .Values.service.port }}
|
||||
targetPort: http
|
||||
protocol: TCP
|
||||
name: http
|
||||
selector:
|
||||
{{- include "homeland.selectorLabels" . | nindent 4 }}
|
||||
12
.gitea/charts/templates/serviceaccount.yaml
Normal file
12
.gitea/charts/templates/serviceaccount.yaml
Normal file
@ -0,0 +1,12 @@
|
||||
{{- if .Values.serviceAccount.create -}}
|
||||
apiVersion: v1
|
||||
kind: ServiceAccount
|
||||
metadata:
|
||||
name: {{ include "homeland.serviceAccountName" . }}
|
||||
labels:
|
||||
{{- include "homeland.labels" . | nindent 4 }}
|
||||
{{- with .Values.serviceAccount.annotations }}
|
||||
annotations:
|
||||
{{- toYaml . | nindent 4 }}
|
||||
{{- end }}
|
||||
{{- end }}
|
||||
15
.gitea/charts/templates/tests/test-connection.yaml
Normal file
15
.gitea/charts/templates/tests/test-connection.yaml
Normal file
@ -0,0 +1,15 @@
|
||||
apiVersion: v1
|
||||
kind: Pod
|
||||
metadata:
|
||||
name: "{{ include "homeland.fullname" . }}-test-connection"
|
||||
labels:
|
||||
{{- include "homeland.labels" . | nindent 4 }}
|
||||
annotations:
|
||||
"helm.sh/hook": test
|
||||
spec:
|
||||
containers:
|
||||
- name: wget
|
||||
image: busybox
|
||||
command: ['wget']
|
||||
args: ['{{ include "homeland.fullname" . }}:{{ .Values.service.port }}']
|
||||
restartPolicy: Never
|
||||
84
.gitea/charts/values.yaml
Normal file
84
.gitea/charts/values.yaml
Normal file
@ -0,0 +1,84 @@
|
||||
# Default values for homeland.
|
||||
# This is a YAML-formatted file.
|
||||
# Declare variables to be passed into your templates.
|
||||
|
||||
replicaCount: 1
|
||||
|
||||
image:
|
||||
repository: 172.16.54.94:5000/homeland
|
||||
pullPolicy: IfNotPresent
|
||||
# Overrides the image tag whose default is the chart appVersion.
|
||||
tag: "29"
|
||||
|
||||
imagePullSecrets: []
|
||||
nameOverride: ""
|
||||
fullnameOverride: ""
|
||||
|
||||
serviceAccount:
|
||||
# Specifies whether a service account should be created
|
||||
create: true
|
||||
# Annotations to add to the service account
|
||||
annotations: {}
|
||||
# The name of the service account to use.
|
||||
# If not set and create is true, a name is generated using the fullname template
|
||||
name: ""
|
||||
|
||||
podAnnotations: {}
|
||||
|
||||
podSecurityContext: {}
|
||||
# fsGroup: 2000
|
||||
|
||||
securityContext: {}
|
||||
# capabilities:
|
||||
# drop:
|
||||
# - ALL
|
||||
# readOnlyRootFilesystem: true
|
||||
# runAsNonRoot: true
|
||||
# runAsUser: 1000
|
||||
|
||||
service:
|
||||
type: ClusterIP
|
||||
port: 80
|
||||
|
||||
ingress:
|
||||
enabled: false
|
||||
className: ""
|
||||
annotations: {}
|
||||
# kubernetes.io/ingress.class: nginx
|
||||
# kubernetes.io/tls-acme: "true"
|
||||
hosts:
|
||||
- host: homeland.local
|
||||
paths:
|
||||
- path: /
|
||||
pathType: ImplementationSpecific
|
||||
tls: []
|
||||
# - secretName: chart-example-tls
|
||||
# hosts:
|
||||
# - chart-example.local
|
||||
|
||||
resources: {}
|
||||
# We usually recommend not to specify default resources and to leave this as a conscious
|
||||
# choice for the user. This also increases chances charts run on environments with little
|
||||
# resources, such as Minikube. If you do want to specify resources, uncomment the following
|
||||
# lines, adjust them as necessary, and remove the curly braces after 'resources:'.
|
||||
# limits:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
# requests:
|
||||
# cpu: 100m
|
||||
# memory: 128Mi
|
||||
|
||||
autoscaling:
|
||||
enabled: false
|
||||
minReplicas: 1
|
||||
maxReplicas: 100
|
||||
targetCPUUtilizationPercentage: 80
|
||||
# targetMemoryUtilizationPercentage: 80
|
||||
|
||||
nodeSelector: {
|
||||
kubernetes.io/hostname: vm10-1-0-152
|
||||
}
|
||||
|
||||
tolerations: []
|
||||
|
||||
affinity: {}
|
||||
@ -3,7 +3,7 @@ run-name: ${{ gitea.actor }} is testing out Gitea Actions 🚀
|
||||
on:
|
||||
push:
|
||||
branches:
|
||||
- 'prod'
|
||||
- 'prod-dh'
|
||||
|
||||
env:
|
||||
BUILD: staging
|
||||
@ -11,7 +11,7 @@ env:
|
||||
|
||||
jobs:
|
||||
Explore-Gitea-Actions:
|
||||
runs-on: stream9
|
||||
runs-on: yantoo-ci
|
||||
steps:
|
||||
- run: echo "🎉 The job was automatically triggered by a ${{ gitea.event_name }} event."
|
||||
- run: echo "🐧 This job is now running on a ${{ runner.os }} server hosted by Gitea!"
|
||||
@ -29,18 +29,13 @@ jobs:
|
||||
- name: Build and push
|
||||
uses: https://gitea.yantootech.com/neil/build-push-action@v6
|
||||
with:
|
||||
push: false
|
||||
tags: gong-zheng-api:${{ gitea.run_id }}
|
||||
- name: Run docker
|
||||
push: true
|
||||
tags: 100.97.153.66:30005/donghang:${{ gitea.run_id }}
|
||||
- name: Install
|
||||
run: |
|
||||
pwd
|
||||
if [ "$(docker ps -q -f name=^gong-zheng-api$)" ]; then
|
||||
docker stop gong-zheng-api
|
||||
fi
|
||||
docker run -d --rm --name gong-zheng-api \
|
||||
-v /usr/share/fonts/opentype/noto:/usr/share/fonts \
|
||||
-v $(pwd)/audio:/app/audio \
|
||||
-p 6211:8080 \
|
||||
-p 6212:8000 \
|
||||
gong-zheng-api:${{ gitea.run_id }}
|
||||
helm upgrade --install donghang ./.gitea/charts \
|
||||
--namespace donghang \
|
||||
--create-namespace \
|
||||
--set image.repository=100.97.153.66:30005/donghang \
|
||||
--set image.tag=${{ gitea.run_id }}
|
||||
- run: echo "🍏 This job's status is ${{ job.status }}."
|
||||
57
Dockerfile
57
Dockerfile
@ -1,56 +1,31 @@
|
||||
# 构建 Go 服务
|
||||
FROM golang:1.21-alpine AS go-builder
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# 安装必要的构建工具
|
||||
RUN apk add --no-cache gcc musl-dev
|
||||
# RUN apk add gcc musl-dev
|
||||
|
||||
# 设置 GOPROXY 环境变量
|
||||
ENV GOPROXY=https://goproxy.cn,direct
|
||||
|
||||
# 复制 Go 项目文件
|
||||
COPY . .
|
||||
|
||||
# 构建 Go 服务
|
||||
RUN go build -o main ./main.go
|
||||
RUN CGO_ENABLED=0 go build -o main ./main.go
|
||||
|
||||
# 构建 Python 服务
|
||||
FROM python:3.11-slim
|
||||
# 运行阶段
|
||||
FROM alpine:latest
|
||||
|
||||
WORKDIR /app
|
||||
WORKDIR /usr/src/app
|
||||
|
||||
# 安装必要的系统依赖
|
||||
RUN apt-get update && apt-get install -y \
|
||||
ca-certificates \
|
||||
&& rm -rf /var/lib/apt/lists/*
|
||||
# 从构建阶段复制编译好的二进制文件和配置文件
|
||||
COPY --from=go-builder /usr/src/app/main .
|
||||
COPY --from=go-builder /usr/src/app/.env .
|
||||
|
||||
# 创建音频目录
|
||||
RUN mkdir -p /app/audio
|
||||
# 暴露端口(根据你的 API 服务端口修改)
|
||||
EXPOSE 8080
|
||||
|
||||
# 复制 Python 文件服务器
|
||||
COPY file_server.py .
|
||||
|
||||
# 从 go-builder 阶段复制编译好的 Go 服务
|
||||
COPY --from=go-builder /app/main .
|
||||
|
||||
# 复制配置文件(如果有的话)
|
||||
COPY --from=go-builder /app/config.yaml .
|
||||
|
||||
# 设置环境变量
|
||||
ENV PORT=8000
|
||||
ENV GO_PORT=8080
|
||||
|
||||
# 创建启动脚本
|
||||
RUN echo '#!/bin/bash\n\
|
||||
# 启动 Go 服务\n\
|
||||
./main &\n\
|
||||
# 启动 Python 文件服务器\n\
|
||||
python file_server.py -p $PORT\n\
|
||||
' > /app/start.sh && chmod +x /app/start.sh
|
||||
|
||||
# 暴露端口
|
||||
EXPOSE 8000 8080
|
||||
|
||||
# 设置工作目录
|
||||
WORKDIR /app
|
||||
|
||||
# 启动服务
|
||||
CMD ["/app/start.sh"]
|
||||
# 运行服务
|
||||
CMD ["./main"]
|
||||
|
||||
@ -4,11 +4,9 @@ services:
|
||||
app:
|
||||
build: .
|
||||
ports:
|
||||
- "8000:8000" # Python 文件服务器端口
|
||||
- "8080:8080" # Go 服务端口
|
||||
volumes:
|
||||
- ./audio:/app/audio # 挂载音频目录
|
||||
environment:
|
||||
- PORT=8000
|
||||
- GO_PORT=8080
|
||||
restart: unless-stopped
|
||||
@ -62,7 +62,6 @@ class FileHandler(http.server.SimpleHTTPRequestHandler):
|
||||
with open(file_path, 'rb') as f:
|
||||
self.send_response(200)
|
||||
self.send_header('Content-type', content_type)
|
||||
self.send_header('Content-Disposition', f'attachment; filename="{os.path.basename(file_path)}"')
|
||||
self.end_headers()
|
||||
self.wfile.write(f.read())
|
||||
except Exception as e:
|
||||
|
||||
@ -2,7 +2,10 @@ package handler
|
||||
|
||||
import (
|
||||
"encoding/json"
|
||||
"fmt"
|
||||
"hash/fnv"
|
||||
"net/http"
|
||||
"strconv"
|
||||
"time"
|
||||
|
||||
"gongzheng_minimax/service"
|
||||
@ -10,6 +13,14 @@ import (
|
||||
"github.com/gin-gonic/gin"
|
||||
)
|
||||
|
||||
type ChatExtRequest struct {
|
||||
Sid string `json:"sid"`
|
||||
DhCode string `json:"dh-code"`
|
||||
DhQuestion string `json:"dh-question"` // 映射为 content
|
||||
DhConversationID string `json:"dh-conversation-id"` // 需要转换为 conversation_id
|
||||
DhContext []interface{} `json:"dh-context"` // 上下文
|
||||
}
|
||||
|
||||
// LLMHandler handles HTTP requests for the LLM service
|
||||
type LLMHandler struct {
|
||||
llmService *service.LLMService
|
||||
@ -79,6 +90,89 @@ func (h *LLMHandler) Chat(c *gin.Context) {
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// ChatExt handles external QA chat requests
|
||||
func (h *LLMHandler) ChatExt(c *gin.Context) {
|
||||
var requestData ChatExtRequest
|
||||
if err := c.ShouldBindJSON(&requestData); err != nil {
|
||||
fmt.Printf("Error binding JSON: %v\n", err)
|
||||
c.JSON(http.StatusBadRequest, gin.H{"error": "Invalid request data"})
|
||||
return
|
||||
}
|
||||
|
||||
fmt.Printf("Received ChatExt request: %+v\n", requestData)
|
||||
|
||||
// 将UUID转换为19位数字字符串
|
||||
h64 := fnv.New64a()
|
||||
h64.Write([]byte(requestData.DhConversationID))
|
||||
hashValue := h64.Sum64()
|
||||
conversationID := strconv.FormatUint(hashValue, 10)
|
||||
// 确保长度为19位,不足补0,超过截取(FNV64通常是19-20位数字)
|
||||
if len(conversationID) < 19 {
|
||||
conversationID = fmt.Sprintf("%019s", conversationID)
|
||||
} else if len(conversationID) > 19 {
|
||||
conversationID = conversationID[:19]
|
||||
}
|
||||
|
||||
fmt.Printf("Converted ConversationID: %s -> %s\n", requestData.DhConversationID, conversationID)
|
||||
|
||||
// 构造 Service 层需要的参数 map
|
||||
serviceData := map[string]interface{}{
|
||||
"tag_ids": []int{1, 11, 29},
|
||||
"conversation_id": conversationID,
|
||||
"content": requestData.DhQuestion,
|
||||
}
|
||||
|
||||
fmt.Printf("Calling Service with data: %+v\n", serviceData)
|
||||
|
||||
response, err := h.llmService.CallExtQAAPIStreamDirect(serviceData)
|
||||
if err != nil {
|
||||
c.JSON(http.StatusInternalServerError, gin.H{"error": err.Error()})
|
||||
return
|
||||
}
|
||||
|
||||
// Check if the response is a channel (streaming response)
|
||||
if messageChan, ok := response.(chan service.Message); ok {
|
||||
// Set headers for SSE
|
||||
c.Header("Content-Type", "text/event-stream")
|
||||
c.Header("Cache-Control", "no-cache")
|
||||
c.Header("Connection", "keep-alive")
|
||||
c.Header("Transfer-Encoding", "chunked")
|
||||
|
||||
// Create a channel to handle client disconnection
|
||||
clientGone := c.Writer.CloseNotify()
|
||||
|
||||
// Stream the messages
|
||||
for {
|
||||
select {
|
||||
case <-clientGone:
|
||||
return
|
||||
case message, ok := <-messageChan:
|
||||
if !ok {
|
||||
return
|
||||
}
|
||||
|
||||
// Convert message to JSON
|
||||
jsonData, err := json.Marshal(message)
|
||||
if err != nil {
|
||||
continue
|
||||
}
|
||||
|
||||
// Write the SSE message
|
||||
c.SSEvent("message", string(jsonData))
|
||||
c.Writer.Flush()
|
||||
|
||||
// If this is the end message, close the connection
|
||||
if message.IsEnd {
|
||||
return
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Non-streaming response
|
||||
c.JSON(http.StatusOK, response)
|
||||
}
|
||||
|
||||
// StopConversation handles stopping a conversation
|
||||
func (h *LLMHandler) StopConversation(c *gin.Context) {
|
||||
taskID := c.Param("task_id")
|
||||
|
||||
23
main.go
23
main.go
@ -1,6 +1,7 @@
|
||||
package main
|
||||
|
||||
import (
|
||||
"fmt"
|
||||
"log"
|
||||
"os"
|
||||
"strconv"
|
||||
@ -25,8 +26,12 @@ func main() {
|
||||
MiniMaxApiKey: os.Getenv("MiniMaxApiKey"),
|
||||
MiniMaxApiURL: os.Getenv("MiniMaxApiURL"),
|
||||
FILE_URL: os.Getenv("FILE_URL"),
|
||||
LLMOurApiUrl: os.Getenv("LLMOurApiUrl"),
|
||||
LLMOurApiKey: os.Getenv("LLMOurApiKey"),
|
||||
})
|
||||
|
||||
fmt.Println("config: ", llmService)
|
||||
|
||||
// Get token configuration from environment variables
|
||||
sigExp, err := strconv.Atoi(os.Getenv("SIG_EXP"))
|
||||
if err != nil {
|
||||
@ -64,14 +69,30 @@ func main() {
|
||||
|
||||
// Define routes
|
||||
router.POST("/chat", llmHandler.Chat)
|
||||
router.POST("/chat-ext", llmHandler.ChatExt)
|
||||
router.POST("/chat-messages/:task_id/stop", llmHandler.StopConversation)
|
||||
router.DELETE("/conversations/:conversation_id", llmHandler.DeleteConversation)
|
||||
router.POST("/speech/synthesize", llmHandler.SynthesizeSpeech)
|
||||
router.GET("/stream-text", llmHandler.StreamText)
|
||||
router.POST("/token", tokenHandler.GenerateToken)
|
||||
// Define routes
|
||||
router.GET("/", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"status": "ok",
|
||||
"message": "Service is healthy",
|
||||
})
|
||||
})
|
||||
// Define routes
|
||||
router.GET("/health", func(c *gin.Context) {
|
||||
c.JSON(200, gin.H{
|
||||
"status": "ok",
|
||||
"message": "Service is healthy",
|
||||
})
|
||||
})
|
||||
|
||||
// Serve static files
|
||||
router.Static("/static", "./static")
|
||||
router.Static("/audio", "./audio") // 添加音频文件访问服务
|
||||
|
||||
// Get host and port from environment variables
|
||||
host := os.Getenv("HOST")
|
||||
@ -80,7 +101,7 @@ func main() {
|
||||
}
|
||||
port := os.Getenv("PORT")
|
||||
if port == "" {
|
||||
port = "8080"
|
||||
port = "80"
|
||||
}
|
||||
|
||||
// Start server
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
Loading…
x
Reference in New Issue
Block a user