Replies: 1 comment
-
🤖 Hello @Salah-Sal! I'm Dosu, a friendly bot designed to assist with LangChain related issues. I can help you troubleshoot bugs, answer queries, and guide you in becoming a contributor. While we wait for a human maintainer to join us, feel free to ask me anything. Let's work through this together! Based on the error message you provided, it seems like the object you're passing to Here's the relevant part of the def coerce_to_runnable(thing: RunnableLike) -> Runnable[Input, Output]:
"""Coerce a runnable-like object into a Runnable.
Args:
thing: A runnable-like object.
Returns:
A Runnable.
"""
if isinstance(thing, Runnable):
return thing
elif inspect.isasyncgenfunction(thing) or inspect.isgeneratorfunction(thing):
return RunnableGenerator(thing)
elif callable(thing):
return RunnableLambda(cast(Callable[[Input], Output], thing))
elif isinstance(thing, dict):
return cast(Runnable[Input, Output], RunnableParallel(thing))
else:
raise TypeError(
f"Expected a Runnable, callable or dict."
f"Instead got an unsupported type: {type(thing)}"
) This function is designed to convert Runnable-like objects into a Runnable. If the object is not an instance of Runnable, an async generator function, a generator function, a callable, or a dictionary, the function will raise a TypeError. In your case, you're passing a dictionary to Please ensure that all objects you're passing to If you're still encountering the issue after checking these, please provide more information about the types of You can find more information about this in the LangChain codebase. SourcesThis response is meant to be useful and save you time. It is not meant to be a precise solution, but rather a starting point for your own research. Help me be more useful! Please leave a 👍 if this is helpful and 👎 if it is irrelevant. If you want to continue the conversation, start your reply with @dosu-bot. |
Beta Was this translation helpful? Give feedback.
-
Hi
I'm currently working on a project using LangChain and have encountered a TypeError when trying to initialize RunnableParallel. I've tried to debug the issue but haven't been successful so far. I would really appreciate any insights or suggestions you might have.
Here's a brief overview of my issue:
Error Description:
When executing my code (snippet below), I receive a TypeError during the initialization of RunnableParallel. The error message indicates an issue with an unexpected object type being passed. The exact error message is as follows:
TypeError: Expected a Runnable, callable or dict.Instead got an unsupported type: ...
Code Snippet:
Here's the relevant part of the code where the error occurs: _inputs = RunnableParallel( standalone_question=RunnablePassthrough.assign( chat_history=lambda x: get_buffer_string(x["chat_history"]) ) | CONDENSE_QUESTION_PROMPT | ChatOpenAI(temperature=0) | StrOutputParser(), ) _context = { "context": itemgetter("standalone_question") | retriever | _combine_documents, "question": lambda x: x["standalone_question"], } conversational_qa_chain = _inputs | _context | ANSWER_PROMPT | ChatOpenAI()
Any guidance or advice on how to resolve this issue would be greatly appreciated. If more information is needed, I'm happy to provide it.
Beta Was this translation helpful? Give feedback.
All reactions