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

View File

@ -476,6 +476,10 @@ def _get_standardized_outputs(
"""
outputs = load(run.outputs)
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 outputs

File diff suppressed because one or more lines are too long