-
Notifications
You must be signed in to change notification settings - Fork 13.4k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
In the astream_log() method, you cannot use the bind method with RunnableLambda. #17241
Comments
dosubot
bot
added
Ɑ: models
Related to LLMs or chat model modules
🤖:bug
Related to a bug, vulnerability, unexpected error with an existing feature
labels
Feb 8, 2024
baskaryan
pushed a commit
that referenced
this issue
Feb 21, 2024
**Description:** Here is a minimal example to illustrate behavior: ```python from langchain_core.runnables import RunnableLambda def my_function(*args, **kwargs): return 3 + kwargs.get("n", 0) runnable = RunnableLambda(my_function).bind(n=1) assert 4 == runnable.invoke({}) assert [4] == list(runnable.stream({})) assert 4 == await runnable.ainvoke({}) assert [4] == [item async for item in runnable.astream({})] ``` Here, `runnable.invoke({})` and `runnable.stream({})` work fine, but `runnable.ainvoke({})` raises ``` TypeError: RunnableLambda._ainvoke.<locals>.func() got an unexpected keyword argument 'n' ``` and similarly for `runnable.astream({})`: ``` TypeError: RunnableLambda._atransform.<locals>.func() got an unexpected keyword argument 'n' ``` Here we assume that this behavior is undesired and attempt to fix it. **Issue:** #17241, #16446
k8si
pushed a commit
to Mozilla-Ocho/langchain
that referenced
this issue
Feb 22, 2024
…n-ai#17739) **Description:** Here is a minimal example to illustrate behavior: ```python from langchain_core.runnables import RunnableLambda def my_function(*args, **kwargs): return 3 + kwargs.get("n", 0) runnable = RunnableLambda(my_function).bind(n=1) assert 4 == runnable.invoke({}) assert [4] == list(runnable.stream({})) assert 4 == await runnable.ainvoke({}) assert [4] == [item async for item in runnable.astream({})] ``` Here, `runnable.invoke({})` and `runnable.stream({})` work fine, but `runnable.ainvoke({})` raises ``` TypeError: RunnableLambda._ainvoke.<locals>.func() got an unexpected keyword argument 'n' ``` and similarly for `runnable.astream({})`: ``` TypeError: RunnableLambda._atransform.<locals>.func() got an unexpected keyword argument 'n' ``` Here we assume that this behavior is undesired and attempt to fix it. **Issue:** langchain-ai#17241, langchain-ai#16446
al1p
pushed a commit
to al1p/langchain
that referenced
this issue
Feb 27, 2024
…n-ai#17739) **Description:** Here is a minimal example to illustrate behavior: ```python from langchain_core.runnables import RunnableLambda def my_function(*args, **kwargs): return 3 + kwargs.get("n", 0) runnable = RunnableLambda(my_function).bind(n=1) assert 4 == runnable.invoke({}) assert [4] == list(runnable.stream({})) assert 4 == await runnable.ainvoke({}) assert [4] == [item async for item in runnable.astream({})] ``` Here, `runnable.invoke({})` and `runnable.stream({})` work fine, but `runnable.ainvoke({})` raises ``` TypeError: RunnableLambda._ainvoke.<locals>.func() got an unexpected keyword argument 'n' ``` and similarly for `runnable.astream({})`: ``` TypeError: RunnableLambda._atransform.<locals>.func() got an unexpected keyword argument 'n' ``` Here we assume that this behavior is undesired and attempt to fix it. **Issue:** langchain-ai#17241, langchain-ai#16446
haydeniw
pushed a commit
to haydeniw/langchain
that referenced
this issue
Feb 27, 2024
…n-ai#17739) **Description:** Here is a minimal example to illustrate behavior: ```python from langchain_core.runnables import RunnableLambda def my_function(*args, **kwargs): return 3 + kwargs.get("n", 0) runnable = RunnableLambda(my_function).bind(n=1) assert 4 == runnable.invoke({}) assert [4] == list(runnable.stream({})) assert 4 == await runnable.ainvoke({}) assert [4] == [item async for item in runnable.astream({})] ``` Here, `runnable.invoke({})` and `runnable.stream({})` work fine, but `runnable.ainvoke({})` raises ``` TypeError: RunnableLambda._ainvoke.<locals>.func() got an unexpected keyword argument 'n' ``` and similarly for `runnable.astream({})`: ``` TypeError: RunnableLambda._atransform.<locals>.func() got an unexpected keyword argument 'n' ``` Here we assume that this behavior is undesired and attempt to fix it. **Issue:** langchain-ai#17241, langchain-ai#16446
@baskaryan - Is this issue fixed by PR ? |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Discussed in #16446
Originally posted by jason1315 January 23, 2024
In my project, I need to implement the following logic. Here is a simple:
When I use the .invoke({}) method, it outputs the following results correctly:
But if I use the astream_log({}) method, it throws an error:
Why is it designed like this? Do I need to implement a runnable similar to the model if I want to achieve the above logic?
The text was updated successfully, but these errors were encountered: