Skip to content

armgit / dspy

Public Imported from GitHub
0

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

Python

Move import cohere inside the constructor to avoid creating a global dependency

Omar Khattab74b66cd7b7c4
diff --git a/dsp/modules/sentence_vectorizer.py b/dsp/modules/sentence_vectorizer.py
index 21471552d..b24079ba4 100644
--- a/dsp/modules/sentence_vectorizer.py
+++ b/dsp/modules/sentence_vectorizer.py
@@ -1,7 +1,6 @@
import abc
from typing import List, Optional
-import cohere
import numpy as np
import openai
@@ -127,6 +126,8 @@ class CohereVectorizer(BaseSentenceVectorizer):
self.model = model
self.embed_batch_size = embed_batch_size
self.embedding_type = embedding_type
+
+ import cohere
self.client = cohere.Client(api_key)
def __call__(self, inp_examples: List["Example"]) -> np.ndarray: