Skip to content

Commit

Permalink
Merge pull request #839 from bjwswang/main
Browse files Browse the repository at this point in the history
chore: add host aliases in kubeagi charts
  • Loading branch information
bjwswang authored Mar 13, 2024
2 parents 001b207 + 91850bb commit 04923e0
Show file tree
Hide file tree
Showing 12 changed files with 114 additions and 132 deletions.
21 changes: 15 additions & 6 deletions apiserver/pkg/modelservice/modelservice.go
Original file line number Diff line number Diff line change
Expand Up @@ -378,9 +378,9 @@ func CheckModelService(ctx context.Context, c client.Client, input generated.Cre

switch *input.APIType {
case "openai":
info, err = checkOpenAI(ctx, c, input)
info, err = checkOpenAI(ctx, input)
case "zhipuai":
info, err = checkZhipuAI(ctx, c, input)
info, err = checkZhipuAI(ctx, input)
default:
err = fmt.Errorf("not support api type %s", *input.APIType)
}
Expand All @@ -399,22 +399,31 @@ func CheckModelService(ctx context.Context, c client.Client, input generated.Cre
return nil, ErrNoAuthProvided
}

func checkOpenAI(ctx context.Context, c client.Client, input generated.CreateModelServiceInput) (string, error) {
func checkOpenAI(ctx context.Context, input generated.CreateModelServiceInput) (string, error) {
apiKey := input.Endpoint.Auth["apiKey"].(string)
client, err := openai.NewOpenAI(apiKey, input.Endpoint.URL)
if err != nil {
return "", err
}

// TODO: able to validate openai models
res, err := client.Validate(ctx, llms.WithModel(""))
// use the first model if specified by user
model := "gpt-3.5"
if input.LlmModels != nil && len(input.LlmModels) > 0 {
model = input.LlmModels[0]
}
if input.EmbeddingModels != nil && len(input.EmbeddingModels) > 0 {
model = input.EmbeddingModels[0]
}

// able to validate openai models
res, err := client.Validate(ctx, llms.WithModel(model))
if err != nil {
return "", err
}
return res.String(), nil
}

func checkZhipuAI(ctx context.Context, c client.Client, input generated.CreateModelServiceInput) (string, error) {
func checkZhipuAI(ctx context.Context, input generated.CreateModelServiceInput) (string, error) {
apiKey := input.Endpoint.Auth["apiKey"].(string)
client := zhipuai.NewZhiPuAI(apiKey)
res, err := client.Validate(ctx)
Expand Down
2 changes: 1 addition & 1 deletion deploy/charts/arcadia/Chart.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ apiVersion: v2
name: arcadia
description: A Helm chart(Also a KubeBB Component) for KubeAGI Arcadia
type: application
version: 0.3.11
version: 0.3.12
appVersion: "0.2.0"

keywords:
Expand Down
61 changes: 0 additions & 61 deletions deploy/charts/arcadia/charts/fastchat/templates/ingress.yaml

This file was deleted.

3 changes: 3 additions & 0 deletions deploy/charts/arcadia/templates/agent-portal.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -56,6 +56,9 @@ spec:
name: agentportal-config-volume
subPath: .env.production
restartPolicy: Always
{{- if .Values.global.hostConfig.enabled }}
hostAliases: {{ toYaml .Values.global.hostConfig.hostAliases | nindent 6 }}
{{- end }}
volumes:
- hostPath:
path: /etc/localtime
Expand Down
3 changes: 3 additions & 0 deletions deploy/charts/arcadia/templates/apiserver.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ spec:
app: {{ .Release.Name }}-apiserver
spec:
serviceAccountName: {{ .Release.Name }}
{{- if .Values.global.hostConfig.enabled }}
hostAliases: {{ toYaml .Values.global.hostConfig.hostAliases | nindent 6 }}
{{- end }}
containers:
- name: apiserver
image: {{ .Values.apiserver.image }}
Expand Down
3 changes: 3 additions & 0 deletions deploy/charts/arcadia/templates/controller.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -67,3 +67,6 @@ spec:
resources: {{ toYaml .Values.controller.resources | nindent 10 }}
serviceAccountName: {{ .Release.Name }}
terminationGracePeriodSeconds: 10
{{- if .Values.global.hostConfig.enabled }}
hostAliases: {{ toYaml .Values.global.hostConfig.hostAliases | nindent 6 }}
{{- end }}
3 changes: 3 additions & 0 deletions deploy/charts/arcadia/templates/dataprocess.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -16,6 +16,9 @@ spec:
control-plane: {{ .Release.Name }}-dataprocess
spec:
serviceAccountName: {{ .Release.Name }}
{{- if .Values.global.hostConfig.enabled }}
hostAliases: {{ toYaml .Values.global.hostConfig.hostAliases | nindent 6 }}
{{- end }}
containers:
- name: data-process
image: {{ .Values.dataprocess.image }}
Expand Down
3 changes: 3 additions & 0 deletions deploy/charts/arcadia/templates/ops-console.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -14,6 +14,9 @@ spec:
labels:
app: {{ .Release.Name }}-opsconsole
spec:
{{- if .Values.global.hostConfig.enabled }}
hostAliases: {{ toYaml .Values.global.hostConfig.hostAliases | nindent 6 }}
{{- end }}
containers:
- image: {{ .Values.opsconsole.image }}
imagePullPolicy: IfNotPresent
Expand Down
64 changes: 0 additions & 64 deletions deploy/charts/arcadia/templates/rag_job_rbac.yaml

This file was deleted.

65 changes: 65 additions & 0 deletions deploy/charts/arcadia/templates/rbac.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -703,3 +703,68 @@ rules:
verbs:
- get
- list
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRole
metadata:
name: ragas-eval-clusterrole
rules:
- apiGroups:
- ""
resources:
- configmaps
- secrets
verbs:
- get
- list
- apiGroups:
- arcadia.kubeagi.k8s.com.cn
resources:
- datasources
- versioneddatasets
- applications
- llms
- knowledgebases
- embedders
- vectorstores
verbs:
- get
- list
- apiGroups:
- evaluation.arcadia.kubeagi.k8s.com.cn
resources:
- rags
verbs:
- get
- list
- apiGroups:
- chain.arcadia.kubeagi.k8s.com.cn
resources:
- llmchains
- retrievalqachains
verbs:
- get
- list
- apiGroups:
- prompt.arcadia.kubeagi.k8s.com.cn
resources:
- prompts
verbs:
- get
- list
- apiGroups:
- retriever.arcadia.kubeagi.k8s.com.cn
resources:
- knowledgebaseretrievers
verbs:
- list
- get
---
apiVersion: rbac.authorization.k8s.io/v1
kind: ClusterRoleBinding
metadata:
name: ragas-eval-clusterrolebinding
roleRef:
apiGroup: rbac.authorization.k8s.io
kind: ClusterRole
name: ragas-eval-clusterrole
14 changes: 14 additions & 0 deletions deploy/charts/arcadia/values.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,20 @@ global:
## When the option is `pgvector`, it needs `postgresql.enabled` to be `true` as well to work.
defaultVectorStoreType: pgvector

# Enable and update the ip if nip.io is NOT accessible in deployed environment
hostConfig:
enabled: true
hostAliases:
- hostnames:
- portal.<replaced-ingress-nginx-ip>.nip.io
- gpts.<replaced-ingress-nginx-ip>.nip.io
- minio-api.<replaced-ingress-nginx-ip>.nip.io
- fastchat-api.<replaced-ingress-nginx-ip>.nip.io
- fastchat-controller.<replaced-ingress-nginx-ip>.nip.io
- minio-api.<replaced-ingress-nginx-ip>.nip.io
- postgresql.<replaced-ingress-nginx-ip>.nip.io
ip: <replaced-ingress-nginx-ip>

# @section controller is used as the core controller for arcadia
# @param image Image to be used
# @param imagePullPolcy ImagePullPolicy
Expand Down
4 changes: 4 additions & 0 deletions tests/deploy-values.yaml
Original file line number Diff line number Diff line change
@@ -1,5 +1,9 @@
global:
defaultVectorStoreType: pgvector

# Enable and update the ip if nip.io is NOT accessible in deployed environment
hostConfig:
enabled: false
# @section controller is used as the core controller for arcadia
# @param image Image to be used
# @param imagePullPolcy ImagePullPolicy
Expand Down

0 comments on commit 04923e0

Please sign in to comment.