diff --git a/internal/core/plugin_manager/aws_manager/packager.go b/internal/core/plugin_manager/aws_manager/packager.go index 61da340..49516ef 100644 --- a/internal/core/plugin_manager/aws_manager/packager.go +++ b/internal/core/plugin_manager/aws_manager/packager.go @@ -93,7 +93,7 @@ func (p *Packager) Pack() (*os.File, error) { full_filename := path.Join(dir, filename) - state, err := p.decoder.Stat(filename) + state, err := p.decoder.Stat(full_filename) if err != nil { return err } diff --git a/internal/core/plugin_manager/aws_manager/packager_test.go b/internal/core/plugin_manager/aws_manager/packager_test.go index db1c737..829507d 100644 --- a/internal/core/plugin_manager/aws_manager/packager_test.go +++ b/internal/core/plugin_manager/aws_manager/packager_test.go @@ -81,7 +81,13 @@ func TestPackager_Pack(t *testing.T) { return err } defer origin_file.Close() - if err := os.WriteFile(filepath.Join(tmpDir, path), []byte{}, 0644); err != nil { + + content, err := io.ReadAll(origin_file) + if err != nil { + return err + } + + if err := os.WriteFile(filepath.Join(tmpDir, path), content, 0644); err != nil { return err } } diff --git a/internal/core/plugin_manager/aws_manager/packager_test_plugin/manifest.yaml b/internal/core/plugin_manager/aws_manager/packager_test_plugin/manifest.yaml index e69de29..f6a1a81 100644 --- a/internal/core/plugin_manager/aws_manager/packager_test_plugin/manifest.yaml +++ b/internal/core/plugin_manager/aws_manager/packager_test_plugin/manifest.yaml @@ -0,0 +1,27 @@ +version: 0.0.1 +type: plugin +author: "Yeuoly" +name: "jina" +created_at: "2024-07-12T08:03:44.658609186Z" +resource: + memory: 1048576 + permission: + tool: + enabled: true + model: + enabled: true + llm: true +plugins: + - "provider/jina.yaml" +execution: + install: install.sh + launch: launch.sh +meta: + version: 0.0.1 + arch: + - "amd64" + - "arm64" + runner: + language: "python" + version: "3.12" + entrypoint: "main" diff --git a/internal/core/plugin_manager/aws_manager/packager_test_plugin/provider/jina.yaml b/internal/core/plugin_manager/aws_manager/packager_test_plugin/provider/jina.yaml new file mode 100644 index 0000000..d9d445d --- /dev/null +++ b/internal/core/plugin_manager/aws_manager/packager_test_plugin/provider/jina.yaml @@ -0,0 +1,79 @@ +type: model +provider: + provider: jina + label: + en_US: Jina + description: + en_US: Embedding and Rerank Model Supported + icon_small: + en_US: icon_s_en.svg + icon_large: + en_US: icon_l_en.svg + background: "#EFFDFD" + help: + title: + en_US: Get your API key from Jina AI + zh_Hans: 从 Jina 获取 API Key + url: + en_US: https://jina.ai/ + supported_model_types: + - text-embedding + - rerank + configurate_methods: + - predefined-model + - customizable-model + provider_credential_schema: + credential_form_schemas: + - variable: api_key + label: + en_US: API Key + type: secret-input + required: true + placeholder: + zh_Hans: 在此输入您的 API Key + en_US: Enter your API Key + model_credential_schema: + model: + label: + en_US: Model Name + zh_Hans: 模型名称 + placeholder: + en_US: Enter your model name + zh_Hans: 输入模型名称 + credential_form_schemas: + - variable: api_key + label: + en_US: API Key + type: secret-input + required: true + placeholder: + zh_Hans: 在此输入您的 API Key + en_US: Enter your API Key + - variable: base_url + label: + zh_Hans: 服务器 URL + en_US: Base URL + type: text-input + required: true + placeholder: + zh_Hans: Base URL, e.g. https://api.jina.ai/v1 + en_US: Base URL, e.g. https://api.jina.ai/v1 + default: 'https://api.jina.ai/v1' + - variable: context_size + label: + zh_Hans: 上下文大小 + en_US: Context size + placeholder: + zh_Hans: 输入上下文大小 + en_US: Enter context size + required: false + type: text-input + default: '8192' + models: + - "models/**/*.yaml" + extra: + python: + provider_source: provider/jina.py + model_sources: + - "models/text_embedding/text_embedding.py" + - "models/rerank/rerank.py" diff --git a/internal/core/plugin_packager/decoder/fs.go b/internal/core/plugin_packager/decoder/fs.go index f1e1d9f..9aeabbd 100644 --- a/internal/core/plugin_packager/decoder/fs.go +++ b/internal/core/plugin_packager/decoder/fs.go @@ -61,6 +61,10 @@ func (d *FSPluginDecoder) Open() error { func (d *FSPluginDecoder) Walk(fn func(filename string, dir string) error) error { return filepath.Walk(d.root, func(path string, info fs.FileInfo, err error) error { + if info.IsDir() { + return nil + } + // trim the first directory path path = strings.TrimPrefix(path, d.root) // trim / from the beginning diff --git a/internal/types/entities/plugin_entities/model_configuration.go b/internal/types/entities/plugin_entities/model_configuration.go index 6208f5a..dd01f4e 100644 --- a/internal/types/entities/plugin_entities/model_configuration.go +++ b/internal/types/entities/plugin_entities/model_configuration.go @@ -207,9 +207,10 @@ type ModelProviderConfiguration struct { Help *ModelProviderHelpEntity `json:"help" validate:"omitempty"` SupportedModelTypes []ModelType `json:"supported_model_types" validate:"required,lte=16,dive,model_type"` ConfigurateMethods []ModelProviderConfigurateMethod `json:"configurate_methods" validate:"required,lte=16,dive,model_provider_configurate_method"` - Models []ModelConfiguration `json:"models" validate:"omitempty,lte=1024,dive"` + Models []string `json:"models" validate:"required,lte=1024"` ProviderCredentialSchema *ModelProviderCredentialSchema `json:"provider_credential_schema" validate:"omitempty"` ModelCredentialSchema *ModelCredentialSchema `json:"model_credential_schema" validate:"omitempty"` + ModelDeclarations []ModelConfiguration `json:"model_declarations" validate:"required,lte=1024,dive"` } func init() {