Prepare reports for Promptkit migration
This commit is contained in:
49
internal/promptassets/promptassets.go
Normal file
49
internal/promptassets/promptassets.go
Normal file
@@ -0,0 +1,49 @@
|
||||
// Package promptassets owns the embedded Promptkit prompt and schema corpus.
|
||||
package promptassets
|
||||
|
||||
import (
|
||||
"embed"
|
||||
"fmt"
|
||||
"io/fs"
|
||||
)
|
||||
|
||||
//go:embed assets/prompts assets/schemas
|
||||
var assets embed.FS
|
||||
|
||||
var schemaPaths = map[string]string{
|
||||
"daily": "assets/schemas/daily.generated_text.schema.json",
|
||||
"hourly": "assets/schemas/hourly.generated_text.schema.json",
|
||||
"today": "assets/schemas/today.generated_text.schema.json",
|
||||
"tomorrow": "assets/schemas/tomorrow.generated_text.schema.json",
|
||||
}
|
||||
|
||||
// PromptFS returns the embedded prompt definitions and their referenced files.
|
||||
func PromptFS() fs.FS {
|
||||
fsys, err := fs.Sub(assets, "assets/prompts")
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("embedded prompt assets: %v", err))
|
||||
}
|
||||
return fsys
|
||||
}
|
||||
|
||||
// SchemaFS returns the embedded generated-text JSON schemas.
|
||||
func SchemaFS() fs.FS {
|
||||
fsys, err := fs.Sub(assets, "assets/schemas")
|
||||
if err != nil {
|
||||
panic(fmt.Sprintf("embedded schema assets: %v", err))
|
||||
}
|
||||
return fsys
|
||||
}
|
||||
|
||||
// Schema returns an independent copy of the canonical schema for id.
|
||||
func Schema(id string) ([]byte, error) {
|
||||
path, ok := schemaPaths[id]
|
||||
if !ok {
|
||||
return nil, fmt.Errorf("unknown generated text schema %q", id)
|
||||
}
|
||||
data, err := assets.ReadFile(path)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("read generated text schema %q: %w", id, err)
|
||||
}
|
||||
return append([]byte(nil), data...), nil
|
||||
}
|
||||
Reference in New Issue
Block a user