Skip to content

Commit

Permalink
Merge pull request kubeagi#771 from nkwangleiGIT/main
Browse files Browse the repository at this point in the history
Add documentloader CRD and add audio handler
  • Loading branch information
nkwangleiGIT authored Feb 28, 2024
2 parents 352145b + 6c97719 commit 327c540
Show file tree
Hide file tree
Showing 22 changed files with 945 additions and 66 deletions.
2 changes: 1 addition & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -52,7 +52,7 @@ List of supported(tested) LLMs
* chatglm2-6b
* qwen-7b-chat / qwen-14b-chat / qwen-72b-chat
* llama2-7b
* mistral-7b
* Mistral-7B-Instruct-v0.1
* bge-large-zh ***embedding***
* m3e ***embedding***
* [ZhiPuAI(智谱 AI)](https://github.com/kubeagi/arcadia/tree/main/pkg/llms/zhipuai)
Expand Down
92 changes: 92 additions & 0 deletions api/app-node/documentloader/v1alpha1/document_loader_types.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,92 @@
/*
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"
)

// DocumentLoaderSpec defines the desired state of DocumentLoader
type DocumentLoaderSpec struct {
// CommonSpec
v1alpha1.CommonSpec `json:",inline"`
// ChunkSize for text splitter
// +kubebuilder:default=2048
ChunkSize int `json:"chunkSize,omitempty"`
// ChunkOverlap for text splitter
// +kubebuilder:default=200
ChunkOverlap int `json:"chunkOverlap,omitempty"`
// FileExtName the type of documents, can be .pdf, .txt, .mp3, etc ...
FileExtName string `json:"fileExtName,omitempty"`
// LoaderConfig defines the config of loader tools
LoaderConfig `json:",inline"`
}

// LoaderConfig defines the config of the loader
type LoaderConfig struct {
Params map[string]string `json:"params,omitempty"`
}

// LoaderStatus defines the observed state of loader
type LoaderStatus 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

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

Spec DocumentLoaderSpec `json:"spec,omitempty"`
Status LoaderStatus `json:"status,omitempty"`
}

//+kubebuilder:object:root=true

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

func init() {
SchemeBuilder.Register(&DocumentLoader{}, &DocumentLoaderList{})
}

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

func (c *DocumentLoader) SetRef() {
annotations := node.SetRefAnnotations(c.GetAnnotations(), []node.Ref{node.InputRef.Len(1)}, []node.Ref{node.CommonRef.Len(1)})
if c.GetAnnotations() == nil {
c.SetAnnotations(annotations)
}
for k, v := range annotations {
c.Annotations[k] = v
}
}
41 changes: 41 additions & 0 deletions api/app-node/documentloader/v1alpha1/groupversion_info.go
Original file line number Diff line number Diff line change
@@ -0,0 +1,41 @@
/*
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 contains API Schema definitions for the arcadia v1alpha1 API group
// +kubebuilder:object:generate=true
// +groupName=arcadia.kubeagi.k8s.com.cn
package v1alpha1

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

const (
Group = "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
)
140 changes: 140 additions & 0 deletions api/app-node/documentloader/v1alpha1/zz_generated.deepcopy.go

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

32 changes: 11 additions & 21 deletions apiserver/docs/docs.go
Original file line number Diff line number Diff line change
Expand Up @@ -1157,13 +1157,6 @@ const docTemplate = `{
"in": "header",
"required": true
},
{
"type": "string",
"description": "application name",
"name": "appName",
"in": "query",
"required": true
},
{
"type": "integer",
"description": "default is 1",
Expand Down Expand Up @@ -1244,13 +1237,6 @@ const docTemplate = `{
"name": "namespace",
"in": "header",
"required": true
},
{
"type": "string",
"description": "application name",
"name": "appName",
"in": "query",
"required": true
}
],
"responses": {
Expand Down Expand Up @@ -1308,13 +1294,6 @@ const docTemplate = `{
"name": "namespace",
"in": "header",
"required": true
},
{
"type": "string",
"description": "application name",
"name": "appName",
"in": "query",
"required": true
}
],
"responses": {
Expand Down Expand Up @@ -1390,6 +1369,17 @@ const docTemplate = `{
"type": "string",
"example": "5a41f3ca-763b-41ec-91c3-4bbbb00736d0"
},
"files": {
"description": "Files this conversation will use in the context",
"type": "array",
"items": {
"type": "string"
},
"example": [
"test.pdf",
"song.mp3"
]
},
"query": {
"description": "Query user query string",
"type": "string",
Expand Down
Loading

0 comments on commit 327c540

Please sign in to comment.