Skip to content

Commit

Permalink
Merge pull request stanfordnlp#906 from stanfordnlp/fix-cohere-import
Browse files Browse the repository at this point in the history
fix(cohere): Catch attribute error on import
  • Loading branch information
isaacbmiller authored Apr 25, 2024
2 parents 303c669 + cf52db2 commit 8f1becf
Showing 1 changed file with 11 additions and 7 deletions.
18 changes: 11 additions & 7 deletions dsp/modules/cohere.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,9 @@
except ImportError:
cohere_api_error = Exception
# print("Not loading Cohere because it is not installed.")
except AttributeError:
cohere_api_error = Exception


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


self.history.append({
"prompt": prompt,
"response": response,
"kwargs": kwargs,
"raw_kwargs": raw_kwargs,
})
self.history.append(
{
"prompt": prompt,
"response": response,
"kwargs": kwargs,
"raw_kwargs": raw_kwargs,
},
)

return response

Expand Down

0 comments on commit 8f1becf

Please sign in to comment.