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 multi knowledgebase #981

Merged
merged 1 commit into from
May 8, 2024
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
16 changes: 16 additions & 0 deletions PROJECT
Original file line number Diff line number Diff line change
Expand Up @@ -151,6 +151,22 @@ resources:
kind: RerankRetriever
path: github.com/kubeagi/arcadia/api/app-node/retriever/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
domain: arcadia.kubeagi.k8s.com.cn
group: retriever
kind: MergerRetriever
path: github.com/kubeagi/arcadia/api/app-node/retriever/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
domain: arcadia.kubeagi.k8s.com.cn
group: retriever
kind: MultiQueryRetriever
path: github.com/kubeagi/arcadia/api/app-node/retriever/v1alpha1
version: v1alpha1
- api:
crdVersion: v1
controller: true
Expand Down
7 changes: 7 additions & 0 deletions api/app-node/common_type.go
Original file line number Diff line number Diff line change
Expand Up @@ -25,8 +25,15 @@ import (
const (
InputLengthAnnotationKey = v1alpha1.Group + `/input-rules`
OutputLengthAnnotationKey = v1alpha1.Group + `/output-rules`

// ConversationKnowledgebaseName is the placeholder name of the conversation knowledgebase
ConversationKnowledgebaseName = "conversation-knowledgebase-placeholder"
)

func IsPlaceholderConversationKnowledgebase(name string) bool {
return name == ConversationKnowledgebaseName
}

type Ref struct {
Kind string `json:"kind,omitempty"`
Group string `json:"group,omitempty"`
Expand Down
76 changes: 76 additions & 0 deletions api/app-node/retriever/v1alpha1/mergerretriever_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,76 @@
/*
Copyright 2024 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"
)

// MergerRetrieverSpec defines the desired state of MergerRetriever
type MergerRetrieverSpec struct {
v1alpha1.CommonSpec `json:",inline"`
}

// MergerRetrieverStatus defines the observed state of MergerRetriever
type MergerRetrieverStatus 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

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

Spec MergerRetrieverSpec `json:"spec,omitempty"`
Status MergerRetrieverStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&MergerRetriever{}, &MergerRetrieverList{})
}

var _ node.Node = (*MergerRetriever)(nil)

func (c *MergerRetriever) SetRef() {
annotations := node.SetRefAnnotations(c.GetAnnotations(), []node.Ref{node.RetrieverRef.Len(1)}, []node.Ref{node.RetrievalQAChainRef.Len(1)})
if c.GetAnnotations() == nil {
c.SetAnnotations(annotations)
}
for k, v := range annotations {
c.Annotations[k] = v
}
}
91 changes: 91 additions & 0 deletions api/app-node/retriever/v1alpha1/zz_generated.deepcopy.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

80 changes: 77 additions & 3 deletions apiserver/graph/generated/generated.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 4 additions & 0 deletions apiserver/graph/generated/models_gen.go

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

Loading
Loading