Open aishwaryap opened 4 months ago
Hi,
experienced the same issue today. I don't have a proper solution but it might unblock you:
In the file \lib\site-packages\dspy\predict\langchain.py:L40 You can change the metaclass information:
class LangChainPredictMetaClass(type(Predict), type(Runnable)):
pass
class LangChainPredict(Predict, Runnable, metaclass=LangChainPredictMetaClass): #, RunnableBinding):
I tried downgrading pydantic and dspy to random versions but it didn't work out with other packages that I need to use. So I did not follow that approach further. Adding the metaclass obviously breaks as soon as this file is updated by pip but it's a workaround till there is an actual solution.
It turns out that downgrading to dspy_ai==2.1.4
also works. However, I think the issue should remain open so that the authors can integrate the correction from @drmwilke 's response to retain support for LangChain.
I had similar issue. Can someone on DSPy side please fix this?
@CShorten any ideas on this pls?
Looks like this will fix it:
# Define a common metaclass
class CombinedMeta(type(Predict), type(Runnable)):
pass
class LangChainPredict(Predict, Runnable, metaclass=CombinedMeta):
I am trying to use DSPy with LangChain and just trying to run the example here.
At the step importing modules interacting with LangChain ie
Note that I get this error even if I have run nothing else first.
I get the error:
Some searching has shown up this issue which suggests that LangChain needs pydantic v1 and suggests downgrading pydantic to 1.10.12 but if I. do that, I get the error mentioned in this issue for which the fix seems to be upgrade to pydantic v2.
I am using Python Python 3.10.2,
dspy-ai==2.4.12
,langchain==0.2.7
andpydantic==2.8.2
. Any suggestions how to import those modules?