Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
11 changes: 8 additions & 3 deletions dist/index.js

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

2 changes: 1 addition & 1 deletion dist/index.js.map

Large diffs are not rendered by default.

13 changes: 9 additions & 4 deletions src/prompt.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,11 +101,8 @@ export function loadPromptFile(filePath: string, templateVariables: TemplateVari

const fileContent = fs.readFileSync(filePath, 'utf-8')

// Apply template variable substitution
const processedContent = replaceTemplateVariables(fileContent, templateVariables)

try {
const config = yaml.load(processedContent) as PromptConfig
const config = yaml.load(fileContent) as PromptConfig

if (!config.messages || !Array.isArray(config.messages)) {
throw new Error('Prompt file must contain a "messages" array')
Expand All @@ -121,6 +118,14 @@ export function loadPromptFile(filePath: string, templateVariables: TemplateVari
}
}

// Prepare messages by replacing template variables with actual content
config.messages = config.messages.map(msg => {
return {
...msg,
content: replaceTemplateVariables(msg.content, templateVariables),
}
})

return config
} catch (error) {
throw new Error(`Failed to parse prompt file: ${error instanceof Error ? error.message : 'Unknown error'}`)
Expand Down