[Core] Patch: rm dumpd of outputs from runnables/base (#18295)

It obstructs evaluations when your return a pydantic object.
This commit is contained in:
William FH 2024-02-29 18:04:53 -08:00 committed by GitHub
parent c7d5ed6f5c
commit fdab931fd3
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
3 changed files with 21 additions and 17 deletions

View File

@ -1272,7 +1272,7 @@ class Runnable(Generic[Input, Output], ABC):
run_manager.on_chain_error(e) run_manager.on_chain_error(e)
raise raise
else: else:
run_manager.on_chain_end(dumpd(output)) run_manager.on_chain_end(output)
return output return output
async def _acall_with_config( async def _acall_with_config(
@ -1315,7 +1315,7 @@ class Runnable(Generic[Input, Output], ABC):
await run_manager.on_chain_error(e) await run_manager.on_chain_error(e)
raise raise
else: else:
await run_manager.on_chain_end(dumpd(output)) await run_manager.on_chain_end(output)
return output return output
def _batch_with_config( def _batch_with_config(
@ -1379,7 +1379,7 @@ class Runnable(Generic[Input, Output], ABC):
first_exception = first_exception or out first_exception = first_exception or out
run_manager.on_chain_error(out) run_manager.on_chain_error(out)
else: else:
run_manager.on_chain_end(dumpd(out)) run_manager.on_chain_end(out)
if return_exceptions or first_exception is None: if return_exceptions or first_exception is None:
return cast(List[Output], output) return cast(List[Output], output)
else: else:
@ -1454,7 +1454,7 @@ class Runnable(Generic[Input, Output], ABC):
first_exception = first_exception or out first_exception = first_exception or out
coros.append(run_manager.on_chain_error(out)) coros.append(run_manager.on_chain_error(out))
else: else:
coros.append(run_manager.on_chain_end(dumpd(out))) coros.append(run_manager.on_chain_end(out))
await asyncio.gather(*coros) await asyncio.gather(*coros)
if return_exceptions or first_exception is None: if return_exceptions or first_exception is None:
return cast(List[Output], output) return cast(List[Output], output)
@ -2238,7 +2238,7 @@ class RunnableSequence(RunnableSerializable[Input, Output]):
first_exception = first_exception or out first_exception = first_exception or out
run_manager.on_chain_error(out) run_manager.on_chain_error(out)
else: else:
run_manager.on_chain_end(dumpd(out)) run_manager.on_chain_end(out)
if return_exceptions or first_exception is None: if return_exceptions or first_exception is None:
return cast(List[Output], inputs) return cast(List[Output], inputs)
else: else:
@ -2363,7 +2363,7 @@ class RunnableSequence(RunnableSerializable[Input, Output]):
first_exception = first_exception or out first_exception = first_exception or out
coros.append(run_manager.on_chain_error(out)) coros.append(run_manager.on_chain_error(out))
else: else:
coros.append(run_manager.on_chain_end(dumpd(out))) coros.append(run_manager.on_chain_end(out))
await asyncio.gather(*coros) await asyncio.gather(*coros)
if return_exceptions or first_exception is None: if return_exceptions or first_exception is None:
return cast(List[Output], inputs) return cast(List[Output], inputs)

View File

@ -476,6 +476,10 @@ def _get_standardized_outputs(
""" """
outputs = load(run.outputs) outputs = load(run.outputs)
if schema_format == "original": if schema_format == "original":
if run.run_type == "prompt" and "output" in outputs:
# These were previously dumped before the tracer.
# Now we needn't do anything to them.
return outputs["output"]
# Return the old schema, without standardizing anything # Return the old schema, without standardizing anything
return outputs return outputs

File diff suppressed because one or more lines are too long