diff --git a/api/v1alpha1/model.go b/api/v1alpha1/model.go index 86a5a0138..13060c175 100644 --- a/api/v1alpha1/model.go +++ b/api/v1alpha1/model.go @@ -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 diff --git a/api/v1alpha1/model_types.go b/api/v1alpha1/model_types.go index 6effd36ae..5f3c53717 100644 --- a/api/v1alpha1/model_types.go +++ b/api/v1alpha1/model_types.go @@ -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"` diff --git a/config/crd/bases/arcadia.kubeagi.k8s.com.cn_models.yaml b/config/crd/bases/arcadia.kubeagi.k8s.com.cn_models.yaml index 7ecfe2c63..95792a39f 100644 --- a/config/crd/bases/arcadia.kubeagi.k8s.com.cn_models.yaml +++ b/config/crd/bases/arcadia.kubeagi.k8s.com.cn_models.yaml @@ -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 diff --git a/config/samples/arcadia_v1alpha1_model_baichuan2-7b.yaml b/config/samples/arcadia_v1alpha1_model_baichuan2-7b.yaml deleted file mode 100644 index 2c15990e2..000000000 --- a/config/samples/arcadia_v1alpha1_model_baichuan2-7b.yaml +++ /dev/null @@ -1,9 +0,0 @@ -apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1 -kind: Model -metadata: - name: baichuan2-7b - namespace: arcadia -spec: - displayName: "baichuan2-7b" - description: "清华发布的ChatGLM2-6B模型" - type: "llm" diff --git a/config/samples/arcadia_v1alpha1_worker.yaml b/config/samples/arcadia_v1alpha1_worker.yaml deleted file mode 100644 index eab1b6d8a..000000000 --- a/config/samples/arcadia_v1alpha1_worker.yaml +++ /dev/null @@ -1,13 +0,0 @@ -apiVersion: arcadia.kubeagi.k8s.com.cn/v1alpha1 -kind: Worker -metadata: - name: worker-sample - namespace: arcadia -spec: - type: "fastchat" - model: - kind: "Models" - name: "baichuan2-7b" - resources: - limits: - nvidia.com/gpu: "1" # request 1 GPU diff --git a/config/samples/arcadia_v1alpha1_worker_baichuan2-7b.yaml b/config/samples/arcadia_v1alpha1_worker_baichuan2-7b.yaml new file mode 100644 index 000000000..d9355c702 --- /dev/null +++ b/config/samples/arcadia_v1alpha1_worker_baichuan2-7b.yaml @@ -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 diff --git a/config/samples/arcadia_v1alpha1_worker_bge-large-zh-v1.5.yaml b/config/samples/arcadia_v1alpha1_worker_bge-large-zh-v1.5.yaml new file mode 100644 index 000000000..7088884ee --- /dev/null +++ b/config/samples/arcadia_v1alpha1_worker_bge-large-zh-v1.5.yaml @@ -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" diff --git a/controllers/model_controller.go b/controllers/model_controller.go index 7636425bb..15b369e6b 100644 --- a/controllers/model_controller.go +++ b/controllers/model_controller.go @@ -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 } diff --git a/deploy/charts/arcadia/Chart.yaml b/deploy/charts/arcadia/Chart.yaml index e796a9621..544905d3b 100644 --- a/deploy/charts/arcadia/Chart.yaml +++ b/deploy/charts/arcadia/Chart.yaml @@ -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: diff --git a/deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_models.yaml b/deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_models.yaml index 7ecfe2c63..95792a39f 100644 --- a/deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_models.yaml +++ b/deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_models.yaml @@ -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 diff --git a/deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_workers.yaml b/deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_workers.yaml index 54d8f6a19..95792a39f 100644 --- a/deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_workers.yaml +++ b/deploy/charts/arcadia/crds/arcadia.kubeagi.k8s.com.cn_workers.yaml @@ -5,27 +5,20 @@ metadata: annotations: controller-gen.kubebuilder.io/version: v0.9.2 creationTimestamp: null - name: workers.arcadia.kubeagi.k8s.com.cn + name: models.arcadia.kubeagi.k8s.com.cn spec: group: arcadia.kubeagi.k8s.com.cn names: - kind: Worker - listKind: WorkerList - plural: workers - singular: worker + kind: Model + listKind: ModelList + plural: models + singular: model scope: Namespaced versions: - - additionalPrinterColumns: - - jsonPath: .spec.type - name: type - type: string - - jsonPath: .spec.model.name - name: model - type: string - name: v1alpha1 + - name: v1alpha1 schema: openAPIV3Schema: - description: Worker is the Schema for the workers API + description: Model is the Schema for the models API properties: apiVersion: description: 'APIVersion defines the versioned schema of this representation @@ -40,237 +33,29 @@ spec: metadata: type: object spec: - description: WorkerSpec defines the desired state of Worker + description: ModelSpec defines the desired state of Model properties: creator: - description: Creator defines datasource creator (AUTO-FILLED by webhook) + description: Creator defines dataset creator(AUTO-FILLED by webhook) type: string description: description: Description defines datasource description type: string displayName: - description: DisplayName defines datasource display name + description: DisplayName defines dataset display name type: string - model: - description: Model this worker wants to use - properties: - apiGroup: - description: APIGroup is the group for the resource being referenced. - If APIGroup is not specified, the specified Kind must be in - the core API group. For any other third-party types, APIGroup - is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - namespace: - description: Namespace is the namespace of resource being referenced - type: string - required: - - kind - - name - type: object - resources: - description: Resource request&limits including - CPU or GPU - Memory - properties: - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute resources - allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute - resources required. If Requests is omitted for a container, - it defaults to Limits if that is explicitly specified, otherwise - to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - storage: - description: Storage claimed to store model files - properties: - accessModes: - description: 'accessModes contains the desired access modes the - volume should have. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#access-modes-1' - items: - type: string - type: array - dataSource: - description: 'dataSource field can be used to specify either: - * An existing VolumeSnapshot object (snapshot.storage.k8s.io/VolumeSnapshot) - * An existing PVC (PersistentVolumeClaim) If the provisioner - or an external controller can support the specified data source, - it will create a new volume based on the contents of the specified - data source. If the AnyVolumeDataSource feature gate is enabled, - this field will always have the same contents as the DataSourceRef - field.' - properties: - apiGroup: - description: APIGroup is the group for the resource being - referenced. If APIGroup is not specified, the specified - Kind must be in the core API group. For any other third-party - types, APIGroup is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - required: - - kind - - name - type: object - x-kubernetes-map-type: atomic - dataSourceRef: - description: 'dataSourceRef specifies the object from which to - populate the volume with data, if a non-empty volume is desired. - This may be any local object from a non-empty API group (non - core object) or a PersistentVolumeClaim object. When this field - is specified, volume binding will only succeed if the type of - the specified object matches some installed volume populator - or dynamic provisioner. This field will replace the functionality - of the DataSource field and as such if both fields are non-empty, - they must have the same value. For backwards compatibility, - both fields (DataSource and DataSourceRef) will be set to the - same value automatically if one of them is empty and the other - is non-empty. There are two important differences between DataSource - and DataSourceRef: * While DataSource only allows two specific - types of objects, DataSourceRef allows any non-core object, - as well as PersistentVolumeClaim objects. * While DataSource - ignores disallowed values (dropping them), DataSourceRef preserves - all values, and generates an error if a disallowed value is - specified. (Beta) Using this field requires the AnyVolumeDataSource - feature gate to be enabled.' - properties: - apiGroup: - description: APIGroup is the group for the resource being - referenced. If APIGroup is not specified, the specified - Kind must be in the core API group. For any other third-party - types, APIGroup is required. - type: string - kind: - description: Kind is the type of resource being referenced - type: string - name: - description: Name is the name of resource being referenced - type: string - required: - - kind - - name - type: object - x-kubernetes-map-type: atomic - resources: - description: 'resources represents the minimum resources the volume - should have. If RecoverVolumeExpansionFailure feature is enabled - users are allowed to specify resource requirements that are - lower than previous value but must still be higher than capacity - recorded in the status field of the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#resources' - properties: - limits: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Limits describes the maximum amount of compute - resources allowed. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - requests: - additionalProperties: - anyOf: - - type: integer - - type: string - pattern: ^(\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))(([KMGTPE]i)|[numkMGTPE]|([eE](\+|-)?(([0-9]+(\.[0-9]*)?)|(\.[0-9]+))))?$ - x-kubernetes-int-or-string: true - description: 'Requests describes the minimum amount of compute - resources required. If Requests is omitted for a container, - it defaults to Limits if that is explicitly specified, otherwise - to an implementation-defined value. More info: https://kubernetes.io/docs/concepts/configuration/manage-resources-containers/' - type: object - type: object - selector: - description: selector is a label query over volumes to consider - for binding. - properties: - matchExpressions: - description: matchExpressions is a list of label selector - requirements. The requirements are ANDed. - items: - description: A label selector requirement is a selector - that contains values, a key, and an operator that relates - the key and values. - properties: - key: - description: key is the label key that the selector - applies to. - type: string - operator: - description: operator represents a key's relationship - to a set of values. Valid operators are In, NotIn, - Exists and DoesNotExist. - type: string - values: - description: values is an array of string values. If - the operator is In or NotIn, the values array must - be non-empty. If the operator is Exists or DoesNotExist, - the values array must be empty. This array is replaced - during a strategic merge patch. - items: - type: string - type: array - required: - - key - - operator - type: object - type: array - matchLabels: - additionalProperties: - type: string - description: matchLabels is a map of {key,value} pairs. A - single {key,value} in the matchLabels map is equivalent - to an element of matchExpressions, whose key field is "key", - the operator is "In", and the values array contains only - "value". The requirements are ANDed. - type: object - type: object - x-kubernetes-map-type: atomic - storageClassName: - description: 'storageClassName is the name of the StorageClass - required by the claim. More info: https://kubernetes.io/docs/concepts/storage/persistent-volumes#class-1' - type: string - volumeMode: - description: volumeMode defines what type of volume is required - by the claim. Value of Filesystem is implied when not included - in claim spec. - type: string - volumeName: - description: volumeName is the binding reference to the PersistentVolume - backing this claim. - type: string - type: object - type: - description: Type for this worker + field: + description: Model application fields + type: string + types: + description: Type defines what kind of model this is Comma seperated + field which can be wrapped by {llm,embdding} type: string required: - - model + - displayName type: object status: - description: WorkerStatus defines the observed state of Worker + description: ModelStatus defines the observed state of Model properties: conditions: description: Conditions of the resource. @@ -310,631 +95,6 @@ spec: - type type: object type: array - podStatus: - description: PodStatus is the observed stated of Worker pod - properties: - conditions: - description: 'Current service state of pod. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions' - items: - description: PodCondition contains details for the current condition - of this pod. - properties: - lastProbeTime: - description: Last time we probed the condition. - format: date-time - type: string - lastTransitionTime: - description: Last time the condition transitioned from one - status to another. - format: date-time - type: string - message: - description: Human-readable message indicating details about - last transition. - type: string - reason: - description: Unique, one-word, CamelCase reason for the - condition's last transition. - type: string - status: - description: 'Status is the status of the condition. Can - be True, False, Unknown. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions' - type: string - type: - description: 'Type is the type of the condition. More info: - https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-conditions' - type: string - required: - - status - - type - type: object - type: array - containerStatuses: - description: 'The list has one entry per container in the manifest. - More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status' - items: - description: ContainerStatus contains details for the current - status of this container. - properties: - containerID: - description: Container's ID in the format '://'. - type: string - image: - description: 'The image the container is running. More info: - https://kubernetes.io/docs/concepts/containers/images.' - type: string - imageID: - description: ImageID of the container's image. - type: string - lastState: - description: Details about the container's last termination - condition. - properties: - running: - description: Details about a running container - properties: - startedAt: - description: Time at which the container was last - (re-)started - format: date-time - type: string - type: object - terminated: - description: Details about a terminated container - properties: - containerID: - description: Container's ID in the format '://' - type: string - exitCode: - description: Exit status from the last termination - of the container - format: int32 - type: integer - finishedAt: - description: Time at which the container last terminated - format: date-time - type: string - message: - description: Message regarding the last termination - of the container - type: string - reason: - description: (brief) reason from the last termination - of the container - type: string - signal: - description: Signal from the last termination of - the container - format: int32 - type: integer - startedAt: - description: Time at which previous execution of - the container started - format: date-time - type: string - required: - - exitCode - type: object - waiting: - description: Details about a waiting container - properties: - message: - description: Message regarding why the container - is not yet running. - type: string - reason: - description: (brief) reason the container is not - yet running. - type: string - type: object - type: object - name: - description: This must be a DNS_LABEL. Each container in - a pod must have a unique name. Cannot be updated. - type: string - ready: - description: Specifies whether the container has passed - its readiness probe. - type: boolean - restartCount: - description: The number of times the container has been - restarted. - format: int32 - type: integer - started: - description: Specifies whether the container has passed - its startup probe. Initialized as false, becomes true - after startupProbe is considered successful. Resets to - false when the container is restarted, or if kubelet loses - state temporarily. Is always true when no startupProbe - is defined. - type: boolean - state: - description: Details about the container's current condition. - properties: - running: - description: Details about a running container - properties: - startedAt: - description: Time at which the container was last - (re-)started - format: date-time - type: string - type: object - terminated: - description: Details about a terminated container - properties: - containerID: - description: Container's ID in the format '://' - type: string - exitCode: - description: Exit status from the last termination - of the container - format: int32 - type: integer - finishedAt: - description: Time at which the container last terminated - format: date-time - type: string - message: - description: Message regarding the last termination - of the container - type: string - reason: - description: (brief) reason from the last termination - of the container - type: string - signal: - description: Signal from the last termination of - the container - format: int32 - type: integer - startedAt: - description: Time at which previous execution of - the container started - format: date-time - type: string - required: - - exitCode - type: object - waiting: - description: Details about a waiting container - properties: - message: - description: Message regarding why the container - is not yet running. - type: string - reason: - description: (brief) reason the container is not - yet running. - type: string - type: object - type: object - required: - - image - - imageID - - name - - ready - - restartCount - type: object - type: array - ephemeralContainerStatuses: - description: Status for any ephemeral containers that have run - in this pod. This field is beta-level and available on clusters - that haven't disabled the EphemeralContainers feature gate. - items: - description: ContainerStatus contains details for the current - status of this container. - properties: - containerID: - description: Container's ID in the format '://'. - type: string - image: - description: 'The image the container is running. More info: - https://kubernetes.io/docs/concepts/containers/images.' - type: string - imageID: - description: ImageID of the container's image. - type: string - lastState: - description: Details about the container's last termination - condition. - properties: - running: - description: Details about a running container - properties: - startedAt: - description: Time at which the container was last - (re-)started - format: date-time - type: string - type: object - terminated: - description: Details about a terminated container - properties: - containerID: - description: Container's ID in the format '://' - type: string - exitCode: - description: Exit status from the last termination - of the container - format: int32 - type: integer - finishedAt: - description: Time at which the container last terminated - format: date-time - type: string - message: - description: Message regarding the last termination - of the container - type: string - reason: - description: (brief) reason from the last termination - of the container - type: string - signal: - description: Signal from the last termination of - the container - format: int32 - type: integer - startedAt: - description: Time at which previous execution of - the container started - format: date-time - type: string - required: - - exitCode - type: object - waiting: - description: Details about a waiting container - properties: - message: - description: Message regarding why the container - is not yet running. - type: string - reason: - description: (brief) reason the container is not - yet running. - type: string - type: object - type: object - name: - description: This must be a DNS_LABEL. Each container in - a pod must have a unique name. Cannot be updated. - type: string - ready: - description: Specifies whether the container has passed - its readiness probe. - type: boolean - restartCount: - description: The number of times the container has been - restarted. - format: int32 - type: integer - started: - description: Specifies whether the container has passed - its startup probe. Initialized as false, becomes true - after startupProbe is considered successful. Resets to - false when the container is restarted, or if kubelet loses - state temporarily. Is always true when no startupProbe - is defined. - type: boolean - state: - description: Details about the container's current condition. - properties: - running: - description: Details about a running container - properties: - startedAt: - description: Time at which the container was last - (re-)started - format: date-time - type: string - type: object - terminated: - description: Details about a terminated container - properties: - containerID: - description: Container's ID in the format '://' - type: string - exitCode: - description: Exit status from the last termination - of the container - format: int32 - type: integer - finishedAt: - description: Time at which the container last terminated - format: date-time - type: string - message: - description: Message regarding the last termination - of the container - type: string - reason: - description: (brief) reason from the last termination - of the container - type: string - signal: - description: Signal from the last termination of - the container - format: int32 - type: integer - startedAt: - description: Time at which previous execution of - the container started - format: date-time - type: string - required: - - exitCode - type: object - waiting: - description: Details about a waiting container - properties: - message: - description: Message regarding why the container - is not yet running. - type: string - reason: - description: (brief) reason the container is not - yet running. - type: string - type: object - type: object - required: - - image - - imageID - - name - - ready - - restartCount - type: object - type: array - hostIP: - description: IP address of the host to which the pod is assigned. - Empty if not yet scheduled. - type: string - initContainerStatuses: - description: 'The list has one entry per init container in the - manifest. The most recent successful init container will have - ready = true, the most recently started container will have - startTime set. More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-and-container-status' - items: - description: ContainerStatus contains details for the current - status of this container. - properties: - containerID: - description: Container's ID in the format '://'. - type: string - image: - description: 'The image the container is running. More info: - https://kubernetes.io/docs/concepts/containers/images.' - type: string - imageID: - description: ImageID of the container's image. - type: string - lastState: - description: Details about the container's last termination - condition. - properties: - running: - description: Details about a running container - properties: - startedAt: - description: Time at which the container was last - (re-)started - format: date-time - type: string - type: object - terminated: - description: Details about a terminated container - properties: - containerID: - description: Container's ID in the format '://' - type: string - exitCode: - description: Exit status from the last termination - of the container - format: int32 - type: integer - finishedAt: - description: Time at which the container last terminated - format: date-time - type: string - message: - description: Message regarding the last termination - of the container - type: string - reason: - description: (brief) reason from the last termination - of the container - type: string - signal: - description: Signal from the last termination of - the container - format: int32 - type: integer - startedAt: - description: Time at which previous execution of - the container started - format: date-time - type: string - required: - - exitCode - type: object - waiting: - description: Details about a waiting container - properties: - message: - description: Message regarding why the container - is not yet running. - type: string - reason: - description: (brief) reason the container is not - yet running. - type: string - type: object - type: object - name: - description: This must be a DNS_LABEL. Each container in - a pod must have a unique name. Cannot be updated. - type: string - ready: - description: Specifies whether the container has passed - its readiness probe. - type: boolean - restartCount: - description: The number of times the container has been - restarted. - format: int32 - type: integer - started: - description: Specifies whether the container has passed - its startup probe. Initialized as false, becomes true - after startupProbe is considered successful. Resets to - false when the container is restarted, or if kubelet loses - state temporarily. Is always true when no startupProbe - is defined. - type: boolean - state: - description: Details about the container's current condition. - properties: - running: - description: Details about a running container - properties: - startedAt: - description: Time at which the container was last - (re-)started - format: date-time - type: string - type: object - terminated: - description: Details about a terminated container - properties: - containerID: - description: Container's ID in the format '://' - type: string - exitCode: - description: Exit status from the last termination - of the container - format: int32 - type: integer - finishedAt: - description: Time at which the container last terminated - format: date-time - type: string - message: - description: Message regarding the last termination - of the container - type: string - reason: - description: (brief) reason from the last termination - of the container - type: string - signal: - description: Signal from the last termination of - the container - format: int32 - type: integer - startedAt: - description: Time at which previous execution of - the container started - format: date-time - type: string - required: - - exitCode - type: object - waiting: - description: Details about a waiting container - properties: - message: - description: Message regarding why the container - is not yet running. - type: string - reason: - description: (brief) reason the container is not - yet running. - type: string - type: object - type: object - required: - - image - - imageID - - name - - ready - - restartCount - type: object - type: array - message: - description: A human readable message indicating details about - why the pod is in this condition. - type: string - nominatedNodeName: - description: nominatedNodeName is set only when this pod preempts - other pods on the node, but it cannot be scheduled right away - as preemption victims receive their graceful termination periods. - This field does not guarantee that the pod will be scheduled - on this node. Scheduler may decide to place the pod elsewhere - if other nodes become available sooner. Scheduler may also decide - to give the resources on this node to a higher priority pod - that is created after preemption. As a result, this field may - be different than PodSpec.nodeName when the pod is scheduled. - type: string - phase: - description: "The phase of a Pod is a simple, high-level summary - of where the Pod is in its lifecycle. The conditions array, - the reason and message fields, and the individual container - status arrays contain more detail about the pod's status. There - are five possible phase values: \n Pending: The pod has been - accepted by the Kubernetes system, but one or more of the container - images has not been created. This includes time before being - scheduled as well as time spent downloading images over the - network, which could take a while. Running: The pod has been - bound to a node, and all of the containers have been created. - At least one container is still running, or is in the process - of starting or restarting. Succeeded: All containers in the - pod have terminated in success, and will not be restarted. Failed: - All containers in the pod have terminated, and at least one - container has terminated in failure. The container either exited - with non-zero status or was terminated by the system. Unknown: - For some reason the state of the pod could not be obtained, - typically due to an error in communicating with the host of - the pod. \n More info: https://kubernetes.io/docs/concepts/workloads/pods/pod-lifecycle#pod-phase" - type: string - podIP: - description: IP address allocated to the pod. Routable at least - within the cluster. Empty if not yet allocated. - type: string - podIPs: - description: podIPs holds the IP addresses allocated to the pod. - If this field is specified, the 0th entry must match the podIP - field. Pods may be allocated at most 1 value for each of IPv4 - and IPv6. This list is empty if no IPs have been allocated yet. - items: - description: 'IP address information for entries in the (plural) - PodIPs field. Each entry includes: IP: An IP address allocated - to the pod. Routable at least within the cluster.' - properties: - ip: - description: ip is an IP address (IPv4 or IPv6) assigned - to the pod - type: string - type: object - type: array - qosClass: - description: 'The Quality of Service (QOS) classification assigned - to the pod based on resource requirements See PodQOSClass type - for available QOS classes More info: https://git.k8s.io/community/contributors/design-proposals/node/resource-qos.md' - type: string - reason: - description: A brief CamelCase message indicating details about - why the pod is in this state. e.g. 'Evicted' - type: string - startTime: - description: RFC 3339 date and time at which the object was acknowledged - by the Kubelet. This is before the Kubelet pulled the container - image(s) for the pod. - format: date-time - type: string - type: object type: object type: object served: true diff --git a/examples/chat_with_worker/README.md b/examples/chat_with_worker/README.md new file mode 100644 index 000000000..f0a11e98b --- /dev/null +++ b/examples/chat_with_worker/README.md @@ -0,0 +1,24 @@ +# Chat with Worker + +An example to chat with [worker baichuan2-7b](https://github.com/kubeagi/arcadia/blob/main/config/samples/arcadia_v1alpha1_worker_baichuan2-7b.yaml). + +We utilize [fastchat](https://github.com/lm-sys/FastChat) to provide OpenAI-Compatible RESTFul APIs. + +Before using this example,please make sure you have deployed this [baichuan2-7b worker](https://github.com/kubeagi/arcadia/blob/main/config/samples/arcadia_v1alpha1_worker_baichuan2-7b.yaml) + +## Usage + +1. Update the baseurl in [main.go](./main.go) based on how you deploy arcadia + +At this example, we deploy arcadia + +- namespace: arcadia +- with ingress: arcadia-fastchat.172.22.96.167.nip.io + +Then we get a final base url `http://arcadia-fastchat.172.22.96.167.nip.io/v1` + +2. Run this chat & embedding example + +```golang +go run main.go +``` \ No newline at end of file diff --git a/examples/chat_with_worker/main.go b/examples/chat_with_worker/main.go new file mode 100644 index 000000000..2e40b1640 --- /dev/null +++ b/examples/chat_with_worker/main.go @@ -0,0 +1,39 @@ +package main + +import ( + "context" + "fmt" + "log" + + "github.com/tmc/langchaingo/llms" + "github.com/tmc/langchaingo/llms/openai" +) + +func main() { + llm, err := openai.New( + openai.WithToken("fake"), + // update base url to fastchat api server + openai.WithBaseURL("http://arcadia-fastchat.172.22.96.167.nip.io/v1"), + openai.WithModel("baichuan2-7b"), + ) + if err != nil { + log.Fatal(err) + } + // llm call + completion, err := llm.Call(context.Background(), "The first man to walk on the moon", + llms.WithTemperature(0.8), + llms.WithStopWords([]string{"Armstrong"}), + ) + if err != nil { + log.Fatal(err) + } + + fmt.Println(completion) + + // create embeddings + embeddings, err := llm.CreateEmbedding(context.Background(), []string{"hello,this is a embedding call"}) + if err != nil { + panic(err) + } + fmt.Println(embeddings) +} diff --git a/graphql-server/go-server/graph/generated/generated.go b/graphql-server/go-server/graph/generated/generated.go index 929d5ce45..66ba57a97 100644 --- a/graphql-server/go-server/graph/generated/generated.go +++ b/graphql-server/go-server/graph/generated/generated.go @@ -143,7 +143,7 @@ type ComplexityRoot struct { DisplayName func(childComplexity int) int Field func(childComplexity int) int Labels func(childComplexity int) int - Modeltype func(childComplexity int) int + Modeltypes func(childComplexity int) int Name func(childComplexity int) int Namespace func(childComplexity int) int UpdateTimestamp func(childComplexity int) int @@ -753,12 +753,12 @@ func (e *executableSchema) Complexity(typeName, field string, childComplexity in return e.complexity.Model.Labels(childComplexity), true - case "Model.modeltype": - if e.complexity.Model.Modeltype == nil { + case "Model.modeltypes": + if e.complexity.Model.Modeltypes == nil { break } - return e.complexity.Model.Modeltype(childComplexity), true + return e.complexity.Model.Modeltypes(childComplexity), true case "Model.name": if e.complexity.Model.Name == nil { @@ -1494,37 +1494,37 @@ extend type Query{ displayName: String! description: String field: String! - modeltype: String! + modeltypes: String! updateTimestamp: Time } input CreateModelInput{ - """模型仓库资源名称(不可同名)""" + """模型资源名称(不可同名)""" name: String! - """模型仓库创建命名空间""" + """模型创建命名空间""" namespace: String! - """模型仓库资源展示名称作为显示,并提供编辑""" + """模型资源展示名称作为显示,并提供编辑""" displayName: String! - """模型仓库应用领域""" + """模型应用领域""" field: String! - """模型仓库资源描述""" + """模型资源描述""" description: String - """模型仓库类型""" - modeltype: String! + """模型类型""" + modeltypes: String! } input UpdateModelInput { - """模型仓库资源名称(不可同名)""" + """模型资源名称(不可同名)""" name: String! - """模型仓库创建命名空间""" + """模型创建命名空间""" namespace: String! - """模型仓库资标签""" + """模型资标签""" labels: Map - """模型仓库资源注释""" + """模型资源注释""" annotations: Map - """模型仓库资源展示名称作为显示,并提供编辑""" + """模型资源展示名称作为显示,并提供编辑""" displayName: String! - """模型仓库资源描述""" + """模型资源描述""" description: String } @@ -5015,8 +5015,8 @@ func (ec *executionContext) fieldContext_Model_field(ctx context.Context, field return fc, nil } -func (ec *executionContext) _Model_modeltype(ctx context.Context, field graphql.CollectedField, obj *Model) (ret graphql.Marshaler) { - fc, err := ec.fieldContext_Model_modeltype(ctx, field) +func (ec *executionContext) _Model_modeltypes(ctx context.Context, field graphql.CollectedField, obj *Model) (ret graphql.Marshaler) { + fc, err := ec.fieldContext_Model_modeltypes(ctx, field) if err != nil { return graphql.Null } @@ -5029,7 +5029,7 @@ func (ec *executionContext) _Model_modeltype(ctx context.Context, field graphql. }() resTmp, err := ec.ResolverMiddleware(ctx, func(rctx context.Context) (interface{}, error) { ctx = rctx // use context from middleware stack in children - return obj.Modeltype, nil + return obj.Modeltypes, nil }) if err != nil { ec.Error(ctx, err) @@ -5046,7 +5046,7 @@ func (ec *executionContext) _Model_modeltype(ctx context.Context, field graphql. return ec.marshalNString2string(ctx, field.Selections, res) } -func (ec *executionContext) fieldContext_Model_modeltype(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { +func (ec *executionContext) fieldContext_Model_modeltypes(ctx context.Context, field graphql.CollectedField) (fc *graphql.FieldContext, err error) { fc = &graphql.FieldContext{ Object: "Model", Field: field, @@ -5155,8 +5155,8 @@ func (ec *executionContext) fieldContext_ModelMutation_createModel(ctx context.C return ec.fieldContext_Model_description(ctx, field) case "field": return ec.fieldContext_Model_field(ctx, field) - case "modeltype": - return ec.fieldContext_Model_modeltype(ctx, field) + case "modeltypes": + return ec.fieldContext_Model_modeltypes(ctx, field) case "updateTimestamp": return ec.fieldContext_Model_updateTimestamp(ctx, field) } @@ -5232,8 +5232,8 @@ func (ec *executionContext) fieldContext_ModelMutation_updateModel(ctx context.C return ec.fieldContext_Model_description(ctx, field) case "field": return ec.fieldContext_Model_field(ctx, field) - case "modeltype": - return ec.fieldContext_Model_modeltype(ctx, field) + case "modeltypes": + return ec.fieldContext_Model_modeltypes(ctx, field) case "updateTimestamp": return ec.fieldContext_Model_updateTimestamp(ctx, field) } @@ -5361,8 +5361,8 @@ func (ec *executionContext) fieldContext_ModelQuery_getModel(ctx context.Context return ec.fieldContext_Model_description(ctx, field) case "field": return ec.fieldContext_Model_field(ctx, field) - case "modeltype": - return ec.fieldContext_Model_modeltype(ctx, field) + case "modeltypes": + return ec.fieldContext_Model_modeltypes(ctx, field) case "updateTimestamp": return ec.fieldContext_Model_updateTimestamp(ctx, field) } @@ -8693,7 +8693,7 @@ func (ec *executionContext) unmarshalInputCreateModelInput(ctx context.Context, asMap[k] = v } - fieldsInOrder := [...]string{"name", "namespace", "displayName", "field", "description", "modeltype"} + fieldsInOrder := [...]string{"name", "namespace", "displayName", "field", "description", "modeltypes"} for _, k := range fieldsInOrder { v, ok := asMap[k] if !ok { @@ -8745,15 +8745,15 @@ func (ec *executionContext) unmarshalInputCreateModelInput(ctx context.Context, return it, err } it.Description = data - case "modeltype": + case "modeltypes": var err error - ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modeltype")) + ctx := graphql.WithPathContext(ctx, graphql.NewPathWithField("modeltypes")) data, err := ec.unmarshalNString2string(ctx, v) if err != nil { return it, err } - it.Modeltype = data + it.Modeltypes = data } } @@ -10889,8 +10889,8 @@ func (ec *executionContext) _Model(ctx context.Context, sel ast.SelectionSet, ob if out.Values[i] == graphql.Null { out.Invalids++ } - case "modeltype": - out.Values[i] = ec._Model_modeltype(ctx, field, obj) + case "modeltypes": + out.Values[i] = ec._Model_modeltypes(ctx, field, obj) if out.Values[i] == graphql.Null { out.Invalids++ } diff --git a/graphql-server/go-server/graph/generated/models_gen.go b/graphql-server/go-server/graph/generated/models_gen.go index a357e1860..f9d9f580f 100644 --- a/graphql-server/go-server/graph/generated/models_gen.go +++ b/graphql-server/go-server/graph/generated/models_gen.go @@ -69,18 +69,18 @@ type CreateKnowledgeBaseInput struct { } type CreateModelInput struct { - // 模型仓库资源名称(不可同名) + // 模型资源名称(不可同名) Name string `json:"name"` - // 模型仓库创建命名空间 + // 模型创建命名空间 Namespace string `json:"namespace"` - // 模型仓库资源展示名称作为显示,并提供编辑 + // 模型资源展示名称作为显示,并提供编辑 DisplayName string `json:"displayName"` - // 模型仓库应用领域 + // 模型应用领域 Field string `json:"field"` - // 模型仓库资源描述 + // 模型资源描述 Description *string `json:"description,omitempty"` - // 模型仓库类型 - Modeltype string `json:"modeltype"` + // 模型类型 + Modeltypes string `json:"modeltypes"` } type Datasource struct { @@ -279,7 +279,7 @@ type Model struct { DisplayName string `json:"displayName"` Description *string `json:"description,omitempty"` Field string `json:"field"` - Modeltype string `json:"modeltype"` + Modeltypes string `json:"modeltypes"` UpdateTimestamp *time.Time `json:"updateTimestamp,omitempty"` } @@ -375,17 +375,17 @@ type UpdateKnowledgeBaseInput struct { } type UpdateModelInput struct { - // 模型仓库资源名称(不可同名) + // 模型资源名称(不可同名) Name string `json:"name"` - // 模型仓库创建命名空间 + // 模型创建命名空间 Namespace string `json:"namespace"` - // 模型仓库资标签 + // 模型资标签 Labels map[string]interface{} `json:"labels,omitempty"` - // 模型仓库资源注释 + // 模型资源注释 Annotations map[string]interface{} `json:"annotations,omitempty"` - // 模型仓库资源展示名称作为显示,并提供编辑 + // 模型资源展示名称作为显示,并提供编辑 DisplayName string `json:"displayName"` - // 模型仓库资源描述 + // 模型资源描述 Description *string `json:"description,omitempty"` } diff --git a/graphql-server/go-server/graph/impl/model.resolvers.go b/graphql-server/go-server/graph/impl/model.resolvers.go index 37aa4b0ba..9acb27a37 100644 --- a/graphql-server/go-server/graph/impl/model.resolvers.go +++ b/graphql-server/go-server/graph/impl/model.resolvers.go @@ -22,7 +22,7 @@ func (r *modelMutationResolver) CreateModel(ctx context.Context, obj *generated. return nil, err } - displayname, description, filed, modeltype := "", "", "", "" + displayname, description, filed, modeltypes := "", "", "", "" if input.DisplayName != "" { displayname = input.DisplayName @@ -33,10 +33,10 @@ func (r *modelMutationResolver) CreateModel(ctx context.Context, obj *generated. if input.Field != "" { filed = input.Field } - if input.Modeltype != "" { - modeltype = input.Modeltype + if input.Modeltypes != "" { + modeltypes = input.Modeltypes } - return md.CreateModel(ctx, c, input.Name, input.Namespace, displayname, description, filed, modeltype) + return md.CreateModel(ctx, c, input.Name, input.Namespace, displayname, description, filed, modeltypes) } // UpdateModel is the resolver for the updateModel field. diff --git a/graphql-server/go-server/graph/schema/model.graphqls b/graphql-server/go-server/graph/schema/model.graphqls index 39cdc9355..b6aee3b65 100644 --- a/graphql-server/go-server/graph/schema/model.graphqls +++ b/graphql-server/go-server/graph/schema/model.graphqls @@ -7,37 +7,37 @@ type Model { displayName: String! description: String field: String! - modeltype: String! + modeltypes: String! updateTimestamp: Time } input CreateModelInput{ - """模型仓库资源名称(不可同名)""" + """模型资源名称(不可同名)""" name: String! - """模型仓库创建命名空间""" + """模型创建命名空间""" namespace: String! - """模型仓库资源展示名称作为显示,并提供编辑""" + """模型资源展示名称作为显示,并提供编辑""" displayName: String! - """模型仓库应用领域""" + """模型应用领域""" field: String! - """模型仓库资源描述""" + """模型资源描述""" description: String - """模型仓库类型""" - modeltype: String! + """模型类型""" + modeltypes: String! } input UpdateModelInput { - """模型仓库资源名称(不可同名)""" + """模型资源名称(不可同名)""" name: String! - """模型仓库创建命名空间""" + """模型创建命名空间""" namespace: String! - """模型仓库资标签""" + """模型资标签""" labels: Map - """模型仓库资源注释""" + """模型资源注释""" annotations: Map - """模型仓库资源展示名称作为显示,并提供编辑""" + """模型资源展示名称作为显示,并提供编辑""" displayName: String! - """模型仓库资源描述""" + """模型资源描述""" description: String } diff --git a/graphql-server/go-server/pkg/model/model.go b/graphql-server/go-server/pkg/model/model.go index 80be2da90..e1bfaa1bc 100644 --- a/graphql-server/go-server/pkg/model/model.go +++ b/graphql-server/go-server/pkg/model/model.go @@ -60,13 +60,13 @@ func obj2model(obj *unstructured.Unstructured) *model.Model { DisplayName: displayName, Description: &description, Field: field, - Modeltype: modeltype, + Modeltypes: modeltype, UpdateTimestamp: &updateTime, } return &md } -func CreateModel(ctx context.Context, c dynamic.Interface, name, namespace, displayName, description, field, modeltype string) (*model.Model, error) { +func CreateModel(ctx context.Context, c dynamic.Interface, name, namespace, displayName, description, field, modeltypes string) (*model.Model, error) { model := v1alpha1.Model{ ObjectMeta: metav1.ObjectMeta{ Name: name, @@ -80,7 +80,7 @@ func CreateModel(ctx context.Context, c dynamic.Interface, name, namespace, disp DiplayName: displayName, Description: description, Field: field, - Type: v1alpha1.ModelType(modeltype), + Types: modeltypes, }, } unstructuredModel, err := runtime.DefaultUnstructuredConverter.ToUnstructured(&model)