common

package
v0.2.2 Latest Latest
Warning

This package is not in the latest version of its module.

Go to latest
Published: Apr 12, 2024 License: Apache-2.0 Imports: 23 Imported by: 0

Documentation

Overview

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.

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.

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.

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.

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.

Index

Constants

View Source
const (
	// The creation time of the file in minio,
	// in this case the generation time of the uplaodid when it was sliced.
	CreationTimestamp = "creationTimestamp"

	// This field refers to the file type
	// In the data returned by minio, there is usually content-type in userMetadata,
	// but this is made explicit by the content-type when the file is uploaded,
	// and if there are other types, we should need to determine them by userTags.
	FileContentType = "content-type"

	FileNotUploaded int = iota
	FileUploaded

	// maxPartsCount - maximum number of parts for a single multipart session.
	MaxPartsCount = 10000

	// maxMultipartPutObjectSize - maximum size 5TiB of object for
	// Multipart operation.
	MaxMultipartPutObjectSize = 1024 * 1024 * 1024 * 1024 * 5

	// minPartSize - minimum part size 128MiB per object after which
	// putObject behaves internally as multipart.
	MinPartSize = 1024 * 1024 * 64
)

Variables

View Source
var (
	DefaultNamespace  = "default"
	ErrNoResourceKind = errors.New("must provide resource kind")

	// Common status
	StatusTrue  = "True"
	StatusFalse = "False"
)
View Source
var (
	ModelTypeAll       = "llm,embedding"
	ModelTypeLLM       = "llm"
	ModelTypeEmbedding = "embedding"
)

ModelType

View Source
var (
	ModelSourceLocal       = "local"
	ModelSourceModelscope  = "modelscope"
	ModelSourceHuggingface = "huggingface"
)

ModelSource

View Source
var (
	DefaultPageNodeConvertFunc = func(node any) generated.PageNode {
		pageNode, ok := node.(generated.PageNode)
		if !ok {
			return nil
		}
		return pageNode
	}
)
View Source
var (
	// UnlimitedPageSize which means all
	UnlimitedPageSize = -1
)

Functions

func AppIconLink(app *v1alpha1.Application, endpointPrefix string) string

func DeleteAllOptions added in v0.2.0

func DeleteAllOptions(input *generated.DeleteCommonInput) ([]client.DeleteAllOfOption, error)

func EditCSV added in v0.2.1

func EditCSV(r io.Reader, updateLines []CSVLine, addLines [][]string, delLines []int) (io.Reader, int64, error)

func GenerateAuthSecretName added in v0.2.0

func GenerateAuthSecretName(base string, ownerKind string) string

GenerateAuthSecretName returns a secret name based on its base name and owner's kind

func GetAPIServer

func GetAPIServer(ctx context.Context, cli client.Client, external bool) (string, error)

GetAPIServer returns the api server url to access arcadia's worker if external is true,then this func will return the external api server

func GetAppCategory added in v0.2.0

func GetAppCategory(app *v1alpha1.Application) []*string

func GetGPTStoreConfig added in v0.2.2

func GetGPTStoreConfig(ctx context.Context, cli client.Client) (*config.GPTsConfig, error)

GetGPTsURL returns the gpts url to access arcadia's gpt store

func GetObjStatus

func GetObjStatus(obj client.Object) string

GetObjStatus is used to calculate the state of the resource, unified management, in general, a resource will only record its own state, then the state calculation of this resource, should be written to this function. But for some special resources. For example, VersionedDataset, he needs to calculate multiple states, it is not suitable for this function.

func ListReources added in v0.2.0

func ListReources(items []client.Object, page, pageSize int, converter ResourceConverter, options ...ResourceFilter) (*generated.PaginatedResult, error)

ListReources filtering resources based on conditions will modify the original array, so if you want to preserve the original data, make a backup before calling the function

func MakeAuthSecret

func MakeAuthSecret(ctx context.Context, c client.Client, secretNamespace, secretName string, input map[string]interface{}, owner client.Object) error

MakeAuthSecret will create or update a secret based on auth input When owner is not nil, owner reference will be set

func MakeEndpoint

func MakeEndpoint(ctx context.Context, c client.Client, owner client.Object, input generated.EndpointInput) (v1alpha1.Endpoint, error)

MakeEndpoint provides a common way to handle endpoint input owner means the resource who owns this endpoint

func NewListOptions added in v0.2.0

func NewListOptions(input generated.ListCommonInput) ([]client.ListOption, error)

func PagePosition added in v0.2.0

func PagePosition(page, size, total int) (int, int)

func SetCreator

func SetCreator(ctx context.Context, common *v1alpha1.CommonSpec)

func TypedObjectReferenceToInput added in v0.2.0

func TypedObjectReferenceToInput(ref generated.TypedObjectReference) generated.TypedObjectReferenceInput

Types

type CSVLine added in v0.2.1

type CSVLine struct {
	LinNumber uint64   `json:"lineNumber,omitempty"`
	Values    []string `json:"values,omitempty"`
}

type ListOptions

type ListOptions struct {
	ConvertFunc PageNodeConvertFunc
}

ListOptions for graphql list

func DefaultListOptions

func DefaultListOptions() *ListOptions

DefaultListOptions initialize a ListOptions with default settings

type ListOptionsFunc

type ListOptionsFunc func(options *ListOptions)

func WithPageNodeConvertFunc

func WithPageNodeConvertFunc(convertFunc PageNodeConvertFunc) ListOptionsFunc

WithPageNodeConvertFunc update the PageNodeConvertFunc

type PageNodeConvertFunc

type PageNodeConvertFunc func(any) generated.PageNode

PageNodeConvertFunc convert `any` to a `PageNode`

type PageNodeSorter added in v0.2.0

type PageNodeSorter []client.Object

func (*PageNodeSorter) Len added in v0.2.0

func (p *PageNodeSorter) Len() int

func (*PageNodeSorter) Less added in v0.2.0

func (p *PageNodeSorter) Less(i, j int) bool

func (*PageNodeSorter) Pop added in v0.2.0

func (p *PageNodeSorter) Pop() any

func (*PageNodeSorter) Push added in v0.2.0

func (p *PageNodeSorter) Push(x any)

func (*PageNodeSorter) Swap added in v0.2.0

func (p *PageNodeSorter) Swap(i, j int)

type ReadCSVResult

type ReadCSVResult struct {
	Rows    [][]string `json:"rows"`
	Total   int64      `json:"total"`
	Version string     `json:"version"`
}

func ReadCSV

func ReadCSV(o io.Reader, startLine, lines, cachedTotalLines int64) (ReadCSVResult, error)

ReadCSV Reads the contents of a csv file by lines according to startLine and lines, if cacheLines=0 then the total number of lines in the file will be counted, otherwise the total number of lines in the file will not be counted and the speedup function returns.

type ResourceConverter added in v0.2.0

type ResourceConverter func(client.Object) (generated.PageNode, error)

type ResourceFilter added in v0.2.0

type ResourceFilter func(client.Object) bool

func FilterApplicationByCategory added in v0.2.0

func FilterApplicationByCategory(category string) ResourceFilter

func FilterApplicationByKeyword added in v0.2.0

func FilterApplicationByKeyword(keyword string) ResourceFilter

Application

func FilterByNameContains added in v0.2.0

func FilterByNameContains(name string) ResourceFilter

func FilterByRAGKeyword added in v0.2.0

func FilterByRAGKeyword(keyword string) ResourceFilter

func FilterDatasetByDisplayName added in v0.2.0

func FilterDatasetByDisplayName(displayName string) ResourceFilter

Dataset Filter

func FilterDatasetByKeyword added in v0.2.0

func FilterDatasetByKeyword(keyword string) ResourceFilter

func FilterDatasourceByKeyword added in v0.2.0

func FilterDatasourceByKeyword(keyword string) ResourceFilter

Datasource

func FilterEmbedderByKeyword added in v0.2.0

func FilterEmbedderByKeyword(keyword string) ResourceFilter

Embedder

func FilterKnowledgeByDisplayName added in v0.2.0

func FilterKnowledgeByDisplayName(displayName string) ResourceFilter

KnowledgeBase

func FilterLLMByKeyword added in v0.2.0

func FilterLLMByKeyword(keyword string) ResourceFilter

LLM

func FilterModelByKeyword added in v0.2.0

func FilterModelByKeyword(keyword string) ResourceFilter

Model

func FilterRAGByStatus added in v0.2.0

func FilterRAGByStatus(status string) ResourceFilter

func FilterVersionedDatasetByDisplayName added in v0.2.0

func FilterVersionedDatasetByDisplayName(displayName string) ResourceFilter

VersionedData

func FilterVersionedDatasetByKeyword added in v0.2.0

func FilterVersionedDatasetByKeyword(keyword string) ResourceFilter

func FilterWorkerByKeyword added in v0.2.0

func FilterWorkerByKeyword(keyword string) ResourceFilter

Worekr

func FilterWorkerByType added in v0.2.0

func FilterWorkerByType(c client.Client, namespace, modelType string) ResourceFilter

type UpdateCSVBody added in v0.2.1

type UpdateCSVBody struct {
	// BucketName string `json:"bucketName"`, from header
	BucketPath string `json:"bucketPath"`
	FileName   string `json:"fileName"`
	Version    string `json:"version"`

	// The version to be edited is inconsistent with the latest version.
	// Do you want to force an update?
	ForceUpdate bool `json:"forceUpdate"`

	UpdateLines []CSVLine  `json:"updateLines"`
	NewLines    [][]string `json:"newLines,omitempty"`
	DelLines    []int      `json:"delLines"`
}

Jump to

Keyboard shortcuts

? : This menu
/ : Search site
f or F : Jump to
y or Y : Canonical URL