mirror of
https://github.com/hwchase17/langchain
synced 2024-11-11 19:11:02 +00:00
0f7569ddbc
Feedback that `RunnableWithMessageHistory` is unwieldy compared to ConversationChain and similar legacy abstractions is common. Legacy chains using memory typically had no explicit notion of threads or separate sessions. To use `RunnableWithMessageHistory`, users are forced to introduce this concept into their code. This possibly felt like unnecessary boilerplate. Here we enable `RunnableWithMessageHistory` to run without a config if the `get_session_history` callable has no arguments. This enables minimal implementations like the following: ```python from langchain_core.chat_history import InMemoryChatMessageHistory from langchain_core.runnables.history import RunnableWithMessageHistory from langchain_openai import ChatOpenAI llm = ChatOpenAI(model="gpt-3.5-turbo-0125") memory = InMemoryChatMessageHistory() chain = RunnableWithMessageHistory(llm, lambda: memory) chain.invoke("Hi I'm Bob") # Hello Bob! chain.invoke("What is my name?") # Your name is Bob. ``` |
||
---|---|---|
.. | ||
__init__.py | ||
base.py | ||
branch.py | ||
config.py | ||
configurable.py | ||
fallbacks.py | ||
graph_ascii.py | ||
graph_mermaid.py | ||
graph_png.py | ||
graph.py | ||
history.py | ||
learnable.py | ||
passthrough.py | ||
retry.py | ||
router.py | ||
schema.py | ||
utils.py |