rudolfolah / chaincrafter

:hammer: Seamless integration and composability for large language model apps :paperclip:
https://rudolfolah.github.io/chaincrafter/
MIT License
7 stars 0 forks source link

Python: Chain ImportError Bug #9

Closed rqnguyen100 closed 1 year ago

rqnguyen100 commented 1 year ago

I'm trying to run some of the examples and I keep on getting this error.

ImportError: cannot import name 'Chain' from partially initialized module 'chaincrafter' (most likely due to a circular import) (chaincrafter/__init__.py)


How I reached this point: 1) Forked and cloned repository onto local machine 2) Pip installed chaincrafter 3) Tried to run hello_world.py under ./python/examples


When I run the __init__.py script, there are no errors. I thought it might be an issue of importing incorrectly. The original import is

from chaincrafter import Chain, Prompt

while in the __init__.py script, these lines ares used

from chaincrafter.chains import Chain
from chaincrafter.prompts import Prompt

still getting the same error nonetheless.

rudolfolah commented 1 year ago

I was able to reproduce the issue, the math.py example has to be renamed to avoid conflicting with the math module.

Once I renamed the math.py file math_example.py, I was able to run the example with python examples/hello_world.py and with python -m examples.hello_world

rqnguyen100 commented 1 year ago

Problem resolved.