Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat: add CRD Application #197

Merged
merged 1 commit into from
Nov 29, 2023
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions Makefile
Original file line number Diff line number Diff line change
Expand Up @@ -268,6 +268,7 @@ gql-sdk-generator: run-graphql-server
config_rule_line_num = $(shell grep -n "rules:" config/rbac/role.yaml | cut -d: -f1)
chart_rule_line_num = $(shell grep -n "rules:" deploy/charts/arcadia/templates/rbac.yaml | cut -d: -f1)
prepare-push: manifests generate fmt vet
@go mod tidy
@echo "install golangci-lint"
@go install github.com/golangci/golangci-lint/cmd/golangci-lint@latest
@echo "run golangci-lint with auto-fix"
Expand Down
48 changes: 37 additions & 11 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@ layout:
plugins:
manifests.sdk.operatorframework.io/v2: {}
scorecard.sdk.operatorframework.io/v2: {}
multigroup: true
projectName: arcadia
repo: github.com/kubeagi/arcadia
resources:
Expand All @@ -14,7 +15,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Laboratory
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -23,7 +24,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: LLM
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -32,7 +33,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Prompt
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
webhooks:
validation: true
Expand All @@ -43,7 +44,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Datasource
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -52,7 +53,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Embedders
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -61,7 +62,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Dataset
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -70,7 +71,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: VersionedDataset
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -79,7 +80,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Worker
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -88,7 +89,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Model
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -97,7 +98,7 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: KnowledgeBase
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
Expand All @@ -106,6 +107,31 @@ resources:
domain: kubeagi.k8s.com.cn
group: arcadia
kind: VectorStore
path: github.com/kubeagi/arcadia/api/v1alpha1
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
namespaced: true
controller: true
domain: kubeagi.k8s.com.cn
group: arcadia
kind: Application
path: github.com/kubeagi/arcadia/api/base/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
domain: arcadia.kubeagi.k8s.com.cn
group: chain
kind: LLMChain
path: github.com/kubeagi/arcadia/api/app-node/chain/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
domain: arcadia.kubeagi.k8s.com.cn
group: prompt
kind: Prompt
path: github.com/kubeagi/arcadia/api/app-node/prompt/v1alpha1
version: v1alpha1
version: "3"
41 changes: 41 additions & 0 deletions api/app-node/chain/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
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=chain.arcadia.kubeagi.k8s.com.cn
package v1alpha1

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

const (
Group = "chain.arcadia.kubeagi.k8s.com.cn"
Version = "v1alpha1"
)

var (
// GroupVersion is group version used to register these objects
GroupVersion = schema.GroupVersion{Group: Group, Version: Version}

// 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
)
87 changes: 87 additions & 0 deletions api/app-node/chain/v1alpha1/llmchain_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,87 @@
/*
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"

node "github.com/kubeagi/arcadia/api/app-node"
"github.com/kubeagi/arcadia/api/base/v1alpha1"
)

// LLMChainSpec defines the desired state of LLMChain
type LLMChainSpec struct {
v1alpha1.CommonSpec `json:",inline"`

CommonChainConfig `json:",inline"`

Input Input `json:"input"`
Output Output `json:"output"`
}

type Input struct {
LLM node.LLMRef `json:"llm"`
Prompt node.PromptRef `json:"prompt"`
}
type Output struct {
node.CommonOrInPutOrOutputRef `json:",inline"`
}

type CommonChainConfig struct {
// 记忆相关参数
Memory Memory `json:"memory,omitempty"`
}

type Memory struct {
// 能记住的最大 token 数
MaxTokenLimit int `json:"maxTokenLimit,omitempty"`
}

// LLMChainStatus defines the observed state of LLMChain
type LLMChainStatus struct {
// ObservedGeneration is the last observed generation.
// +optional
ObservedGeneration int64 `json:"observedGeneration,omitempty"`

// ConditionedStatus is the current status
v1alpha1.ConditionedStatus `json:",inline"`
}

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

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

Spec LLMChainSpec `json:"spec,omitempty"`
Status LLMChainStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&LLMChain{}, &LLMChainList{})
}
Loading