Refactor AIGC ID Handling in Load Function
- Renamed the ID generation function to `aigcID` for clarity and added a new function to parse AIGC IDs from file paths. - Implemented special handling for `.ai.yml` and `.ai.yaml` extensions to correctly format the AIGC ID by removing the "_ai" suffix, improving ID accuracy in the loading process.
This commit is contained in:
parent
5830c3d177
commit
2a191950d7
1 changed files with 12 additions and 1 deletions
13
aigc/load.go
13
aigc/load.go
|
|
@ -28,7 +28,7 @@ func Load(cfg config.Config) error {
|
||||||
return nil
|
return nil
|
||||||
}
|
}
|
||||||
|
|
||||||
id := share.ID(root, file)
|
id := aigcID(root, file)
|
||||||
_, err := LoadFile(file, id)
|
_, err := LoadFile(file, id)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
messages = append(messages, err.Error())
|
messages = append(messages, err.Error())
|
||||||
|
|
@ -48,6 +48,17 @@ func Load(cfg config.Config) error {
|
||||||
return nil
|
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
|
// LoadFile load AIGC by file
|
||||||
func LoadFile(file string, id string) (*DSL, error) {
|
func LoadFile(file string, id string) (*DSL, error) {
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Reference in a new issue