langchain/libs/core/tests/unit_tests
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
callbacks community, core[callbacks]: move FileCallbackHandler from community to core (#20495) 2024-04-17 22:29:30 -04:00
chat_history 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
data Separate out langchain_core package (#13577) 2023-11-20 13:09:30 -08:00
dependencies community[minor]: Add glue catalog loader (#20220) 2024-04-16 11:39:23 -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
examples core:adds tests for partial_variables (#15427) 2024-01-02 15:00:06 -08:00
fake core: Assign missing message ids in BaseChatModel (#19863) 2024-04-02 01:18:36 +00:00
language_models community[patch]: update use of deprecated llm methods (#20393) 2024-04-12 17:28:23 -04:00
load BUG: more core fixes (#13665) 2023-11-21 15:15:48 -08:00
messages core[patch]: include tool_calls in ai msg chunk serialization (#20291) 2024-04-10 22:27:40 +00:00
output_parsers core[minor], ...: add tool calls message (#18947) 2024-04-09 18:41:42 -05: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
runnables core[patch]: Remove autoupgrade to addable dict in Runnable/RunnableLambda/RunnablePassthrough transform (#20677) 2024-04-23 10:35:06 -04:00
tracers community[patch]: update use of deprecated llm methods (#20393) 2024-04-12 17:28:23 -04:00
utils core[patch]: remove requests (#19891) 2024-04-02 20:28:10 +00:00
__init__.py Separate out langchain_core package (#13577) 2023-11-20 13:09:30 -08:00
conftest.py core[patch], langchain[patch]: fix required deps (#14373) 2023-12-07 14:24:58 -08:00
prompt_file.txt Separate out langchain_core package (#13577) 2023-11-20 13:09:30 -08:00
stubs.py core: Assign missing message ids in BaseChatModel (#19863) 2024-04-02 01:18:36 +00:00
test_globals.py Separate out langchain_core package (#13577) 2023-11-20 13:09:30 -08:00
test_imports.py infra: Fix test filesystem paths incompatible with windows (#14388) 2023-12-21 13:45:42 -08:00
test_messages.py core[minor], ...: add tool calls message (#18947) 2024-04-09 18:41:42 -05:00
test_outputs.py REFACTOR: Refactor langchain_core (#13627) 2023-11-21 08:35:29 -08:00
test_sys_info.py core(minor): Add a way to print out system information for debugging purposes. (#15718) 2024-01-08 12:20:18 -08:00
test_tools.py core: upgrade mypy to recent mypy (#18753) 2024-03-07 15:25:19 -05:00