Collect prompt file paths from effective configuration
This commit is contained in:
@@ -41,10 +41,23 @@ const operatorImports = `config:
|
||||
`
|
||||
|
||||
func NewRuntime(ctx context.Context, loaded *ck.Result[config.Config], client *http.Client) (*Runtime, error) {
|
||||
return newRuntimeWithPromptFS(ctx, loaded, client, prompts.Filesystem())
|
||||
engine, err := NewEngine(ctx, loaded, client)
|
||||
if err != nil {
|
||||
return nil, err
|
||||
}
|
||||
paths, err := capturedSourcePaths(engine)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("inspect captured LLM sources: %w", err)
|
||||
}
|
||||
return &Runtime{Config: loaded.Config, Engine: engine, SourcePaths: paths}, nil
|
||||
}
|
||||
|
||||
func newRuntimeWithPromptFS(ctx context.Context, loaded *ck.Result[config.Config], client *http.Client, promptFS fs.FS) (*Runtime, error) {
|
||||
// NewEngine loads the captured PromptKit resources without processing collision checks.
|
||||
func NewEngine(ctx context.Context, loaded *ck.Result[config.Config], client *http.Client) (*pk.Engine, error) {
|
||||
return newEngineWithPromptFS(ctx, loaded, client, prompts.Filesystem())
|
||||
}
|
||||
|
||||
func newEngineWithPromptFS(ctx context.Context, loaded *ck.Result[config.Config], client *http.Client, promptFS fs.FS) (*pk.Engine, error) {
|
||||
if err := ctx.Err(); err != nil {
|
||||
return nil, err
|
||||
}
|
||||
@@ -93,11 +106,7 @@ func newRuntimeWithPromptFS(ctx context.Context, loaded *ck.Result[config.Config
|
||||
return nil, embeddedAssetOrInputError(ctx, embedded, fmt.Errorf("inspect prompt %s: %w", meta.PromptID, err))
|
||||
}
|
||||
}
|
||||
paths, err := capturedSourcePaths(engine)
|
||||
if err != nil {
|
||||
return nil, fmt.Errorf("inspect captured LLM sources: %w", err)
|
||||
}
|
||||
return &Runtime{Config: loaded.Config, Engine: engine, SourcePaths: paths}, nil
|
||||
return engine, nil
|
||||
}
|
||||
|
||||
func embeddedAssetOrInputError(ctx context.Context, inputs []ck.Input, cause error) error {
|
||||
|
||||
Reference in New Issue
Block a user