47 lines
1.2 KiB
Go
47 lines
1.2 KiB
Go
package cli
|
|
|
|
import (
|
|
"context"
|
|
"fmt"
|
|
|
|
"gitea.maximumdirect.net/eric/notarius/internal/core/config"
|
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
|
)
|
|
|
|
func validateExplicitPromptKitProfiles(ctx context.Context, cfg config.Config, profileIDs []string, assets *llm.AssetRegistry) error {
|
|
if len(profileIDs) == 0 {
|
|
return nil
|
|
}
|
|
inspector, err := llm.NewPromptKitProfileInspector(llm.PromptKitProfileInspectorConfig{
|
|
Source: promptKitProfileSourceConfig(cfg),
|
|
Assets: assets,
|
|
})
|
|
if err != nil {
|
|
return fmt.Errorf("load PromptKit profiles: %w", err)
|
|
}
|
|
for _, profileID := range profileIDs {
|
|
if _, err := inspector.InspectProfile(ctx, profileID); err != nil {
|
|
return err
|
|
}
|
|
}
|
|
return nil
|
|
}
|
|
|
|
func promptKitProfileSourceConfig(cfg config.Config) llm.PromptKitProfileSourceConfig {
|
|
return llm.PromptKitProfileSourceConfig{
|
|
ProfileDir: cfg.PromptKit.ProfileDir,
|
|
ProfileFile: cfg.PromptKit.ProfileFile,
|
|
LocalBackend: mapPromptKitLocalBackend(cfg.PromptKit.LocalBackend),
|
|
}
|
|
}
|
|
|
|
func mapPromptKitLocalBackend(cfg *config.PromptKitLocalBackendConfig) *llm.PromptKitLocalBackendConfig {
|
|
if cfg == nil {
|
|
return nil
|
|
}
|
|
return &llm.PromptKitLocalBackendConfig{
|
|
Endpoint: cfg.Endpoint,
|
|
ConcurrencyLimit: cfg.ConcurrencyLimit,
|
|
}
|
|
}
|