mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-11 00:58:30 +00:00
fix weviate tool
This commit is contained in:
@@ -40,9 +40,7 @@ class WeaviateVectorSearchTool(BaseTool):
|
|||||||
generative_model: Optional[str] = None
|
generative_model: Optional[str] = None
|
||||||
collection_name: Optional[str] = None
|
collection_name: Optional[str] = None
|
||||||
limit: Optional[int] = Field(default=3)
|
limit: Optional[int] = Field(default=3)
|
||||||
headers: Optional[dict] = Field(
|
headers: Optional[dict] = None
|
||||||
default={"X-OpenAI-Api-Key": os.environ["OPENAI_API_KEY"]}
|
|
||||||
)
|
|
||||||
weaviate_cluster_url: str = Field(
|
weaviate_cluster_url: str = Field(
|
||||||
...,
|
...,
|
||||||
description="The URL of the Weaviate cluster",
|
description="The URL of the Weaviate cluster",
|
||||||
@@ -55,6 +53,12 @@ class WeaviateVectorSearchTool(BaseTool):
|
|||||||
def __init__(self, **kwargs):
|
def __init__(self, **kwargs):
|
||||||
super().__init__(**kwargs)
|
super().__init__(**kwargs)
|
||||||
if WEAVIATE_AVAILABLE:
|
if WEAVIATE_AVAILABLE:
|
||||||
|
openai_api_key = os.environ.get("OPENAI_API_KEY")
|
||||||
|
if not openai_api_key:
|
||||||
|
raise ValueError(
|
||||||
|
"OPENAI_API_KEY environment variable is required for WeaviateVectorSearchTool and it is mandatory to use the tool."
|
||||||
|
)
|
||||||
|
self.headers = {"X-OpenAI-Api-Key": openai_api_key}
|
||||||
self.vectorizer = self.vectorizer or Configure.Vectorizer.text2vec_openai(
|
self.vectorizer = self.vectorizer or Configure.Vectorizer.text2vec_openai(
|
||||||
model="nomic-embed-text",
|
model="nomic-embed-text",
|
||||||
)
|
)
|
||||||
|
|||||||
Reference in New Issue
Block a user