forked from kubeagi/arcadia
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request kubeagi#771 from nkwangleiGIT/main
Add documentloader CRD and add audio handler
- Loading branch information
Showing
22 changed files
with
945 additions
and
66 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
92 changes: 92 additions & 0 deletions
92
api/app-node/documentloader/v1alpha1/document_loader_types.go
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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 | ||
} | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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
140
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.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.