Skip to content

Commit

Permalink
feat: new CRD VectorStore Chroma
Browse files Browse the repository at this point in the history
Signed-off-by: Abirdcfly <[email protected]>
  • Loading branch information
Abirdcfly committed Nov 2, 2023
1 parent 999b221 commit 3e405c7
Show file tree
Hide file tree
Showing 35 changed files with 9,744 additions and 25 deletions.
27 changes: 27 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -72,4 +72,31 @@ resources:
kind: VersionedDataset
path: github.com/kubeagi/arcadia/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kubeagi.k8s.com.cn
group: arcadia
kind: VectorStore
path: github.com/kubeagi/arcadia/api/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: arcadia.kubeagi.k8s.com.cn
group: vectorstore
kind: Chroma
path: github.com/kubeagi/arcadia/api/v1alpha1/vectorstore
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Application
path: github.com/kubeagi/arcadia/api/v1alpha1
version: v1alpha1
version: "3"
101 changes: 101 additions & 0 deletions api/v1alpha1/application_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,101 @@
/*
Copyright 2023 KubeAGI.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package v1alpha1

import (
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"
)

// ApplicationSpec defines the desired state of Application
type ApplicationSpec struct {
Nodes []Node `json:"nodes,omitempty"`
Connections []Connection `json:"connections,omitempty"`
}

type Node struct {
Name string `json:"name"`
// LLMRef is a reference to a llm.
// +optional
LLMRef *TypedObjectReference `json:"llmRef,omitempty"`

// LLMSpec is a specification of a llm.
// +optional
LLMSpec *LLMSpec `json:"llmSpec,omitempty"`

// LLMRef is a reference to a llm.
// +optional
EmbedderRef *TypedObjectReference `json:"embedderRef,omitempty"`

// EmbedderSpec is a specification of a Embedder.
// +optional
EmbedderSpec *EmbedderSpec `json:"EmbedderSpec,omitempty"`

// LLMRef is a reference to a llm.
// +optional
VectorStoreRef *TypedObjectReference `json:"vectorStoreRef,omitempty"`

// VectorStoreSpec is a specification of a VectorStore.
// +optional
VectorStoreSpec *VectorStoreSpec `json:"VectorStoreSpec,omitempty"`

// Chain is a reference to a chain.
// +optional
Chain Chain `json:"chain,omitempty"`
}

type Connection struct {
SourceNode string `json:"sourceNode"`
TargetNode string `json:"targetNode"`
}

type Chain struct {
LLMChain LLMChain `json:"llmChain,omitempty"`
}

type LLMChain struct {
}

// ApplicationStatus defines the observed state of Application
type ApplicationStatus struct {
// INSERT ADDITIONAL STATUS FIELD - define observed state of cluster
// Important: Run "make" to regenerate code after modifying this file
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Application is the Schema for the applications API
type Application struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ApplicationSpec `json:"spec,omitempty"`
Status ApplicationStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ApplicationList contains a list of Application
type ApplicationList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Application `json:"items"`
}

func init() {
SchemeBuilder.Register(&Application{}, &ApplicationList{})
}
11 changes: 11 additions & 0 deletions api/v1alpha1/common.go
Original file line number Diff line number Diff line change
Expand Up @@ -80,3 +80,14 @@ type Endpoint struct {
// Insecure if the endpoint needs a secure connection
Insecure bool `json:"insecure,omitempty"`
}

type CommonSpec struct {
// Creator defines datasource creator (AUTO-FILLED by webhook)
Creator string `json:"creator,omitempty"`

// DisplayName defines datasource display name
DiplayName string `json:"displayName,omitempty"`

// Description defines datasource description
Description string `json:"description,omitempty"`
}
8 changes: 2 additions & 6 deletions api/v1alpha1/datasource_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,15 +25,11 @@ import (

// DatasourceSpec defines the desired state of Datasource
type DatasourceSpec struct {
CommonSpec `json:",inline"`

// Creator defines datasource creator(AUTO-FILLED by webhook)
Creator string `json:"creator,omitempty"`

// DisplayName defines datasource display name
DiplayName string `json:"displayName"`

// Description defines datasource description
Description string `json:"description,omitempty"`

// Enpoint defines connection info
Enpoint *Endpoint `json:"endpoint,omitempty"`

Expand Down
7 changes: 1 addition & 6 deletions api/v1alpha1/embedder_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -27,12 +27,7 @@ import (

// EmbedderSpec defines the desired state of Embedder
type EmbedderSpec struct {
// INSERT ADDITIONAL SPEC FIELDS - desired state of cluster
// Important: Run "make" to regenerate code after modifying this file

// Name of the Embedding service
DisplayName string `json:"displayName,omitempty"`

CommonSpec `json:",inline"`
// ServiceType indicates the source type of embedding service
ServiceType embeddings.EmbeddingType `json:"serviceType,omitempty"`

Expand Down
2 changes: 1 addition & 1 deletion api/v1alpha1/llm_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,7 +24,7 @@ import (

// LLMSpec defines the desired state of LLM
type LLMSpec struct {
DisplayName string `json:"displayName,omitempty"`
CommonSpec `json:",inline"`
// Type defines the type of llm
Type llms.LLMType `json:"type"`

Expand Down
1 change: 1 addition & 0 deletions api/v1alpha1/prompt_types.go
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@ import (

// PromptSpec defines the desired state of Prompt
type PromptSpec struct {
CommonSpec `json:",inline"`
// LLM serivice name(CRD LLM)
LLM string `json:"llm"`
// ZhiPuAIParams defines the params of ZhiPuAI
Expand Down
77 changes: 77 additions & 0 deletions api/v1alpha1/vectorstore/chroma_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,77 @@
/*
Copyright 2023 KubeAGI.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

package vectorstore

import (
"github.com/kubeagi/arcadia/api/v1alpha1"

Check failure on line 20 in api/v1alpha1/vectorstore/chroma_types.go

View workflow job for this annotation

GitHub Actions / Lint Go code

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kubeagi/arcadia) -s blank -s dot --custom-order (gci)
appsv1 "k8s.io/api/apps/v1"
corev1 "k8s.io/api/core/v1"
metav1 "k8s.io/apimachinery/pkg/apis/meta/v1"

Check failure on line 23 in api/v1alpha1/vectorstore/chroma_types.go

View workflow job for this annotation

GitHub Actions / Lint Go code

File is not `gci`-ed with --skip-generated -s standard -s default -s prefix(github.com/kubeagi/arcadia) -s blank -s dot --custom-order (gci)
)

// ChromaSpec defines the desired state of Chroma
type ChromaSpec struct {
v1alpha1.CommonSpec `json:",inline"`
// Endpoint represents the endpoint used to communicate with the VectorStore.
ProxyEndpoint v1alpha1.Endpoint `json:"proxyEndpoint"`
// +optional
CollactionName string `json:"collactionName,omitempty"`
// +optional
StorePVC string `json:"storePVC,omitempty"`
// +optional
Image string `json:"image,omitempty"`
// +optional
Deploy *appsv1.DeploymentSpec `json:"deploy,omitempty"`
// +optional
Service *corev1.ServiceSpec `json:"service,omitempty"`
}

// ChromaStatus defines the observed state of Chroma
type ChromaStatus struct {
// ConditionedStatus is the current status
// +optional
v1alpha1.ConditionedStatus `json:",inline"`

// ObservedGeneration is the latest generation observed by the controller.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`
}

//+kubebuilder:object:root=true
//+kubebuilder:subresource:status

// Chroma is the Schema for the Chroma API
type Chroma struct {
metav1.TypeMeta `json:",inline"`
metav1.ObjectMeta `json:"metadata,omitempty"`

Spec ChromaSpec `json:"spec,omitempty"`
Status ChromaStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

// ChromaList contains a list of Chroma
type ChromaList struct {
metav1.TypeMeta `json:",inline"`
metav1.ListMeta `json:"metadata,omitempty"`
Items []Chroma `json:"items"`
}

func init() {
SchemeBuilder.Register(&Chroma{}, &ChromaList{})
}
36 changes: 36 additions & 0 deletions api/v1alpha1/vectorstore/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,36 @@
/*
Copyright 2023 KubeAGI.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
limitations under the License.
*/

// Package v1alpha1 contains API Schema definitions for the arcadia v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=arcadia.kubeagi.k8s.com.cn
package vectorstore

import (
"k8s.io/apimachinery/pkg/runtime/schema"
"sigs.k8s.io/controller-runtime/pkg/scheme"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: "vectorstore.arcadia.kubeagi.k8s.com.cn", Version: "v1alpha1"}

// SchemeBuilder is used to add go types to the GroupVersionKind scheme
SchemeBuilder = &scheme.Builder{GroupVersion: GroupVersion}

// AddToScheme adds the types in this group-version to the given scheme.
AddToScheme = SchemeBuilder.AddToScheme
)
Loading

0 comments on commit 3e405c7

Please sign in to comment.