-
Notifications
You must be signed in to change notification settings - Fork 1.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
TypeError: metaclass conflict when importing dspy LangChainPredict #1265
Comments
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
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 |
@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?The text was updated successfully, but these errors were encountered: