https://promptfoo.dev/ logo
Does transform support reading a .js file just lik...
# ❓|questions
a
I checked the docs, and all the example show inline
js
examples. I'm using
StructuredOutputParser
using
zod
in langchain and getting
JSON
from LLMs. Now I get a response in a
JSON
format, but it's wrapped in a code block (3 backticks), so before running any assertions, I first want to parse it using
Zod.
Parsing via
zod
would validate the structure of the response but I want to format the response in text format for
llm-rubric
. It would save me token cost, and the
llm
would only need to focus on the content, not the structure.
Also, moving to a file would make it easier to use libraries, for eg.
lodash
etc
i
Not currently possible but I've just added support for this: https://github.com/promptfoo/promptfoo/pull/605 Example:
Copy code
yaml
# ...
tests:
  - vars:
      language: French
      body: Hello world
    options:
      transform: file://path/to/transform.js
    # ...
Copy code
js
module.exports = (output, context) => {
  // Use context.vars, context.prompt ...
  return output.toUpperCase();
}
Will be included in tonight's release
a
I don't know what to say, other than that you're amazing @ian 🫶 Saw your other equally impressive projects and I'm a fan now. Thank you once again.
2 Views