Upgrade PromptKit and assemble native configuration sources
This commit is contained in:
@@ -33,7 +33,7 @@ License and notices: [LGPL 3.0](licenses/LGPL-3.0.txt) |
|
|||||||
|
|
||||||
## PromptKit
|
## PromptKit
|
||||||
|
|
||||||
Selected module: `gitea.maximumdirect.net/eric/promptkit` at `v0.11.2`.
|
Selected module: `gitea.maximumdirect.net/eric/promptkit` at `v0.12.0`.
|
||||||
|
|
||||||
Copyright (C) 2026 Eric Rakestraw
|
Copyright (C) 2026 Eric Rakestraw
|
||||||
|
|
||||||
@@ -41,38 +41,38 @@ SPDX-License-Identifier: LGPL-3.0-or-later
|
|||||||
|
|
||||||
License and notices: [LGPL 3.0](licenses/LGPL-3.0.txt) |
|
License and notices: [LGPL 3.0](licenses/LGPL-3.0.txt) |
|
||||||
[GPL 3.0](licenses/GPL-3.0.txt) |
|
[GPL 3.0](licenses/GPL-3.0.txt) |
|
||||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit/src/commit/12d6d80024e80c552d122a076c22429bf6f2f6c2/COPYRIGHT) |
|
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit/src/commit/4b8169da286917fde7875425bb32b799b12c6af3/COPYRIGHT) |
|
||||||
[LICENSE](https://gitea.maximumdirect.net/eric/promptkit/src/commit/12d6d80024e80c552d122a076c22429bf6f2f6c2/LICENSE).
|
[LICENSE](https://gitea.maximumdirect.net/eric/promptkit/src/commit/4b8169da286917fde7875425bb32b799b12c6af3/LICENSE).
|
||||||
|
|
||||||
[Source](https://gitea.maximumdirect.net/eric/promptkit/src/commit/12d6d80024e80c552d122a076c22429bf6f2f6c2).
|
[Source](https://gitea.maximumdirect.net/eric/promptkit/src/commit/4b8169da286917fde7875425bb32b799b12c6af3).
|
||||||
|
|
||||||
## PromptKit OpenRouter Catalog
|
## PromptKit OpenRouter Catalog
|
||||||
|
|
||||||
Selected module: `gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v2` at `v2.20260926.0`.
|
Selected module: `gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3` at `v3.20260930.0`.
|
||||||
|
|
||||||
Copyright (C) 2026 Eric Rakestraw
|
Copyright (C) 2026 Eric Rakestraw
|
||||||
|
|
||||||
SPDX-License-Identifier: MIT
|
SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
License and notices: [MIT](licenses/MIT.txt) |
|
License and notices: [MIT](licenses/MIT.txt) |
|
||||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/4f731d217e0bc39151c010f50fb5912706e7b6b3/COPYRIGHT) |
|
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/f17d208cb7ad1fb043cda2266cd3011d11b40aa0/COPYRIGHT) |
|
||||||
[LICENSE](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/4f731d217e0bc39151c010f50fb5912706e7b6b3/LICENSE).
|
[LICENSE](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/f17d208cb7ad1fb043cda2266cd3011d11b40aa0/LICENSE).
|
||||||
|
|
||||||
[Source](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/4f731d217e0bc39151c010f50fb5912706e7b6b3).
|
[Source](https://gitea.maximumdirect.net/eric/promptkit-backend-openrouter/src/commit/f17d208cb7ad1fb043cda2266cd3011d11b40aa0).
|
||||||
|
|
||||||
## PromptKit Rakestrawhome Catalog
|
## PromptKit Rakestrawhome Catalog
|
||||||
|
|
||||||
Selected module: `gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v2` at `v2.20260926.0`.
|
Selected module: `gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3` at `v3.20260930.0`.
|
||||||
|
|
||||||
Copyright (C) 2026 Eric Rakestraw
|
Copyright (C) 2026 Eric Rakestraw
|
||||||
|
|
||||||
SPDX-License-Identifier: MIT
|
SPDX-License-Identifier: MIT
|
||||||
|
|
||||||
License and notices: [MIT](licenses/MIT.txt) |
|
License and notices: [MIT](licenses/MIT.txt) |
|
||||||
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/48918a3ad39fd99843cda94a86133b1b3881d596/COPYRIGHT) |
|
[COPYRIGHT](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/993443d88c451901f4c917fa00c204fd3b54d28d/COPYRIGHT) |
|
||||||
[LICENSE](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/48918a3ad39fd99843cda94a86133b1b3881d596/LICENSE).
|
[LICENSE](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/993443d88c451901f4c917fa00c204fd3b54d28d/LICENSE).
|
||||||
|
|
||||||
[Source](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/48918a3ad39fd99843cda94a86133b1b3881d596).
|
[Source](https://gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/src/commit/993443d88c451901f4c917fa00c204fd3b54d28d).
|
||||||
|
|
||||||
## jsonschema
|
## jsonschema
|
||||||
|
|
||||||
|
|||||||
@@ -215,6 +215,10 @@ Prompt size: one mechanical conversion, no constructor work.
|
|||||||
|
|
||||||
## Stage 2 — Upgrade Dependencies And Assemble Native Source Groups
|
## Stage 2 — Upgrade Dependencies And Assemble Native Source Groups
|
||||||
|
|
||||||
|
> Completion: complete. The native compile pass confirms the expected follow-up
|
||||||
|
> work: migrate client and inspector constructors in Stage 3, then migrate LLM
|
||||||
|
> and CLI test fixtures in Stages 4–5; no compatibility wrappers were added.
|
||||||
|
|
||||||
Goal: establish v0.12 and shared native source construction.
|
Goal: establish v0.12 and shared native source construction.
|
||||||
|
|
||||||
Inspect `go.mod`, `go.sum`, `asset_registry.go`, `promptkit_profiles.go`,
|
Inspect `go.mod`, `go.sum`, `asset_registry.go`, `promptkit_profiles.go`,
|
||||||
|
|||||||
7
go.mod
7
go.mod
@@ -4,15 +4,14 @@ go 1.25.5
|
|||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.maximumdirect.net/eric/ConfigKit v0.5.0
|
gitea.maximumdirect.net/eric/ConfigKit v0.5.0
|
||||||
gitea.maximumdirect.net/eric/promptkit v0.11.2
|
gitea.maximumdirect.net/eric/promptkit v0.12.0
|
||||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2
|
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2
|
||||||
gopkg.in/yaml.v3 v3.0.1 // indirect
|
|
||||||
)
|
)
|
||||||
|
|
||||||
require golang.org/x/text v0.40.0
|
require golang.org/x/text v0.40.0
|
||||||
|
|
||||||
require (
|
require (
|
||||||
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v2 v2.20260926.0 // indirect
|
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3 v3.20260930.0 // indirect
|
||||||
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v2 v2.20260926.0 // indirect
|
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3 v3.20260930.0 // indirect
|
||||||
go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect
|
go.yaml.in/yaml/v4 v4.0.0-rc.6 // indirect
|
||||||
)
|
)
|
||||||
|
|||||||
14
go.sum
14
go.sum
@@ -1,11 +1,11 @@
|
|||||||
gitea.maximumdirect.net/eric/ConfigKit v0.5.0 h1:2KwG10+kApWM3avOoYA+p768xcbHUp7tQ2rqizBNpyg=
|
gitea.maximumdirect.net/eric/ConfigKit v0.5.0 h1:2KwG10+kApWM3avOoYA+p768xcbHUp7tQ2rqizBNpyg=
|
||||||
gitea.maximumdirect.net/eric/ConfigKit v0.5.0/go.mod h1:tYWpsrbLyu05r8+1MapWp5fN6ZrX9I8hU2xEPedYmYk=
|
gitea.maximumdirect.net/eric/ConfigKit v0.5.0/go.mod h1:tYWpsrbLyu05r8+1MapWp5fN6ZrX9I8hU2xEPedYmYk=
|
||||||
gitea.maximumdirect.net/eric/promptkit v0.11.2 h1:2RqI+KtflvSh7vLQaTAQCmMaFQscEA7EPwPazyvXRoY=
|
gitea.maximumdirect.net/eric/promptkit v0.12.0 h1:oIFWEg6GPxtmX3Plqv0euP+FnK1LCk/t4xDy6oKCpP4=
|
||||||
gitea.maximumdirect.net/eric/promptkit v0.11.2/go.mod h1:onm/FBPUKQ8/NSPwTEk26Ut+dVX2iXcq8vEseB+g/0E=
|
gitea.maximumdirect.net/eric/promptkit v0.12.0/go.mod h1:pFOOy5v1zH17stEi9rmHYmfbuLjnfVMcUhfmk+4VtJY=
|
||||||
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v2 v2.20260926.0 h1:wdab+R+lgMZxzYwhbAuCrW7zdSQ1cW9ovBR6UzLmZR4=
|
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3 v3.20260930.0 h1:lzfCDbzJQRGzIlRPRprnAV9hVVL5zUQy80VMQ0kbYa0=
|
||||||
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v2 v2.20260926.0/go.mod h1:a3VBbh9oaGXD6ruxhtwHj+AWW6DY/SSyby1QtMmYSUo=
|
gitea.maximumdirect.net/eric/promptkit-backend-openrouter/v3 v3.20260930.0/go.mod h1:HjS0f+3q0IdHCTEz+VVAEgIwIWJFAZUjuKdAtvtqKdg=
|
||||||
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v2 v2.20260926.0 h1:baCCIB6Ee5t0S4Zc++NTBIPcJEv5UPS6DlSrpZfykwg=
|
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3 v3.20260930.0 h1:h12ZTRldAmpLAomj0oQRGteFxHLN1LPE6XDl9zJNbm8=
|
||||||
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v2 v2.20260926.0/go.mod h1:mtgD1E0SGm0e/I8Ffhz+AYX7GN7RKUWJXehNFIKHs4Y=
|
gitea.maximumdirect.net/eric/promptkit-backend-rakestrawhome/v3 v3.20260930.0/go.mod h1:OEFBeKdjTsLzqJwLmXI2O5gG3r64FktcVJVb3mBrRfg=
|
||||||
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
github.com/dlclark/regexp2 v1.11.0 h1:G/nrcoOa7ZXlpoa/91N3X7mM3r8eIlMBBJZvsz/mxKI=
|
||||||
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
github.com/dlclark/regexp2 v1.11.0/go.mod h1:DHkYz0B9wPfa6wondMfaivmHpzrQ3v9q8cnmRbL6yW8=
|
||||||
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
|
github.com/santhosh-tekuri/jsonschema/v6 v6.0.2 h1:KRzFb2m7YtdldCEkzs6KqmJw4nqEVZGK7IN2kJkjTuQ=
|
||||||
@@ -14,7 +14,5 @@ go.yaml.in/yaml/v4 v4.0.0-rc.6 h1:1h7H1ohdUh93/FyE4YaDa1Zh64K6VVbjF4K6WUxMtH4=
|
|||||||
go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
go.yaml.in/yaml/v4 v4.0.0-rc.6/go.mod h1:aZqd9kCMsGL7AuUv/m/PvWLdg5sjJsZ4oHDEnfPPfY0=
|
||||||
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
golang.org/x/text v0.40.0 h1:Ub2Z6/xjgF1WrYQz2nuITOEegKFtiIy+rieRJ5lHZKs=
|
||||||
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
golang.org/x/text v0.40.0/go.mod h1:hpnzDAfGV753zIKo+wk3u1bVKCGPbrnF7+7LBF/UHVY=
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405 h1:yhCVgyC4o1eVCa2tZl7eS0r+SDo693bJlVdllGtEeKM=
|
|
||||||
gopkg.in/check.v1 v0.0.0-20161208181325-20d25e280405/go.mod h1:Co6ibVJAznAaIkqp8huTwlJQCZ016jof/cbN4VW5Yz0=
|
|
||||||
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
gopkg.in/yaml.v3 v3.0.1 h1:fxVm/GzAzEWqLHuvctI91KS9hhNmmWOoWu0XTYJS7CA=
|
||||||
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
gopkg.in/yaml.v3 v3.0.1/go.mod h1:K4uyk7z7BCEPqu6E+C64Yfv1cQ7kz7rIZviUmN+EgEM=
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import (
|
|||||||
"path"
|
"path"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
configkit "gitea.maximumdirect.net/eric/ConfigKit"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/readonlyfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/readonlyfs"
|
||||||
"gitea.maximumdirect.net/eric/promptkit"
|
"gitea.maximumdirect.net/eric/promptkit"
|
||||||
)
|
)
|
||||||
@@ -99,43 +100,43 @@ func (r *AssetRegistry) FallbackProfileDigest() (string, error) {
|
|||||||
return digest, err
|
return digest, err
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *AssetRegistry) PromptKitOptions() ([]promptkit.Option, error) {
|
// PromptKitConfigurationSources returns the registered prompt and fallback
|
||||||
options, _, err := r.promptKitOptions()
|
// profile assets as native PromptKit underlay groups. Schema assets remain a
|
||||||
return options, err
|
// separate PromptKit option because they are runtime validation resources.
|
||||||
}
|
func (r *AssetRegistry) PromptKitConfigurationSources() (promptkit.ConfigurationSources, []promptkit.Option, error) {
|
||||||
|
if r == nil {
|
||||||
func (r *AssetRegistry) promptKitOptions() ([]promptkit.Option, string, error) {
|
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("asset registry must not be nil")
|
||||||
promptFS, err := r.PromptFS()
|
|
||||||
if err != nil {
|
|
||||||
return nil, "", fmt.Errorf("prepare prompt assets: %w", err)
|
|
||||||
}
|
}
|
||||||
|
underlays, err := promptKitFilesystemUnderlays(r.prompts, "notarius-prompts")
|
||||||
|
if err != nil {
|
||||||
|
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare prompt configuration sources: %w", err)
|
||||||
|
}
|
||||||
|
profiles, err := promptKitFilesystemUnderlays(r.fallbackProfiles, "notarius-fallback-profiles")
|
||||||
|
if err != nil {
|
||||||
|
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare fallback profile configuration sources: %w", err)
|
||||||
|
}
|
||||||
|
underlays = append(underlays, profiles...)
|
||||||
schemaFS, err := r.SchemaFS()
|
schemaFS, err := r.SchemaFS()
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return nil, "", fmt.Errorf("prepare schema assets: %w", err)
|
return promptkit.ConfigurationSources{}, nil, fmt.Errorf("prepare schema assets: %w", err)
|
||||||
}
|
}
|
||||||
options := []promptkit.Option{
|
return promptkit.ConfigurationSources{Underlays: underlays}, []promptkit.Option{
|
||||||
promptkit.WithPromptFS(promptFS, "."),
|
|
||||||
promptkit.WithSchemaFS(schemaFS, "."),
|
promptkit.WithSchemaFS(schemaFS, "."),
|
||||||
}
|
}, nil
|
||||||
fallbackFS, fallbackDigest, hasFallback, err := r.fallbackProfileAssets()
|
|
||||||
if err != nil {
|
|
||||||
return nil, "", err
|
|
||||||
}
|
|
||||||
if hasFallback {
|
|
||||||
options = append(options, promptkit.WithFallbackProfileFS(fallbackFS, "."))
|
|
||||||
}
|
|
||||||
return options, fallbackDigest, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *AssetRegistry) promptKitFallbackProfileOption() (promptkit.Option, bool, error) {
|
func promptKitFilesystemUnderlays(sources []AssetSource, label string) ([]configkit.Underlay, error) {
|
||||||
fallbackFS, _, hasFallback, err := r.fallbackProfileAssets()
|
underlays := make([]configkit.Underlay, 0, len(sources))
|
||||||
if err != nil {
|
for index, source := range sources {
|
||||||
return nil, false, err
|
inputs, err := promptkit.FilesystemInputs(fmt.Sprintf("%s-%d", label, index), source.FS, source.Root)
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("select filesystem inputs: %w", err)
|
||||||
|
}
|
||||||
|
if len(inputs) != 0 {
|
||||||
|
underlays = append(underlays, configkit.Underlay{Inputs: inputs})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if !hasFallback {
|
return underlays, nil
|
||||||
return nil, false, nil
|
|
||||||
}
|
|
||||||
return promptkit.WithFallbackProfileFS(fallbackFS, "."), true, nil
|
|
||||||
}
|
}
|
||||||
|
|
||||||
func (r *AssetRegistry) fallbackProfileAssets() (fs.FS, string, bool, error) {
|
func (r *AssetRegistry) fallbackProfileAssets() (fs.FS, string, bool, error) {
|
||||||
|
|||||||
54
internal/framework/llm/asset_registry_sources_test.go
Normal file
54
internal/framework/llm/asset_registry_sources_test.go
Normal file
@@ -0,0 +1,54 @@
|
|||||||
|
package llm
|
||||||
|
|
||||||
|
import (
|
||||||
|
"testing"
|
||||||
|
"testing/fstest"
|
||||||
|
)
|
||||||
|
|
||||||
|
func TestPromptKitConfigurationSourcesKeepsNativeFilesystemGroups(t *testing.T) {
|
||||||
|
registry := NewAssetRegistry()
|
||||||
|
for index, name := range []string{"first", "second"} {
|
||||||
|
files := fstest.MapFS{
|
||||||
|
"prompts/prompt.yaml": {Data: []byte("prompts: {}\n")},
|
||||||
|
}
|
||||||
|
if err := registry.RegisterPromptFS(files, "."); err != nil {
|
||||||
|
t.Fatalf("register prompt source %d (%s): %v", index, name, err)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
fallbackProfiles := fstest.MapFS{
|
||||||
|
"profiles.yaml": {Data: []byte("profiles: {}\n")},
|
||||||
|
}
|
||||||
|
if err := registry.RegisterFallbackProfileFS(fallbackProfiles, "."); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
schemas := fstest.MapFS{"schema.json": {Data: []byte(`{"type":"object"}`)}}
|
||||||
|
if err := registry.RegisterSchemaFS(schemas, "."); err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
|
||||||
|
sources, options, err := registry.PromptKitConfigurationSources()
|
||||||
|
if err != nil {
|
||||||
|
t.Fatal(err)
|
||||||
|
}
|
||||||
|
if sources.Main != nil {
|
||||||
|
t.Fatalf("maintained sources unexpectedly set a main input: %+v", sources.Main)
|
||||||
|
}
|
||||||
|
if len(sources.Underlays) != 3 {
|
||||||
|
t.Fatalf("underlays = %d, want two prompt groups and one profile group", len(sources.Underlays))
|
||||||
|
}
|
||||||
|
for index, underlay := range sources.Underlays {
|
||||||
|
if len(underlay.Inputs) != 1 {
|
||||||
|
t.Fatalf("underlay %d has %d inputs, want 1", index, len(underlay.Inputs))
|
||||||
|
}
|
||||||
|
input := underlay.Inputs[0]
|
||||||
|
if input.Imports {
|
||||||
|
t.Fatalf("maintained input %d unexpectedly enables imports", index)
|
||||||
|
}
|
||||||
|
if input.Filesystem == nil || input.Filesystem.FS == nil {
|
||||||
|
t.Fatalf("maintained input %d has no native filesystem context", index)
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if len(options) != 1 {
|
||||||
|
t.Fatalf("runtime options = %d, want one schema option", len(options))
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -56,10 +56,6 @@ type LLMProfileRecorder struct {
|
|||||||
var _ contracts.StructuredLLMClient = (*PromptKitClient)(nil)
|
var _ contracts.StructuredLLMClient = (*PromptKitClient)(nil)
|
||||||
var _ contracts.LLMProfileManifestProvider = (*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) {
|
func NewPromptKitClient(cfg PromptKitClientConfig) (*PromptKitClient, error) {
|
||||||
if cfg.Assets == nil {
|
if cfg.Assets == nil {
|
||||||
return nil, fmt.Errorf("PromptKit client assets must not be nil")
|
return nil, fmt.Errorf("PromptKit client assets must not be nil")
|
||||||
|
|||||||
@@ -6,6 +6,7 @@ import (
|
|||||||
"fmt"
|
"fmt"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
configkit "gitea.maximumdirect.net/eric/ConfigKit"
|
||||||
"gitea.maximumdirect.net/eric/promptkit"
|
"gitea.maximumdirect.net/eric/promptkit"
|
||||||
)
|
)
|
||||||
|
|
||||||
@@ -121,13 +122,13 @@ func (i *PromptKitProfileInspector) InspectProfile(ctx context.Context, profileI
|
|||||||
}, nil
|
}, nil
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptKitProfileSourceEngineOptions(cfg PromptKitProfileSourceConfig) (PromptKitProfileSourceConfig, []promptkit.Option, error) {
|
func promptKitProfileConfigurationSources(cfg PromptKitProfileSourceConfig) (PromptKitProfileSourceConfig, promptkit.ConfigurationSources, error) {
|
||||||
source := PromptKitProfileSourceConfig{
|
source := PromptKitProfileSourceConfig{
|
||||||
ProfileDir: strings.TrimSpace(cfg.ProfileDir),
|
ProfileDir: strings.TrimSpace(cfg.ProfileDir),
|
||||||
ProfileFile: strings.TrimSpace(cfg.ProfileFile),
|
ProfileFile: strings.TrimSpace(cfg.ProfileFile),
|
||||||
}
|
}
|
||||||
if source.ProfileDir != "" && source.ProfileFile != "" {
|
if source.ProfileDir != "" && source.ProfileFile != "" {
|
||||||
return PromptKitProfileSourceConfig{}, nil, fmt.Errorf("PromptKit profile_dir and profile_file are mutually exclusive")
|
return PromptKitProfileSourceConfig{}, promptkit.ConfigurationSources{}, fmt.Errorf("PromptKit profile_dir and profile_file are mutually exclusive")
|
||||||
}
|
}
|
||||||
if cfg.LocalBackend != nil {
|
if cfg.LocalBackend != nil {
|
||||||
localBackend := *cfg.LocalBackend
|
localBackend := *cfg.LocalBackend
|
||||||
@@ -135,12 +136,31 @@ func promptKitProfileSourceEngineOptions(cfg PromptKitProfileSourceConfig) (Prom
|
|||||||
source.LocalBackend = &localBackend
|
source.LocalBackend = &localBackend
|
||||||
}
|
}
|
||||||
|
|
||||||
var options []promptkit.Option
|
var underlays []configkit.Underlay
|
||||||
if source.ProfileFile != "" {
|
if source.ProfileFile != "" {
|
||||||
options = append(options, promptkit.WithProfileFile(source.ProfileFile))
|
underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{{
|
||||||
|
Source: configkit.File(source.ProfileFile),
|
||||||
|
Imports: true,
|
||||||
|
}}})
|
||||||
|
} else if source.ProfileDir != "" {
|
||||||
|
inputs, err := promptkit.DirectoryInputs(source.ProfileDir)
|
||||||
|
if err != nil {
|
||||||
|
return PromptKitProfileSourceConfig{}, promptkit.ConfigurationSources{}, fmt.Errorf("select PromptKit profile directory: %w", err)
|
||||||
|
}
|
||||||
|
for index := range inputs {
|
||||||
|
inputs[index].Imports = true
|
||||||
|
}
|
||||||
|
if len(inputs) != 0 {
|
||||||
|
underlays = append(underlays, configkit.Underlay{Inputs: inputs})
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if source.LocalBackend != nil {
|
if source.LocalBackend != nil {
|
||||||
options = append(options, PromptKitLocalBackendOption(*source.LocalBackend))
|
backend := promptkit.LocalBackend(source.LocalBackend.Endpoint, source.LocalBackend.ConcurrencyLimit)
|
||||||
|
underlays = append(underlays, configkit.Underlay{Inputs: []configkit.Input{{
|
||||||
|
Source: promptkit.BackendSource("notarius-local-backend", map[string]promptkit.BackendConfig{
|
||||||
|
promptkit.BackendLocal: backend,
|
||||||
|
}),
|
||||||
|
}}})
|
||||||
}
|
}
|
||||||
return source, options, nil
|
return source, promptkit.ConfigurationSources{Underlays: underlays}, nil
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user