Register configured local PromptKit backend

This commit is contained in:
2026-07-30 05:14:22 +00:00
parent d627b91b4f
commit 715fff7b72
6 changed files with 255 additions and 0 deletions

View File

@@ -19,9 +19,15 @@ import (
const promptKitProviderName = "promptkit"
type PromptKitLocalBackendConfig struct {
Endpoint string
ConcurrencyLimit int
}
type PromptKitClientConfig struct {
ProfileDir string
ProfileFile string
LocalBackend *PromptKitLocalBackendConfig
Assets *AssetRegistry
Timeout time.Duration
HTTPClient *http.Client
@@ -46,6 +52,10 @@ type LLMProfileRecorder struct {
var _ contracts.StructuredLLMClient = (*PromptKitClient)(nil)
var _ contracts.LLMProfileManifestProvider = (*PromptKitClient)(nil)
func PromptKitLocalBackendOption(cfg PromptKitLocalBackendConfig) promptkit.Option {
return promptkit.WithBackend(promptkit.LocalBackend(cfg.Endpoint, cfg.ConcurrencyLimit))
}
func NewPromptKitClient(cfg PromptKitClientConfig) (*PromptKitClient, error) {
if cfg.Assets == nil {
return nil, fmt.Errorf("PromptKit client assets must not be nil")
@@ -60,6 +70,11 @@ func NewPromptKitClient(cfg PromptKitClientConfig) (*PromptKitClient, error) {
if profileFile := strings.TrimSpace(cfg.ProfileFile); profileFile != "" {
options = append(options, promptkit.WithProfileFile(profileFile))
}
if cfg.LocalBackend != nil {
localBackend := *cfg.LocalBackend
localBackend.Endpoint = strings.TrimSpace(localBackend.Endpoint)
options = append(options, PromptKitLocalBackendOption(localBackend))
}
options = append(options, cfg.EngineOptions...)
engine, err := promptkit.NewEngine(promptkit.Config{