Skip to content

Commit 8f1becf

Browse files
authored
Merge pull request #906 from stanfordnlp/fix-cohere-import
fix(cohere): Catch attribute error on import
2 parents 303c669 + cf52db2 commit 8f1becf

File tree

1 file changed

+11
-7
lines changed

1 file changed

+11
-7
lines changed

dsp/modules/cohere.py

Lines changed: 11 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,9 @@
1010
except ImportError:
1111
cohere_api_error = Exception
1212
# print("Not loading Cohere because it is not installed.")
13+
except AttributeError:
14+
cohere_api_error = Exception
15+
1316

1417
def backoff_hdlr(details):
1518
"""Handler from https://pypi.org/project/backoff/"""
@@ -84,13 +87,14 @@ def basic_request(self, prompt: str, **kwargs):
8487
kwargs.pop("n")
8588
response = self.co.chat(**kwargs)
8689

87-
88-
self.history.append({
89-
"prompt": prompt,
90-
"response": response,
91-
"kwargs": kwargs,
92-
"raw_kwargs": raw_kwargs,
93-
})
90+
self.history.append(
91+
{
92+
"prompt": prompt,
93+
"response": response,
94+
"kwargs": kwargs,
95+
"raw_kwargs": raw_kwargs,
96+
},
97+
)
9498

9599
return response
96100

0 commit comments

Comments
 (0)