Compare commits
9 Commits
f4c05c34ef
...
406ad1d362
| Author | SHA1 | Date | |
|---|---|---|---|
| 406ad1d362 | |||
| 5f207b2ab1 | |||
| c613b306ae | |||
| 1c7291e17d | |||
| 2345da106a | |||
| 03761c97dd | |||
| 9cb9ee48a7 | |||
| 08954f17e2 | |||
| a57f83e30d |
15
assets/package.go
Normal file
15
assets/package.go
Normal file
@@ -0,0 +1,15 @@
|
|||||||
|
// Package assets exposes embedded LLM-facing content.
|
||||||
|
package assets
|
||||||
|
|
||||||
|
import (
|
||||||
|
"embed"
|
||||||
|
"io/fs"
|
||||||
|
)
|
||||||
|
|
||||||
|
//go:embed dnd generic
|
||||||
|
var embedded embed.FS
|
||||||
|
|
||||||
|
// FS returns the embedded read-only asset filesystem.
|
||||||
|
func FS() fs.FS {
|
||||||
|
return embedded
|
||||||
|
}
|
||||||
@@ -1,6 +1,6 @@
|
|||||||
# ADR-0004: Package modules by domain, not by stage
|
# ADR-0004: Package modules by domain, not by stage
|
||||||
|
|
||||||
**Status:** Accepted
|
**Status:** Accepted — its asset-co-location rule is superseded by [ADR-0011](0011-centralize-llm-assets.md); its domain-first module packaging decision remains accepted.
|
||||||
**Date:** 2026-07-13
|
**Date:** 2026-07-13
|
||||||
|
|
||||||
## Context
|
## Context
|
||||||
|
|||||||
69
docs/adr/0011-centralize-llm-assets.md
Normal file
69
docs/adr/0011-centralize-llm-assets.md
Normal file
@@ -0,0 +1,69 @@
|
|||||||
|
# ADR-0011: Centralize LLM-facing assets in a content-only package
|
||||||
|
|
||||||
|
**Status:** Accepted
|
||||||
|
**Date:** 2026-08-05
|
||||||
|
|
||||||
|
## Context
|
||||||
|
|
||||||
|
LLM prompts, private response schemas, generic schemas, and fallback profiles
|
||||||
|
are authored and reviewed as content, but package-local embedding scattered that
|
||||||
|
content across implementation trees. Finding all of the assets that contribute
|
||||||
|
to a prompt family required navigating code ownership boundaries rather than a
|
||||||
|
single discoverable content boundary.
|
||||||
|
|
||||||
|
The repository must retain module ownership of prompt semantics, schema
|
||||||
|
identities, registration, and prompt-cache behavior. Durable artifact schemas
|
||||||
|
and non-LLM domain data have different compatibility and ownership rules, so
|
||||||
|
they must not move merely because they are embedded files.
|
||||||
|
|
||||||
|
## Decision
|
||||||
|
|
||||||
|
LLM-facing content is embedded by the root `assets` package. It is a data-only
|
||||||
|
dependency leaf: its single `FS() fs.FS` API returns the read-only embedded
|
||||||
|
filesystem, and the package contains no business logic or internal or PromptKit
|
||||||
|
dependencies. The accepted import path is
|
||||||
|
`gitea.maximumdirect.net/eric/notarius/assets`; it makes repository-owned
|
||||||
|
content available to its consumers, not a public extension contract.
|
||||||
|
|
||||||
|
Consumers scope that filesystem to the subtree they own before reading or
|
||||||
|
registering content. Modules continue to own their manifests, prompt ordering,
|
||||||
|
private response-schema identity, and registration. Centralizing physical files
|
||||||
|
does not centralize domain semantics or transfer those responsibilities to the
|
||||||
|
root package.
|
||||||
|
|
||||||
|
The root package contains prompt content, private LLM response schemas, generic
|
||||||
|
LLM schemas, shared fragments, and fallback profiles. Durable artifact schemas
|
||||||
|
and non-LLM domain data remain with their current owners. A module fingerprint
|
||||||
|
is derived from its manifest-selected module and shared files, rather than from
|
||||||
|
an entire asset tree. The relocation is accepted to cause a one-time checkpoint
|
||||||
|
invalidation.
|
||||||
|
|
||||||
|
This decision supersedes only the physical asset-co-location portion of
|
||||||
|
ADR-0004's decision that places domain-specific prompt fragments and schemas
|
||||||
|
within the domain tree. ADR-0004's domain-first packaging and registrar
|
||||||
|
ownership decisions remain accepted.
|
||||||
|
|
||||||
|
## Alternatives Considered
|
||||||
|
|
||||||
|
- Keep package-local assets. This preserves physical co-location with code but
|
||||||
|
makes prompt-author discovery and cross-family review unnecessarily costly.
|
||||||
|
- Use `internal/llmassets`. This would hide content from legitimate owners
|
||||||
|
outside the `internal` subtree and would make the root asset boundary depend
|
||||||
|
on implementation-layer placement.
|
||||||
|
- Build a behavioral central registry. This would mix content discovery with
|
||||||
|
prompt selection and registration behavior, moving module semantics into a
|
||||||
|
shared registry.
|
||||||
|
- Use runtime filesystem overlays. This would add runtime configuration and
|
||||||
|
failure modes where compile-time embedded content is sufficient.
|
||||||
|
|
||||||
|
## Consequences
|
||||||
|
|
||||||
|
Prompt authors can find in-scope LLM content in one top-level tree while module
|
||||||
|
packages continue to define its meaning and registration. Consumers have an
|
||||||
|
explicit, narrow dependency on only the content they need. The root package is
|
||||||
|
intentionally importable but must remain a stable, content-only leaf rather
|
||||||
|
than becoming a general extension API.
|
||||||
|
|
||||||
|
The initial relocation invalidates existing checkpoints once. Later checkpoint
|
||||||
|
identity changes remain limited to the manifest-selected prompt and shared
|
||||||
|
content, so unrelated files do not trigger recomputation.
|
||||||
@@ -43,14 +43,21 @@ the contracts above define durable data.
|
|||||||
|
|
||||||
## Prompt Construction
|
## Prompt Construction
|
||||||
|
|
||||||
|
D&D LLM-facing content lives beneath `assets/dnd/`. New extractor content uses
|
||||||
|
its feature subtree; when a family has both extraction and normalization
|
||||||
|
content, keep those in its `extract` and `normalize` subtrees. The owning module
|
||||||
|
still defines the ordered manifest and registers the resulting scoped filesystem.
|
||||||
|
Shared fragments belong to the D&D shared implementation and are selected by
|
||||||
|
name, never copied into individual module subtrees.
|
||||||
|
|
||||||
D&D extractors assemble prompts from an ordered manifest of shared and
|
D&D extractors assemble prompts from an ordered manifest of shared and
|
||||||
module-owned assets. The location extractor and occurrence extractor reuse the
|
module-selected assets. The location extractor and occurrence extractor reuse
|
||||||
shared D&D system, evidence, identity, reference, and transcript assets instead
|
the shared D&D system, evidence, identity, reference, and transcript assets
|
||||||
of copying their text into individual modules. A manifest’s declared sequence,
|
instead of copying their text into individual modules. A manifest’s declared
|
||||||
including cache-control placement, is part of the prompt behavior.
|
sequence, including cache-control placement, is part of the prompt behavior.
|
||||||
|
|
||||||
Every maintained D&D LLM prompt selects `dnd-extraction` as its default
|
Every maintained D&D LLM prompt selects `dnd-extraction` as its default
|
||||||
profile. The D&D registrar embeds that fallback profile with the maintained
|
profile. The D&D registrar registers that fallback profile with the maintained
|
||||||
OpenRouter model, timeout, and service-tier policy. An operator may provide a
|
OpenRouter model, timeout, and service-tier policy. An operator may provide a
|
||||||
complete profile with the same ID through the configured PromptKit source; that
|
complete profile with the same ID through the configured PromptKit source; that
|
||||||
definition replaces the fallback rather than merging with it. The fallback
|
definition replaces the fallback rather than merging with it. The fallback
|
||||||
|
|||||||
@@ -125,16 +125,24 @@ the corresponding PromptKit filesystems and rejects invalid roots, unreadable
|
|||||||
assets, duplicate paths, and missing prompt or schema files during preparation.
|
assets, duplicate paths, and missing prompt or schema files during preparation.
|
||||||
Fallback assets receive a safe content digest for checkpoint identity; raw
|
Fallback assets receive a safe content digest for checkpoint identity; raw
|
||||||
paths and bytes are never included. The framework’s `promptfs` helper combines
|
paths and bytes are never included. The framework’s `promptfs` helper combines
|
||||||
module-owned prompt files with reusable domain fragments without making the
|
module-selected prompt files with reusable domain fragments without making the
|
||||||
framework depend on D&D content.
|
framework depend on D&D content.
|
||||||
|
|
||||||
Each LLM-backed module owns its prompt declaration, package-specific assets,
|
LLM-facing content is embedded once by the root `assets` package. Each consumer
|
||||||
and private response schema. Shared D&D wording is owned by the D&D shared
|
uses only its scoped subtree, while the module retains ownership of its prompt
|
||||||
asset package; the detailed D&D conventions are in
|
declaration, ordered manifest, private response-schema identity, and
|
||||||
[D&D Module Internals](dnd.md). The mounted prompt assets used by a module also
|
registration. Shared D&D fragments are selected by D&D's shared implementation;
|
||||||
determine its prompt fingerprint. Schema loaders validate JSON, attach identity
|
the detailed convention is in [D&D Module Internals](dnd.md). This physical
|
||||||
and digest metadata, make defensive copies, and expose diagnostics without raw
|
arrangement and its data-only boundary are defined by
|
||||||
schema bytes.
|
[Architecture](../policy/architecture.md) and
|
||||||
|
[ADR-0011](../adr/0011-centralize-llm-assets.md), rather than by this runtime
|
||||||
|
guide.
|
||||||
|
|
||||||
|
Mounted prompt assets determine a module's fingerprint. The fingerprint hashes
|
||||||
|
only the module and shared files explicitly selected by its manifest, so an
|
||||||
|
unrelated asset does not invalidate a checkpoint. Schema loaders validate JSON,
|
||||||
|
attach identity and digest metadata, make defensive copies, and expose
|
||||||
|
diagnostics without raw schema bytes.
|
||||||
|
|
||||||
Private response schemas validate a model transport envelope. They are not the
|
Private response schemas validate a model transport envelope. They are not the
|
||||||
durable artifact schema and should not be documented as an external wire
|
durable artifact schema and should not be documented as an external wire
|
||||||
|
|||||||
@@ -29,6 +29,7 @@ physical state roots.
|
|||||||
| Generic models | **internal/core/source**, **internal/core/artifacts**, **internal/framework/contracts** | Source documents and chunks, manifests and provenance, plus typed artifact, reference, validation, output, and structured-completion contracts. |
|
| Generic models | **internal/core/source**, **internal/core/artifacts**, **internal/framework/contracts** | Source documents and chunks, manifests and provenance, plus typed artifact, reference, validation, output, and structured-completion contracts. |
|
||||||
| Pipeline framework | **internal/framework/pipeline** | Registries, profile and reference resolution, typed preparation, validation, retry coordination, ordered execution, handoff, and result assembly. |
|
| Pipeline framework | **internal/framework/pipeline** | Registries, profile and reference resolution, typed preparation, validation, retry coordination, ordered execution, handoff, and result assembly. |
|
||||||
| LLM and prompt runtime | **internal/framework/llm**, **internal/framework/promptfs** | Provider-neutral structured completions, scheduling, profile recording, prompt assets, schema registration, and credential-shaped-value redaction. |
|
| LLM and prompt runtime | **internal/framework/llm**, **internal/framework/promptfs** | Provider-neutral structured completions, scheduling, profile recording, prompt assets, schema registration, and credential-shaped-value redaction. |
|
||||||
|
| Embedded LLM content | **assets** | Read-only centralized LLM-facing content, scoped by its consuming package; see [LLM Runtime](llm.md#prompt-and-schema-assets) and [D&D Module Internals](dnd.md#prompt-construction). |
|
||||||
| Runtime state | **internal/core/fileio**, **internal/core/debugbundle**, **internal/framework/checkpoint**, **internal/framework/chunkplan**, **internal/framework/chunkmap**, **internal/framework/debug** | Confined atomic files, debug bundles, checkpoint and chunk-plan state, accepted chunk maps, and pipeline-facing debug recording. |
|
| Runtime state | **internal/core/fileio**, **internal/core/debugbundle**, **internal/framework/checkpoint**, **internal/framework/chunkplan**, **internal/framework/chunkmap**, **internal/framework/debug** | Confined atomic files, debug bundles, checkpoint and chunk-plan state, accepted chunk maps, and pipeline-facing debug recording. |
|
||||||
| Production extensions | **internal/modules/generic**, **internal/modules/seriatim**, **internal/modules/dnd** | Domain-neutral extensions, Seriatim input support, and D&D extraction families registered into the production catalog. |
|
| Production extensions | **internal/modules/generic**, **internal/modules/seriatim**, **internal/modules/dnd** | Domain-neutral extensions, Seriatim input support, and D&D extraction families registered into the production catalog. |
|
||||||
|
|
||||||
|
|||||||
@@ -44,6 +44,13 @@ must not compose the application or take ownership of process behavior. The
|
|||||||
current packages implementing these layers are inventoried in
|
current packages implementing these layers are inventoried in
|
||||||
[Internal Overview](../internal/overview.md).
|
[Internal Overview](../internal/overview.md).
|
||||||
|
|
||||||
|
The root `assets` package is a content-only dependency leaf. It may expose a
|
||||||
|
read-only embedded filesystem, but it must contain no business logic and must
|
||||||
|
not depend on `internal` packages or PromptKit. Consumers scope that filesystem
|
||||||
|
to the content they own; the root package is not a behavioral registry or a
|
||||||
|
public extension contract. The rationale and compatibility consequence are
|
||||||
|
recorded in [ADR-0011](../adr/0011-centralize-llm-assets.md).
|
||||||
|
|
||||||
The following dependency boundaries are mandatory:
|
The following dependency boundaries are mandatory:
|
||||||
|
|
||||||
- extractors and validators do not depend on concrete input adapters;
|
- extractors and validators do not depend on concrete input adapters;
|
||||||
@@ -73,6 +80,12 @@ Extract modules own artifact semantics, prompt use, response schemas, and
|
|||||||
domain interpretation. Domain-specific concepts remain in the relevant module,
|
domain interpretation. Domain-specific concepts remain in the relevant module,
|
||||||
validator, shared domain helper, and artifact contract.
|
validator, shared domain helper, and artifact contract.
|
||||||
|
|
||||||
|
Physical centralization of LLM-facing content does not transfer semantic
|
||||||
|
ownership from those modules. Modules retain their manifests, response-schema
|
||||||
|
identities, prompt ordering, and registration, while reading only their scoped
|
||||||
|
content subtree. Generic framework code remains domain-neutral when it reads
|
||||||
|
its own scoped generic assets from the shared content container.
|
||||||
|
|
||||||
Typed artifact registrations declare one stable artifact kind and exact Go
|
Typed artifact registrations declare one stable artifact kind and exact Go
|
||||||
type from extraction through merge, normalization, and semantic validation.
|
type from extraction through merge, normalization, and semantic validation.
|
||||||
Pipeline resolution requires a compatible codec and matching kind-specific
|
Pipeline resolution requires a compatible codec and matching kind-specific
|
||||||
|
|||||||
@@ -2,17 +2,17 @@ package llm
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"crypto/sha256"
|
"crypto/sha256"
|
||||||
"embed"
|
|
||||||
"encoding/hex"
|
"encoding/hex"
|
||||||
"encoding/json"
|
"encoding/json"
|
||||||
"fmt"
|
"fmt"
|
||||||
"io/fs"
|
"io/fs"
|
||||||
"sort"
|
"sort"
|
||||||
"strings"
|
"strings"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
)
|
)
|
||||||
|
|
||||||
//go:embed assets/schemas/*.json
|
var schemaAssets = mustSubFS(rootassets.FS(), "generic")
|
||||||
var schemaAssets embed.FS
|
|
||||||
|
|
||||||
// ResponseSchemaKey identifies one structured response schema.
|
// ResponseSchemaKey identifies one structured response schema.
|
||||||
type ResponseSchemaKey string
|
type ResponseSchemaKey string
|
||||||
@@ -49,17 +49,25 @@ var responseSchemaRegistry = map[ResponseSchemaKey]ResponseSchema{
|
|||||||
ID: "notarius.test_artifact",
|
ID: "notarius.test_artifact",
|
||||||
Version: schemaVersionV1,
|
Version: schemaVersionV1,
|
||||||
Name: "notarius_test_artifact_v1",
|
Name: "notarius_test_artifact_v1",
|
||||||
AssetPath: "assets/schemas/test_artifact.v1.json",
|
AssetPath: "schemas/test_artifact.v1.json",
|
||||||
}),
|
}),
|
||||||
TestValidatorDecisionSchemaKey: mustLoadResponseSchema(schemaAssets, ResponseSchemaDefinition{
|
TestValidatorDecisionSchemaKey: mustLoadResponseSchema(schemaAssets, ResponseSchemaDefinition{
|
||||||
Key: TestValidatorDecisionSchemaKey,
|
Key: TestValidatorDecisionSchemaKey,
|
||||||
ID: "notarius.test_validator_decision",
|
ID: "notarius.test_validator_decision",
|
||||||
Version: schemaVersionV1,
|
Version: schemaVersionV1,
|
||||||
Name: "notarius_test_validator_decision_v1",
|
Name: "notarius_test_validator_decision_v1",
|
||||||
AssetPath: "assets/schemas/test_validator_decision.v1.json",
|
AssetPath: "schemas/test_validator_decision.v1.json",
|
||||||
}),
|
}),
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func mustSubFS(fsys fs.FS, dir string) fs.FS {
|
||||||
|
sub, err := fs.Sub(fsys, dir)
|
||||||
|
if err != nil {
|
||||||
|
panic(fmt.Errorf("scope embedded assets to %s: %w", dir, err))
|
||||||
|
}
|
||||||
|
return sub
|
||||||
|
}
|
||||||
|
|
||||||
// RegisteredResponseSchemas returns all registered response schemas sorted by key.
|
// RegisteredResponseSchemas returns all registered response schemas sorted by key.
|
||||||
func RegisteredResponseSchemas() []ResponseSchema {
|
func RegisteredResponseSchemas() []ResponseSchema {
|
||||||
keys := make([]string, 0, len(responseSchemaRegistry))
|
keys := make([]string, 0, len(responseSchemaRegistry))
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package scenes
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/schemas/*.json assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package scenes
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: "dnd.scenes",
|
ModuleDir: "dnd.scenes",
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.scenes.yaml", Path: "assets/prompts/dnd.scenes.yaml"},
|
{Name: "dnd.scenes.yaml", Path: "prompts/dnd.scenes.yaml"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -25,20 +27,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/scenes")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope scene assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare scene prompt assets: %w", err)
|
return fmt.Errorf("prepare scene prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope scene schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: ResponseSchemaVersion,
|
Version: ResponseSchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_scenes.v1.json",
|
AssetPath: "schemas/dnd_scenes.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package combatturns
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/schemas/dnd_combat_turns_llm.v1.json assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package combatturns
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: "dnd.combat_turns",
|
ModuleDir: "dnd.combat_turns",
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.combat_turns.yaml", Path: "assets/prompts/dnd.combat_turns.yaml"},
|
{Name: "dnd.combat_turns.yaml", Path: "prompts/dnd.combat_turns.yaml"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -28,20 +30,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/combat-turns")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope combat-turn assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare combat-turn prompt assets: %w", err)
|
return fmt.Errorf("prepare combat-turn prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope combat-turn schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_combat_turns_llm.v1.json",
|
AssetPath: "schemas/dnd_combat_turns_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package enemyevents
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/schemas/dnd_enemy_events_llm.v1.json assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package enemyevents
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,10 +16,10 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: "dnd.enemy_events",
|
ModuleDir: "dnd.enemy_events",
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.enemy_events.yaml", Path: "assets/prompts/dnd.enemy_events.yaml"},
|
{Name: "dnd.enemy_events.yaml", Path: "prompts/dnd.enemy_events.yaml"},
|
||||||
{Name: "grounding.md", Path: "assets/prompts/grounding.md"},
|
{Name: "grounding.md", Path: "prompts/grounding.md"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -29,20 +31,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/enemy-events")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope enemy-event assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare enemy-event prompt assets: %w", err)
|
return fmt.Errorf("prepare enemy-event prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope enemy-event schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_enemy_events_llm.v1.json",
|
AssetPath: "schemas/dnd_enemy_events_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package itemevents
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/schemas/dnd_item_events_llm.v1.json assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package itemevents
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: "dnd.item_events",
|
ModuleDir: "dnd.item_events",
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.item_events.yaml", Path: "assets/prompts/dnd.item_events.yaml"},
|
{Name: "dnd.item_events.yaml", Path: "prompts/dnd.item_events.yaml"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -27,20 +29,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/item-events")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope item-event assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare item event prompt assets: %w", err)
|
return fmt.Errorf("prepare item event prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope item-event schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_item_events_llm.v1.json",
|
AssetPath: "schemas/dnd_item_events_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package locationoccurrences
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/prompts/*.yaml assets/prompts/*.md assets/schemas/*.json
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package locationoccurrences
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,10 +16,10 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: PromptID,
|
ModuleDir: PromptID,
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.location_occurrences.yaml", Path: "assets/prompts/dnd.location_occurrences.yaml"},
|
{Name: "dnd.location_occurrences.yaml", Path: "prompts/dnd.location_occurrences.yaml"},
|
||||||
{Name: "locations.md", Path: "assets/prompts/locations.md"},
|
{Name: "locations.md", Path: "prompts/locations.md"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -28,20 +30,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/location-occurrences")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope location-occurrence assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare location-occurrence prompt assets: %w", err)
|
return fmt.Errorf("prepare location-occurrence prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope location-occurrence schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_location_occurrences_llm.v1.json",
|
AssetPath: "schemas/dnd_location_occurrences_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package locations
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/prompts/*.yaml assets/prompts/*.md assets/schemas/*.json
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package locations
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: PromptID,
|
ModuleDir: PromptID,
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.locations.yaml", Path: "assets/prompts/dnd.locations.yaml"},
|
{Name: "dnd.locations.yaml", Path: "prompts/dnd.locations.yaml"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -27,20 +29,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/locations/extract")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope location extraction assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare location prompt assets: %w", err)
|
return fmt.Errorf("prepare location prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope location extraction schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_locations_llm.v1.json",
|
AssetPath: "schemas/dnd_locations_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package npcinteractions
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/schemas/dnd_npc_interactions_llm.v1.json assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package npcinteractions
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: "dnd.npc_interactions",
|
ModuleDir: "dnd.npc_interactions",
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.npc_interactions.yaml", Path: "assets/prompts/dnd.npc_interactions.yaml"},
|
{Name: "dnd.npc_interactions.yaml", Path: "prompts/dnd.npc_interactions.yaml"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -28,20 +30,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/npc-interactions")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope NPC-interaction assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare NPC-interaction prompt assets: %w", err)
|
return fmt.Errorf("prepare NPC-interaction prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope NPC-interaction schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_npc_interactions_llm.v1.json",
|
AssetPath: "schemas/dnd_npc_interactions_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package npcs
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/schemas/dnd_npcs_llm.v1.json assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package npcs
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: "dnd.npcs",
|
ModuleDir: "dnd.npcs",
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.npcs.yaml", Path: "assets/prompts/dnd.npcs.yaml"},
|
{Name: "dnd.npcs.yaml", Path: "prompts/dnd.npcs.yaml"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -27,20 +29,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/npcs/extract")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope NPC extraction assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare NPC prompt assets: %w", err)
|
return fmt.Errorf("prepare NPC prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope NPC extraction schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -11,11 +11,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_npcs_llm.v1.json",
|
AssetPath: "schemas/dnd_npcs_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package scenedescriptions
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/schemas/dnd_scene_descriptions_llm.v1.json assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package scenedescriptions
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,9 +16,9 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: "dnd.scene_descriptions",
|
ModuleDir: "dnd.scene_descriptions",
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.scene_descriptions.yaml", Path: "assets/prompts/dnd.scene_descriptions.yaml"},
|
{Name: "dnd.scene_descriptions.yaml", Path: "prompts/dnd.scene_descriptions.yaml"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -26,20 +28,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/scene-descriptions")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope scene-description assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare scene-description prompt assets: %w", err)
|
return fmt.Errorf("prepare scene-description prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope scene-description schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -12,11 +12,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_scene_descriptions_llm.v1.json",
|
AssetPath: "schemas/dnd_scene_descriptions_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package spells
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/schemas/dnd_spells_llm.v1.json assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package spells
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,10 +16,10 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: "dnd.spells",
|
ModuleDir: "dnd.spells",
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.spells.yaml", Path: "assets/prompts/dnd.spells.yaml"},
|
{Name: "dnd.spells.yaml", Path: "prompts/dnd.spells.yaml"},
|
||||||
{Name: "catalog.md", Path: "assets/prompts/catalog.md"},
|
{Name: "catalog.md", Path: "prompts/catalog.md"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "instructions.md", Path: "assets/prompts/instructions.md"},
|
{Name: "instructions.md", Path: "prompts/instructions.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{
|
SharedFiles: []string{
|
||||||
"common-dnd-system.md",
|
"common-dnd-system.md",
|
||||||
@@ -29,20 +31,41 @@ var promptAssetManifest = shared.PromptAssetManifest{
|
|||||||
},
|
},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/spells")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope spell assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare spell prompt assets: %w", err)
|
return fmt.Errorf("prepare spell prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
if err := registry.RegisterPromptFS(promptFS, promptAssetRoot); err != nil {
|
||||||
return err
|
return err
|
||||||
}
|
}
|
||||||
return registry.RegisterSchemaFS(embeddedAssets, "assets/schemas")
|
schemas, err := fs.Sub(assets, "schemas")
|
||||||
|
if err != nil {
|
||||||
|
return fmt.Errorf("scope spell schemas: %w", err)
|
||||||
|
}
|
||||||
|
return registry.RegisterSchemaFS(schemas, ".")
|
||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() {
|
promptAssetHashOnce.Do(func() {
|
||||||
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
})
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -10,11 +10,15 @@ const (
|
|||||||
)
|
)
|
||||||
|
|
||||||
func loadResponseSchema() (llm.ResponseSchema, error) {
|
func loadResponseSchema() (llm.ResponseSchema, error) {
|
||||||
return llm.LoadResponseSchema(embeddedAssets, llm.ResponseSchemaDefinition{
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return llm.ResponseSchema{}, err
|
||||||
|
}
|
||||||
|
return llm.LoadResponseSchema(assets, llm.ResponseSchemaDefinition{
|
||||||
Key: ResponseSchemaKey,
|
Key: ResponseSchemaKey,
|
||||||
ID: ResponseSchemaID,
|
ID: ResponseSchemaID,
|
||||||
Version: SchemaVersion,
|
Version: SchemaVersion,
|
||||||
Name: ResponseSchemaName,
|
Name: ResponseSchemaName,
|
||||||
AssetPath: "assets/schemas/dnd_spells_llm.v1.json",
|
AssetPath: "schemas/dnd_spells_llm.v1.json",
|
||||||
})
|
})
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -1,6 +0,0 @@
|
|||||||
package locations
|
|
||||||
|
|
||||||
import "embed"
|
|
||||||
|
|
||||||
//go:embed assets/prompts/*.yaml assets/prompts/*.md
|
|
||||||
var embeddedAssets embed.FS
|
|
||||||
@@ -2,8 +2,10 @@ package locations
|
|||||||
|
|
||||||
import (
|
import (
|
||||||
"fmt"
|
"fmt"
|
||||||
|
"io/fs"
|
||||||
"sync"
|
"sync"
|
||||||
|
|
||||||
|
rootassets "gitea.maximumdirect.net/eric/notarius/assets"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/llm"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
"gitea.maximumdirect.net/eric/notarius/internal/framework/promptfs"
|
||||||
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
"gitea.maximumdirect.net/eric/notarius/internal/modules/dnd/shared"
|
||||||
@@ -14,15 +16,27 @@ const promptAssetRoot = "assets/prompts"
|
|||||||
var promptAssetManifest = shared.PromptAssetManifest{
|
var promptAssetManifest = shared.PromptAssetManifest{
|
||||||
ModuleDir: PromptID,
|
ModuleDir: PromptID,
|
||||||
ModuleFiles: []promptfs.ModulePromptFile{
|
ModuleFiles: []promptfs.ModulePromptFile{
|
||||||
{Name: "dnd.locations.normalize.yaml", Path: "assets/prompts/dnd.locations.normalize.yaml"},
|
{Name: "dnd.locations.normalize.yaml", Path: "prompts/dnd.locations.normalize.yaml"},
|
||||||
{Name: "task.md", Path: "assets/prompts/task.md"},
|
{Name: "task.md", Path: "prompts/task.md"},
|
||||||
{Name: "candidates.md", Path: "assets/prompts/candidates.md"},
|
{Name: "candidates.md", Path: "prompts/candidates.md"},
|
||||||
},
|
},
|
||||||
SharedFiles: []string{"common-dnd-system.md", "common-dnd-entity-reconciliation.md", "common-dnd-transcript.md"},
|
SharedFiles: []string{"common-dnd-system.md", "common-dnd-entity-reconciliation.md", "common-dnd-transcript.md"},
|
||||||
}
|
}
|
||||||
|
|
||||||
|
func moduleAssetFS() (fs.FS, error) {
|
||||||
|
assets, err := fs.Sub(rootassets.FS(), "dnd/locations/normalize")
|
||||||
|
if err != nil {
|
||||||
|
return nil, fmt.Errorf("scope location normalization assets: %w", err)
|
||||||
|
}
|
||||||
|
return assets, nil
|
||||||
|
}
|
||||||
|
|
||||||
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
||||||
promptFS, err := promptAssetManifest.PromptFS(embeddedAssets)
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
return err
|
||||||
|
}
|
||||||
|
promptFS, err := promptAssetManifest.PromptFS(assets)
|
||||||
if err != nil {
|
if err != nil {
|
||||||
return fmt.Errorf("prepare location normalization prompt assets: %w", err)
|
return fmt.Errorf("prepare location normalization prompt assets: %w", err)
|
||||||
}
|
}
|
||||||
@@ -30,7 +44,14 @@ func RegisterPromptAssets(registry *llm.AssetRegistry) error {
|
|||||||
}
|
}
|
||||||
|
|
||||||
func promptAssetMetadata() (string, error) {
|
func promptAssetMetadata() (string, error) {
|
||||||
promptAssetHashOnce.Do(func() { promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(embeddedAssets) })
|
promptAssetHashOnce.Do(func() {
|
||||||
|
assets, err := moduleAssetFS()
|
||||||
|
if err != nil {
|
||||||
|
promptAssetHashErr = err
|
||||||
|
return
|
||||||
|
}
|
||||||
|
promptAssetHash, promptAssetHashErr = promptAssetManifest.Hash(assets)
|
||||||
|
})
|
||||||
return promptAssetHash, promptAssetHashErr
|
return promptAssetHash, promptAssetHashErr
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user