feat: Add system-prompt-file input for file-based system prompts
This enhancement adds the ability to load a system prompt from a file, similar to the existing prompt-file functionality, providing more flexibility when working with complex system prompts. Key changes: - Added new `system-prompt-file` input to action.yml with proper description - Updated main.ts implementation to handle file-based system prompts with: - File existence checking and appropriate error handling - Proper precedence (system-prompt-file takes priority over system-prompt) - Consistent error messages with existing prompt-file implementation Test coverage added: - Basic usage: Test verifies system-prompt-file loads content correctly - Error handling: Test ensures proper errors when system-prompt-file doesn't exist - Precedence: Test confirms system-prompt-file overrides system-prompt when both exist - Integration: Test validates both prompt-file and system-prompt-file work together - Max tokens: Test verifies custom token limits are properly passed to the model - Testing infrastructure: Improved mock implementations that detect unexpected calls Documentation: - Updated README.md with system-prompt-file in inputs table - Added dedicated usage example for system-prompt-file - Fixed formatting in inputs table CI/CD: - Updated workflow to test system-prompt-file functionality with actual file content This feature maintains backward compatibility while adding a useful option for workflows that need to use more complex system prompts stored in files.
This commit is contained in:
+16
-1
@@ -33574,7 +33574,22 @@ async function run() {
|
||||
else {
|
||||
throw new Error('prompt is not set');
|
||||
}
|
||||
const systemPrompt = coreExports.getInput('system-prompt');
|
||||
const systemPromptFile = coreExports.getInput('system-prompt-file');
|
||||
const systemPromptString = coreExports.getInput('system-prompt');
|
||||
let systemPrompt;
|
||||
if (systemPromptFile !== undefined && systemPromptFile !== '') {
|
||||
if (!fs.existsSync(systemPromptFile)) {
|
||||
throw new Error(`System prompt file not found: ${systemPromptFile}`);
|
||||
}
|
||||
systemPrompt = fs.readFileSync(systemPromptFile, 'utf-8');
|
||||
}
|
||||
else if (systemPromptString !== undefined && systemPromptString !== '') {
|
||||
systemPrompt = systemPromptString;
|
||||
}
|
||||
else {
|
||||
// Use default system prompt
|
||||
systemPrompt = 'You are a helpful assistant';
|
||||
}
|
||||
const modelName = coreExports.getInput('model');
|
||||
const maxTokens = parseInt(coreExports.getInput('max-tokens'), 10);
|
||||
const token = coreExports.getInput('token') || process.env['GITHUB_TOKEN'];
|
||||
|
||||
+1
-1
File diff suppressed because one or more lines are too long
Reference in New Issue
Block a user