Skip to content

Commit

Permalink
fix: change model's type to plural; add example to call worker apis
Browse files Browse the repository at this point in the history
Signed-off-by: bjwswang <[email protected]>
  • Loading branch information
bjwswang committed Nov 21, 2023
1 parent 11cf14a commit 2f82623
Show file tree
Hide file tree
Showing 18 changed files with 215 additions and 974 deletions.
24 changes: 9 additions & 15 deletions api/v1alpha1/model.go
Original file line number Diff line number Diff line change
Expand Up @@ -16,27 +16,21 @@ limitations under the License.

package v1alpha1

import "fmt"

const (
// LabelModelType keeps the spec.type field
LabelModelType = Group + "/model-type"
LabelModelFullPath = Group + "/full-path"
import (
"fmt"
)

type ModelType string

const (
ModelTypeEmbedding ModelType = "embedding"
ModelTypeLLM ModelType = "llm"
ModelTypeUnknown ModelType = "unknown"
// LabelModelTypes keeps the spec.types field
LabelModelTypes = Group + "/model-types"
LabelModelFullPath = Group + "/full-path"
)

func (model Model) ModelType() ModelType {
if model.Spec.Type == "" {
return ModelTypeUnknown
func (model Model) ModelTypes() string {
if model.Spec.Types == "" {
return "unknown"
}
return model.Spec.Type
return model.Spec.Types
}

// FullPath with bucket and object path
Expand Down
3 changes: 2 additions & 1 deletion api/v1alpha1/model_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,8 @@ type ModelSpec struct {
Field string `json:"field,omitempty"`

// Type defines what kind of model this is
Type ModelType `json:"type,omitempty"`
// Comma seperated field which can be wrapped by {llm,embdding}
Types string `json:"types,omitempty"`

// TODO: extend model to utilize third party storage sources
// Source *TypedObjectReference `json:"source,omitempty"`
Expand Down
5 changes: 3 additions & 2 deletions config/crd/bases/arcadia.kubeagi.k8s.com.cn_models.yaml
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ spec:
field:
description: Model application fields
type: string
type:
description: Type defines what kind of model this is
types:
description: Type defines what kind of model this is Comma seperated
field which can be wrapped by {llm,embdding}
type: string
required:
- displayName
Expand Down
9 changes: 0 additions & 9 deletions config/samples/arcadia_v1alpha1_model_baichuan2-7b.yaml

This file was deleted.

13 changes: 0 additions & 13 deletions config/samples/arcadia_v1alpha1_worker.yaml

This file was deleted.

23 changes: 23 additions & 0 deletions config/samples/arcadia_v1alpha1_worker_baichuan2-7b.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,23 @@
apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1
kind: Model
metadata:
name: baichuan2-7b
namespace: arcadia
spec:
displayName: "baichuan2-7b"
description: "百川智能发布的大语言模型模型,同时提供embedding模型能力"
types: "llm,embedding"
---
apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1
kind: Worker
metadata:
name: worker-baichuan
namespace: arcadia
spec:
type: "fastchat"
model:
kind: "Models"
name: "baichuan2-7b"
resources:
limits:
nvidia.com/gpu: "1" # request 1 GPU
20 changes: 20 additions & 0 deletions config/samples/arcadia_v1alpha1_worker_bge-large-zh-v1.5.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,20 @@
apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1
kind: Model
metadata:
name: bge-large-zh-v1.5
namespace: arcadia
spec:
displayName: "bge-large-zh-v1.5"
description: "智源研究员发布的Embedding模型"
types: "embedding"
---
apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1
kind: Worker
metadata:
name: worker-bge
namespace: arcadia
spec:
type: "fastchat"
model:
kind: "Models"
name: "bge-large-zh-v1.5"
8 changes: 4 additions & 4 deletions controllers/model_controller.go
Original file line number Diff line number Diff line change
Expand Up @@ -140,10 +140,10 @@ func (r *ModelReconciler) Initialize(ctx context.Context, logger logr.Logger, in
if instanceDeepCopy.Labels == nil {
instanceDeepCopy.Labels = make(map[string]string)
}
// For model type
currentType := string(instanceDeepCopy.ModelType())
if v := instanceDeepCopy.Labels[arcadiav1alpha1.LabelModelType]; v != currentType {
instanceDeepCopy.Labels[arcadiav1alpha1.LabelModelType] = currentType
// For model types
currentType := string(instanceDeepCopy.ModelTypes())
if v := instanceDeepCopy.Labels[arcadiav1alpha1.LabelModelTypes]; v != currentType {
instanceDeepCopy.Labels[arcadiav1alpha1.LabelModelTypes] = currentType
update = true
}

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(KubeBB Component) for KubeAGI Arcadia
type: application
version: 0.1.26
version: 0.1.27
appVersion: "0.0.1"

keywords:
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,9 @@ spec:
field:
description: Model application fields
type: string
type:
description: Type defines what kind of model this is
types:
description: Type defines what kind of model this is Comma seperated
field which can be wrapped by {llm,embdding}
type: string
required:
- displayName
Expand Down
Loading

0 comments on commit 2f82623

Please sign in to comment.