Skip to content

Commit

Permalink
fix: aws packager
Browse files Browse the repository at this point in the history
  • Loading branch information
Yeuoly committed Sep 2, 2024
1 parent fefd2c1 commit 431d57e
Show file tree
Hide file tree
Showing 6 changed files with 120 additions and 3 deletions.
2 changes: 1 addition & 1 deletion internal/core/plugin_manager/aws_manager/packager.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
Expand Down
8 changes: 7 additions & 1 deletion internal/core/plugin_manager/aws_manager/packager_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
}
}
Expand Down
Original file line number Diff line number Diff line change
@@ -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"
Original file line number Diff line number Diff line change
@@ -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"
4 changes: 4 additions & 0 deletions internal/core/plugin_packager/decoder/fs.go
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -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() {
Expand Down

0 comments on commit 431d57e

Please sign in to comment.