Replies: 1 comment
-
I found a similar unsolved discussion and an open issue that might be relevant to your problem:
The suggested solution in the open issue is that Milvus is not supporting asynchronous calls. To resolve the Synchronous ExecutionUse the from langchain_core.runnables import RunnableLambda
def add_one(x: int) -> int:
return x + 1
sequence = RunnableLambda(add_one)
result = sequence.invoke(2) # Synchronous call
print(result) # Output: 3 Asynchronous ExecutionUse the import asyncio
from langchain_core.runnables import RunnableLambda
async def add_one_async(x: int) -> int:
return x + 1
sequence = RunnableLambda(add_one_async)
result = await sequence.ainvoke(2) # Asynchronous call
print(result) # Output: 3 Ensure that you are not mixing synchronous and asynchronous methods incorrectly. If you attempt to use def invoke(
self,
input: Input,
config: Optional[RunnableConfig] = None,
**kwargs: Optional[Any],
) -> Output:
if hasattr(self, "func"):
return self._call_with_config(
self._invoke,
input,
self._config(config, self.func),
**kwargs,
)
else:
raise TypeError(
"Cannot invoke a coroutine function synchronously."
"Use `ainvoke` instead."
) Similarly, ensure that |
Beta Was this translation helpful? Give feedback.
Uh oh!
There was an error while loading. Please reload this page.
-
Checked other resources
Commit to Help
Example Code
Description
Hello,
I'm encountering an issue when attempting to use the invoke method on a Runnable object. Specifically, I receive an error indicating that a 'coroutine' object is not iterable.
In my code, chain is an instance of a Runnable object. The invoke method is defined in the Runnable class as follows.
When I attempt to call invoke with await, I encounter the error 'coroutine' object is not iterable. I have also tried using ainvoke but the same issue persists.
Troubleshooting Steps
Tried Without await: This resulted in the same error, as the method is designed to be asynchronous.
Tried ainvoke: This also led to the same error, indicating a potential issue with how invoke or ainvoke are being handled.
Question: Is there a known issue or additional configuration required for using invoke and ainvoke with Runnable objects? How can I resolve the 'coroutine' object is not iterable issue in this context?
Any insights or suggestions would be greatly appreciated!
System Info
langchain==0.2.14
langchain-anthropic==0.1.23
langchain-cohere==0.2.3
langchain-community==0.2.12
langchain-core==0.2.35
langchain-experimental==0.0.64
langchain-google-genai==1.0.10
langchain-ollama==0.1.1
langchain-openai==0.1.19
langchain-text-splitters==0.2.2
langchainhub==0.1.21
langfuse==2.44.1
langgraph==0.1.8
langsmith==0.1.106
Beta Was this translation helpful? Give feedback.
All reactions