mirror of
https://github.com/hwchase17/langchain.git
synced 2025-07-06 21:20:33 +00:00
add repr for not serializable (#10071)
Co-authored-by: Nuno Campos <nuno@boringbits.io>
This commit is contained in:
parent
355ff09cce
commit
d7bf7dc412
@ -1193,7 +1193,6 @@ class CallbackManager(BaseCallbackManager):
|
||||
"""
|
||||
if run_id is None:
|
||||
run_id = uuid.uuid4()
|
||||
|
||||
_handle_event(
|
||||
self.handlers,
|
||||
"on_chain_start",
|
||||
|
@ -1,5 +1,5 @@
|
||||
from abc import ABC
|
||||
from typing import Any, Dict, List, Literal, TypedDict, Union, cast
|
||||
from typing import Any, Dict, List, Literal, Optional, TypedDict, Union, cast
|
||||
|
||||
from langchain.pydantic_v1 import BaseModel, PrivateAttr
|
||||
|
||||
@ -28,6 +28,7 @@ class SerializedNotImplemented(BaseSerialized):
|
||||
"""Serialized not implemented."""
|
||||
|
||||
type: Literal["not_implemented"]
|
||||
repr: Optional[str]
|
||||
|
||||
|
||||
class Serializable(BaseModel, ABC):
|
||||
@ -156,8 +157,15 @@ def to_json_not_implemented(obj: object) -> SerializedNotImplemented:
|
||||
_id = [*obj.__class__.__module__.split("."), obj.__class__.__name__]
|
||||
except Exception:
|
||||
pass
|
||||
return {
|
||||
|
||||
result: SerializedNotImplemented = {
|
||||
"lc": 1,
|
||||
"type": "not_implemented",
|
||||
"id": _id,
|
||||
"repr": None,
|
||||
}
|
||||
try:
|
||||
result["repr"] = repr(obj)
|
||||
except Exception:
|
||||
pass
|
||||
return result
|
||||
|
@ -1697,6 +1697,9 @@ class RunnableLambda(Runnable[Input, Output]):
|
||||
else:
|
||||
return False
|
||||
|
||||
def __repr__(self) -> str:
|
||||
return "RunnableLambda(...)"
|
||||
|
||||
def _invoke(
|
||||
self,
|
||||
input: Input,
|
||||
|
@ -229,7 +229,8 @@
|
||||
"api_resources",
|
||||
"completion",
|
||||
"Completion"
|
||||
]
|
||||
],
|
||||
"repr": "<class 'openai.api_resources.completion.Completion'>"
|
||||
}
|
||||
}
|
||||
},
|
||||
|
File diff suppressed because one or more lines are too long
Loading…
Reference in New Issue
Block a user