cocopilot

This commit is contained in:
Sense T 2025-01-23 22:38:09 +08:00
parent e00474109d
commit 322b0781ac
8 changed files with 220 additions and 1 deletions

View File

@ -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"
]
}
}

6
cocopilot/Chart.yaml Normal file
View File

@ -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"

View File

@ -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": ""
}

View File

@ -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

View File

@ -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 }}

View File

@ -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 }}

View File

@ -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 }}

38
cocopilot/values.yaml Normal file
View File

@ -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: []