diff --git a/.vscode/settings.json b/.vscode/settings.json index be6f4cf..3df1f74 100644 --- a/.vscode/settings.json +++ b/.vscode/settings.json @@ -5,6 +5,9 @@ "file:///home/coder/helm-starred/hass/influxdb/deployment.yaml" ], "https://json.schemastore.org/helmfile.json": "file:///home/coder/helm-starred/matrix/values.yaml", - "https://json.schemastore.org/chart.json": "file:///home/coder/helm-starred/matrix/dendrite/Chart.yaml" + "https://json.schemastore.org/chart.json": [ + "file:///home/coder/helm-starred/matrix/dendrite/Chart.yaml", + "file:///home/coder/helm-starred/cocopilot/Chart.yaml" + ] } } \ No newline at end of file diff --git a/cocopilot/Chart.yaml b/cocopilot/Chart.yaml new file mode 100644 index 0000000..8c478e4 --- /dev/null +++ b/cocopilot/Chart.yaml @@ -0,0 +1,6 @@ +apiVersion: v2 +name: cocopilot +description: Cocopilot is a shim for AI apis +type: application +version: 0.1.0 +appVersion: "v0.0.7" \ No newline at end of file diff --git a/cocopilot/templates/configmap.yaml b/cocopilot/templates/configmap.yaml new file mode 100644 index 0000000..2f7a4c0 --- /dev/null +++ b/cocopilot/templates/configmap.yaml @@ -0,0 +1,29 @@ +apiVersion: v1 +kind: ConfigMap +metadata: + name: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + labels: + app: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + {{- include "cocopilot.labels" . | nindent 4 }} +data: + config.json: |- + { + "bind": {{ include "cocopilot.config.bind" . | quote }}, + "proxy_url": {{ .Values.config.proxyUrl | quote }}, + "timeout": {{ .Values.config.timeout }}, + "codex_api_base": {{ .Values.config.codex.apiBase | quote }}, + "codex_api_key": "", + "codex_api_organization": {{ .Values.config.codex.organization | quote }}, + "codex_api_project": {{ .Values.config.codex.project | quote }}, + "codex_max_tokens": 500, + "code_instruct_model": {{ .Values.config.codex.model | quote }}, + "chat_api_base": {{ .Values.config.chat.apiBase | quote }}, + "chat_api_key": "", + "chat_api_organization": {{ .Values.config.chat.organization | quote }}, + "chat_api_project": {{ .Values.config.chat.project | quote }}, + "chat_max_tokens": {{ .Values.config.chat.maxTokens }}, + "chat_model_default": {{ .Values.config.chat.model | quote }}, + "chat_model_map": {{ .Values.config.chat.modelMap | toJson }}, + "chat_locale": {{ .Values.config.chat.locale | quote }}, + "auth_token": "" + } \ No newline at end of file diff --git a/cocopilot/templates/deployment.yaml b/cocopilot/templates/deployment.yaml new file mode 100644 index 0000000..3ef5b60 --- /dev/null +++ b/cocopilot/templates/deployment.yaml @@ -0,0 +1,52 @@ +apiVersion: apps/v1 +kind: Deployment +metadata: + name: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + labels: + app: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + {{- include "cocopilot.labels" . | nindent 4 }} +spec: + selector: + matchLabels: + app: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + template: + metadata: + labels: + app: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + spec: + containers: + - name: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + image: {{ include "cocopilot.image" . | quote}} + imagePullPolicy: {{ .Values.image.pullPolicy }} + {{- if .Values.resources }} + resources: + {{- toYaml .Values.resources | nindent 10 }} + {{- end }} + ports: + - containerPort: {{ .Values.config.port }} + name: svc + env: + - name: OVERRIDE_CODEX_API_KEY + valueFrom: + secretKeyRef: + name: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + key: password + - name: OVERRIDE_CHAT_API_KEY + valueFrom: + secretKeyRef: + name: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + key: password + {{- if .Values.env }} + {{- toYaml .Values.env | nindent 8 }} + {{- end }} + volumeMounts: + - name: config + mountPath: /app/config.json + subPath: config.json + volumes: + - name: config + configMap: + name: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + items: + - key: config.json + path: config.json diff --git a/cocopilot/templates/helper.tpl b/cocopilot/templates/helper.tpl new file mode 100644 index 0000000..8594e33 --- /dev/null +++ b/cocopilot/templates/helper.tpl @@ -0,0 +1,63 @@ +{{/* +Expand the name of the chart. +*/}} +{{- define "cocopilot.name" -}} +{{- .Values.nameOverride | default .Chart.Name | 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 "cocopilot.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 "cocopilot.chart" -}} +{{- printf "%s-%s" .Chart.Name .Chart.Version | replace "+" "_" | trunc 63 | trimSuffix "-" }} +{{- end }} + +{{/* +Common labels +*/}} +{{- define "cocopilot.labels" -}} +helm.sh/chart: {{ include "cocopilot.chart" . }} +{{ include "cocopilot.selectorLabels" . }} +{{- if .Chart.AppVersion }} +app.kubernetes.io/version: {{ .Chart.AppVersion | quote }} +{{- end }} +app.kubernetes.io/managed-by: {{ .Release.Service }} +{{- end }} + +{{/* +Selector labels +*/}} +{{- define "cocopilot.selectorLabels" -}} +app.kubernetes.io/name: {{ include "cocopilot.name" . }} +app.kubernetes.io/instance: {{ .Release.Name }} +{{- end }} + +{{- define "cocopilot.image" -}} +{{- include "cocopilot.image.tag" . | printf "%s/%s:%s" .Values.image.registry .Values.image.repository -}} +{{- end }} + +{{- define "cocopilot.image.tag" -}} +{{ .Values.image.tag | default .Chart.AppVersion }} +{{- end }} + +{{- define "cocopilot.config.bind" -}} +{{- .Values.config.port | int | printf "%s:%d" .Values.config.listen -}} +{{- end }} \ No newline at end of file diff --git a/cocopilot/templates/secret.yaml b/cocopilot/templates/secret.yaml new file mode 100644 index 0000000..f378b98 --- /dev/null +++ b/cocopilot/templates/secret.yaml @@ -0,0 +1,10 @@ +apiVersion: v1 +kind: Secret +metadata: + name: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + labels: + app: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + {{- include "cocopilot.labels" . | nindent 4 }} +type: Opaque +data: + password: {{ .Values.config.secretKey | b64enc }} diff --git a/cocopilot/templates/service.yaml b/cocopilot/templates/service.yaml new file mode 100644 index 0000000..6ffc714 --- /dev/null +++ b/cocopilot/templates/service.yaml @@ -0,0 +1,18 @@ +apiVersion: v1 +kind: Service +metadata: + name: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + labels: + app: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + {{- include "cocopilot.labels" . | nindent 4 }} +spec: + selector: + app: {{ include "cocopilot.fullname" . | printf "%s-cocopilot"}} + ports: + - port: {{.Values.service.port}} + targetPort: svc + ipFamilyPolicy: PreferDualStack + ipFamilies: + - IPv4 + - IPv6 + type: {{ .Values.service.type }} \ No newline at end of file diff --git a/cocopilot/values.yaml b/cocopilot/values.yaml new file mode 100644 index 0000000..f50bc2e --- /dev/null +++ b/cocopilot/values.yaml @@ -0,0 +1,38 @@ +fullnameOverride: "" +nameOverride: "" +image: + registry: "ghcr.io" + repository: "senseab/ai-shim" + tag: "" + pullPolicy: "IfNotPresent" + +resources: + limits: + cpu: 500m + memory: 512Mi + +service: + type: ClusterIP + port: 8181 + +config: + listen: "[::]" + port: 8181 + secretKey: "sk-5001283573a645c6801964e2886c6fc4" + proxyUrl: "" + timeout: 600 + codex: + apiBase: "https://api.deepseek.com/beta/v1" + organization: "" + project: "" + model: "deepseek-coder" + chat: + model: "deepseek-coder" + locale: "zh_CN" + maxTokens: 4096 + modelMap: {} + apiBase: "https://api.deepseek.com/v1" + organization: "" + project: "" + +env: [] \ No newline at end of file