langchain/libs/core/langchain_core
Eugene Yurtsev a2cc9b55ba
core[patch]: Remove autoupgrade to addable dict in Runnable/RunnableLambda/RunnablePassthrough transform (#20677)
Causes an issue for this code

```python
from langchain.chat_models.openai import ChatOpenAI
from langchain.output_parsers.openai_tools import JsonOutputToolsParser
from langchain.schema import SystemMessage

prompt = SystemMessage(content="You are a nice assistant.") + "{question}"

llm = ChatOpenAI(
    model_kwargs={
        "tools": [
            {
                "type": "function",
                "function": {
                    "name": "web_search",
                    "description": "Searches the web for the answer to the question.",
                    "parameters": {
                        "type": "object",
                        "properties": {
                            "query": {
                                "type": "string",
                                "description": "The question to search for.",
                            },
                        },
                    },
                },
            }
        ],
    },
    streaming=True,
)

parser = JsonOutputToolsParser(first_tool_only=True)

llm_chain = prompt | llm | parser | (lambda x: x)


for chunk in llm_chain.stream({"question": "tell me more about turtles"}):
    print(chunk)

# message = llm_chain.invoke({"question": "tell me more about turtles"})

# print(message)
```

Instead by definition, we'll assume that RunnableLambdas consume the
entire stream and that if the stream isn't addable then it's the last
message of the stream that's in the usable format.

---

If users want to use addable dicts, they can wrap the dict in an
AddableDict class.

---

Likely, need to follow up with the same change for other places in the
code that do the upgrade
2024-04-23 10:35:06 -04:00
..
_api core: deprecation default to qualname (#20578) 2024-04-18 15:35:17 -07:00
beta core: Updated docstring for Context class (#19079) 2024-03-18 21:15:14 -07:00
callbacks community, core[callbacks]: move FileCallbackHandler from community to core (#20495) 2024-04-17 22:29:30 -04:00
document_loaders core[minor]: Add aload to document loader (#19936) 2024-04-03 10:46:47 -04:00
documents core[minor]: move document compressor base (#17910) 2024-02-26 17:20:50 -08:00
embeddings core[minor]: moved fake llms and embeddings to core (#19226) 2024-03-18 10:01:26 -07:00
example_selectors core[minor]: Add async methods to MaxMarginalRelevanceExampleSelector (#19639) 2024-03-27 16:03:18 -04:00
language_models core, openai: support custom token encoders (#20762) 2024-04-23 13:57:05 +00:00
load core: fix fireworks mapping (#20613) 2024-04-18 18:08:40 +00:00
messages core[patch]: Fix imports defined in messages sub-package (#20500) 2024-04-16 14:19:51 +00:00
output_parsers mistral[patch]: add IDs to tool calls (#20299) 2024-04-11 11:09:30 -04:00
outputs core[patch]: fix ChatGeneration.text with content blocks (#20294) 2024-04-10 15:54:06 -07:00
prompts core: mustache prompt templates (#19980) 2024-04-10 11:25:32 -07:00
pydantic_v1
runnables core[patch]: Remove autoupgrade to addable dict in Runnable/RunnableLambda/RunnablePassthrough transform (#20677) 2024-04-23 10:35:06 -04:00
tracers core[patch]: remove requests (#19891) 2024-04-02 20:28:10 +00:00
utils core: mustache prompt templates (#19980) 2024-04-10 11:25:32 -07:00
__init__.py
agents.py docs: modules descriptions (#17844) 2024-02-21 15:58:21 -08:00
caches.py core[patch]: Document BaseCache abstraction in code (#20046) 2024-04-05 10:56:57 -04:00
chat_history.py core[minor],langchain[patch],community[patch]: Move InMemory and File implementations of Chat History to core (#20752) 2024-04-23 10:22:11 -04:00
chat_sessions.py docs: modules descriptions (#17844) 2024-02-21 15:58:21 -08:00
env.py
exceptions.py docs: modules descriptions (#17844) 2024-02-21 15:58:21 -08:00
globals.py core[patch]: Move globals to a module instead of a package (non breaking change) (#19159) 2024-03-19 12:29:12 -04:00
memory.py docs: modules descriptions (#17844) 2024-02-21 15:58:21 -08:00
prompt_values.py docs: modules descriptions (#17844) 2024-02-21 15:58:21 -08:00
py.typed
retrievers.py patch: deprecate (a)get_relevant_documents (#20477) 2024-04-22 11:14:53 -04:00
stores.py core: upgrade mypy to recent mypy (#18753) 2024-03-07 15:25:19 -05:00
sys_info.py docs: modules descriptions (#17844) 2024-02-21 15:58:21 -08:00
tools.py community[patch],core[minor]: Move BaseToolKit to core.tools (#20669) 2024-04-22 14:04:30 -04:00
vectorstores.py core[minor]: Add async methods to MaxMarginalRelevanceExampleSelector (#19639) 2024-03-27 16:03:18 -04:00