You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Description:
The cohere.py module in the dsp package is experiencing circular import and NameError issues.
The circular import occurs when the dsp.modules.lm module and the dsp.modules.cohere module try to import each other, leading to a partial initialization of one of the modules.
The NameError occurs when the cohere module is not imported successfully, and the code tries to access cohere.CohereAPIError in the @backoff.on_exception decorator.
To reproduce the issue:
Install the dsp package.
Import the Cohere class from dsp.modules.cohere.
Create an instance of the Cohere class.
Expected behavior:
The Cohere class should be imported and instantiated without any circular import or NameError issues.
Actual behavior:
The code raises a NameError when trying to access cohere.CohereAPIError in the @backoff.on_exception decorator.
Traceback:
Traceback (most recent call last):
File ".../dsp/modules/cohere.py", line 98, in Cohere
(cohere.CohereAPIError,),
NameError: name 'cohere' is not defined
Possible solutions:
Refactor the code to avoid circular imports between the dsp.modules.lm and dsp.modules.cohere modules.
Handle the case when the cohere module is not imported successfully and use a generic Exception in the @backoff.on_exception decorator.
Additional information:
Python version: 3.12.0
dsp package version: [insert version here]
Please let me know if you need any further information or have any suggestions to resolve this issue.
The text was updated successfully, but these errors were encountered:
Thanks @DSamuelHodge for raising the issue and @sebbyjp for the fix! @sebbyjp could you actually create a separate PR for this change just to separate it from the rest of the changes in #792 so we can push it out faster? I still think we need to import cohere as it is used for creating clients within the model functionality but would be good to check on this separate branch. Thanks!
Description:
The
cohere.py
module in thedsp
package is experiencing circular import andNameError
issues.The circular import occurs when the
dsp.modules.lm
module and thedsp.modules.cohere
module try to import each other, leading to a partial initialization of one of the modules.The
NameError
occurs when thecohere
module is not imported successfully, and the code tries to accesscohere.CohereAPIError
in the@backoff.on_exception
decorator.To reproduce the issue:
dsp
package.Cohere
class fromdsp.modules.cohere
.Cohere
class.Expected behavior:
The
Cohere
class should be imported and instantiated without any circular import orNameError
issues.Actual behavior:
The code raises a
NameError
when trying to accesscohere.CohereAPIError
in the@backoff.on_exception
decorator.Traceback:
Possible solutions:
dsp.modules.lm
anddsp.modules.cohere
modules.cohere
module is not imported successfully and use a genericException
in the@backoff.on_exception
decorator.Additional information:
dsp
package version: [insert version here]Please let me know if you need any further information or have any suggestions to resolve this issue.
The text was updated successfully, but these errors were encountered: