( filePath: string, prompt: Partial<Prompt>, functionName: string | undefined, )
| 83 | * @returns Array of prompts extracted or executed from the file. |
| 84 | */ |
| 85 | export function processPythonFile( |
| 86 | filePath: string, |
| 87 | prompt: Partial<Prompt>, |
| 88 | functionName: string | undefined, |
| 89 | ): Prompt[] { |
| 90 | const fileContent = fs.readFileSync(filePath, 'utf-8'); |
| 91 | const label = |
| 92 | prompt.label ?? (functionName ? `${filePath}:${functionName}` : `${filePath}: ${fileContent}`); |
| 93 | return [ |
| 94 | { |
| 95 | raw: fileContent, |
| 96 | label, |
| 97 | function: functionName |
| 98 | ? (context) => |
| 99 | pythonPromptFunction(filePath, functionName, { ...context, config: prompt.config }) |
| 100 | : (context) => pythonPromptFunctionLegacy(filePath, { ...context, config: prompt.config }), |
| 101 | config: prompt.config, |
| 102 | }, |
| 103 | ]; |
| 104 | } |
no test coverage detected
searching dependent graphs…