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

Function pythonPromptFunction

src/prompts/processors/python.ts:20–41  ·  view source on GitHub ↗
(
  filePath: string,
  functionName: string,
  context: {
    vars: Record<string, VarValue>;
    provider?: ApiProvider;
    config?: unknown;
  },
)

Source from the content-addressed store, hash-verified

18 * @returns The prompts
19 */
20export const pythonPromptFunction = async (
21 filePath: string,
22 functionName: string,
23 context: {
24 vars: Record<string, VarValue>;
25 provider?: ApiProvider;
26 config?: unknown;
27 },
28) => {
29 invariant(context.provider?.id, 'provider.id is required');
30 const transformedContext: PromptFunctionContext = {
31 vars: context.vars,
32 provider: {
33 id:
34 typeof context.provider?.id === 'function' ? context.provider?.id() : context.provider?.id,
35 label: context.provider?.label,
36 },
37 config: context.config ?? {},
38 };
39
40 return runPython(filePath, functionName, [transformedContext]);
41};
42
43/**
44 * Legacy Python prompt function. Runs the whole python file.

Callers 2

processPythonFileFunction · 0.85

Calls 3

runPythonFunction · 0.90
invariantFunction · 0.85
idMethod · 0.65

Tested by

no test coverage detected

Used in the wild real call sites across dependent graphs

searching dependent graphs…