stream_log endpoint fails on chain with object DynamoDBChatMessageHistory #507
Unanswered
mesutgurlek
asked this question in
Q&A
Replies: 2 comments 1 reply
-
What's the failure you're seeing? |
Beta Was this translation helpful? Give feedback.
1 reply
-
Hi again @eyurtsev, I think I got the problem specifically, so I can provide the summary, but still dont know how to workaround it.
yield {
# EventSourceResponse expects a string for data
# so after serializing into bytes, we decode into utf-8
# to get a string.
"data": self._serializer.dumps(data).decode("utf-8"),
"event": "data",
}
self._serializer = WellKnownLCSerializer()
class WellKnownLCSerializer(Serializer):
def dumpd(self, obj: Any) -> Any:
"""Convert the given object to a JSON serializable object."""
return orjson.loads(orjson.dumps(obj, default=default))
def dumps(self, obj: Any) -> bytes:
"""Dump the given object as a JSON string."""
return orjson.dumps(obj, default=default)
def loadd(self, obj: Any) -> Any:
"""Load the given object."""
return _decode_lc_objects(obj)
def loads(self, s: bytes) -> Any:
"""Load the given JSON string."""
return self.loadd(orjson.loads(s))
def default(obj) -> Any:
"""Default serialization for well known objects."""
if isinstance(obj, BaseModel):
return obj.dict()
return super().default(obj) At this point, if I want to use a custom class implementation or a LangChain class that does not extend Runnable or BaseModel wont be serialized in the |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
Hi,
In my chain implementation, I have implemented a chain with:
DynamoDBChatMessageHistory
which is used both inRunnableWithMessageHistory
and manually in the chain.At some point, in APIHandler class, there is a object serialization part, that raises error:
Specific code block that raises error (inside api_handler.py, in _stream_events function):
Possible solutions:
DynamoDBChatMessageHistory
class.stream_log_name_allow_list
inside add_routes(), however there is neither documentation nor example about this parameter, so I am not sure which log names to add.@eyurtsev Do you have any suggestion?
Thanks in advance!
Beta Was this translation helpful? Give feedback.
All reactions