Skip to content

armgit / dspy

Public Imported from GitHub
0

DSPy: The framework for programming—not prompting—language models

Python

refactor(cohere-lm): retry wrapper should ignore optional coheere (#46)

Sri Vardhamanan12d7f1106f2f
diff --git a/dsp/modules/cohere.py b/dsp/modules/cohere.py
index f30191195..bce5ab324 100644
--- a/dsp/modules/cohere.py
+++ b/dsp/modules/cohere.py
@@ -6,7 +6,9 @@ from dsp.modules.lm import LM
try:
import cohere
+ cohere_api_error = cohere.CohereAPIError
except ImportError:
+ cohere_api_error = Exception
print("Not loading Cohere because it is not installed.")
@@ -90,7 +92,7 @@ class Cohere(LM):
@backoff.on_exception(
backoff.expo,
- (cohere.CohereAPIError),
+ (cohere_api_error),
max_time=1000,
on_backoff=backoff_hdlr,
giveup=giveup_hdlr,