Merge pull request #1383 from trheyi/main
Refactor AIGC ID Handling in Load Function
This commit is contained in:
commit
1e665423b1
3 changed files with 44 additions and 1 deletions
16
.github/workflows/pr-test.yml
vendored
16
.github/workflows/pr-test.yml
vendored
|
|
@ -40,6 +40,7 @@ env:
|
|||
|
||||
OPENAI_TEST_KEY: ${{ secrets.OPENAI_TEST_KEY }}
|
||||
TEST_MOAPI_SECRET: ${{ secrets.OPENAI_TEST_KEY }}
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_TEST_KEY }}
|
||||
TEST_MOAPI_MIRROR: https://api.openai.com
|
||||
|
||||
# DeepSeek API Configuration
|
||||
|
|
@ -314,11 +315,21 @@ jobs:
|
|||
with:
|
||||
ref: ${{ env.HEAD }}
|
||||
|
||||
- name: Setup Apple Private Key
|
||||
run: |
|
||||
mkdir -p ../app/openapi/certs/apple
|
||||
echo "${{ secrets.APPLE_PRIVATE_KEY_USER }}" > ../app/openapi/certs/apple/signin_client_secret_key.p8
|
||||
|
||||
- name: Setup Go ${{ matrix.go }}
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
||||
- name: Start Redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Setup Go Tools
|
||||
run: make tools
|
||||
|
||||
|
|
@ -468,6 +479,11 @@ jobs:
|
|||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
||||
- name: Start Redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Setup Go Tools
|
||||
run: make tools
|
||||
|
||||
|
|
|
|||
16
.github/workflows/unit-test.yml
vendored
16
.github/workflows/unit-test.yml
vendored
|
|
@ -44,6 +44,7 @@ env:
|
|||
|
||||
OPENAI_TEST_KEY: ${{ secrets.OPENAI_TEST_KEY }}
|
||||
TEST_MOAPI_SECRET: ${{ secrets.OPENAI_TEST_KEY }}
|
||||
OPENAI_API_KEY: ${{ secrets.OPENAI_TEST_KEY }}
|
||||
TEST_MOAPI_MIRROR: https://api.openai.com
|
||||
|
||||
# DeepSeek API Configuration
|
||||
|
|
@ -273,11 +274,21 @@ jobs:
|
|||
- name: Checkout Code
|
||||
uses: actions/checkout@v4
|
||||
|
||||
- name: Setup Apple Private Key
|
||||
run: |
|
||||
mkdir -p ../app/openapi/certs/apple
|
||||
echo "${{ secrets.APPLE_PRIVATE_KEY_USER }}" > ../app/openapi/certs/apple/signin_client_secret_key.p8
|
||||
|
||||
- name: Setup Go ${{ matrix.go }}
|
||||
uses: actions/setup-go@v5
|
||||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
||||
- name: Start Redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Setup Go Tools
|
||||
run: make tools
|
||||
|
||||
|
|
@ -379,6 +390,11 @@ jobs:
|
|||
with:
|
||||
go-version: ${{ matrix.go }}
|
||||
|
||||
- name: Start Redis
|
||||
uses: supercharge/redis-github-action@1.4.0
|
||||
with:
|
||||
redis-version: 6
|
||||
|
||||
- name: Setup Go Tools
|
||||
run: make tools
|
||||
|
||||
|
|
|
|||
13
aigc/load.go
13
aigc/load.go
|
|
@ -28,7 +28,7 @@ func Load(cfg config.Config) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
id := share.ID(root, file)
|
||||
id := aigcID(root, file)
|
||||
_, err := LoadFile(file, id)
|
||||
if err != nil {
|
||||
messages = append(messages, err.Error())
|
||||
|
|
@ -48,6 +48,17 @@ func Load(cfg config.Config) error {
|
|||
return nil
|
||||
}
|
||||
|
||||
// aigcID parses AIGC ID from file path
|
||||
// Special handling for .ai.yml and .ai.yaml extensions
|
||||
// e.g., "aigcs/translate.ai.yml" -> "translate"
|
||||
func aigcID(root, file string) string {
|
||||
id := share.ID(root, file)
|
||||
// Remove "_ai" suffix caused by .ai.yml/.ai.yaml extension
|
||||
// share.ID treats .yml/.yaml as single extension, so "translate.ai.yml" becomes "translate_ai"
|
||||
id = strings.TrimSuffix(id, "_ai")
|
||||
return id
|
||||
}
|
||||
|
||||
// LoadFile load AIGC by file
|
||||
func LoadFile(file string, id string) (*DSL, error) {
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue