From dd7af1f6b4ea169544f2dd239552d25b9c61d41a Mon Sep 17 00:00:00 2001 From: Kaustubh Kumar Date: Sat, 13 Apr 2024 19:47:57 +0530 Subject: [PATCH] =?UTF-8?q?fix:=20py-script=20execute's=20return=20type=20?= =?UTF-8?q?should=20be=20consistent=20with=20scorer=E2=80=A6=20(#125)?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- .changeset/pink-laws-relax.md | 5 +++++ docs/models/custom.mdx | 6 +++--- examples/rag/rag.py | 3 +-- packages/core/src/executors/run/transformers/script.ts | 2 +- 4 files changed, 10 insertions(+), 6 deletions(-) create mode 100644 .changeset/pink-laws-relax.md diff --git a/.changeset/pink-laws-relax.md b/.changeset/pink-laws-relax.md new file mode 100644 index 00000000..5c0e738d --- /dev/null +++ b/.changeset/pink-laws-relax.md @@ -0,0 +1,5 @@ +--- +"@empiricalrun/core": minor +--- + +fix: py-script execute's return type should be consistent with scorer's return type diff --git a/docs/models/custom.mdx b/docs/models/custom.mdx index d59ecebf..31c46fe3 100644 --- a/docs/models/custom.mdx +++ b/docs/models/custom.mdx @@ -30,8 +30,8 @@ signature: - **Arguments** - inputs: dict of key-value pairs with [sample inputs](../dataset/basics) - parameters: dict of key-value pairs with the run parameters -- **Returns**: a dict with - - output (string): The response from the model/application +- **Returns**: an output dict with + - value (string): The response from the model/application - metadata (dict): Custom key-value pairs that are passed on to the scorer and web reporter @@ -40,7 +40,7 @@ signature: def execute(inputs): # ... return { - "output": output, + "value": output, "metadata": { "key": value } diff --git a/examples/rag/rag.py b/examples/rag/rag.py index c6b40a4c..d3b957bc 100644 --- a/examples/rag/rag.py +++ b/examples/rag/rag.py @@ -24,8 +24,7 @@ def build_query_engine(llm): response = query_engine.query(question) output = response.response contexts = [c.node.get_content() for c in response.source_nodes] - return { - "output": output, + "value": output, "metadata": {"contexts": contexts}, } diff --git a/packages/core/src/executors/run/transformers/script.ts b/packages/core/src/executors/run/transformers/script.ts index 69e3660b..9a4002a4 100644 --- a/packages/core/src/executors/run/transformers/script.ts +++ b/packages/core/src/executors/run/transformers/script.ts @@ -75,7 +75,7 @@ export const scriptExecutor: Transformer = async (runConfig, sample) => { return { output: { - value: result["output"], + value: result["value"], metadata: result["metadata"], }, };