MCPcopy Index your code
hub / github.com/promptfoo/promptfoo / processPythonFile

Function processPythonFile

src/prompts/processors/python.ts:85–104  ·  view source on GitHub ↗
(
  filePath: string,
  prompt: Partial<Prompt>,
  functionName: string | undefined,
)

Source from the content-addressed store, hash-verified

83 * @returns Array of prompts extracted or executed from the file.
84 */
85export 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}

Callers 2

python.test.tsFile · 0.90
processPromptFunction · 0.90

Calls 2

pythonPromptFunctionFunction · 0.85

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…