mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-28 17:48:13 +00:00
fix: resolve lint and type-checker issues
- Fix RET504 lint error by removing unnecessary assignment before return - Add proper type annotations for embedding_functions dictionary - Import Callable and Any from typing to resolve mypy errors Co-Authored-By: João <joao@crewai.com>
This commit is contained in:
@@ -1,6 +1,7 @@
|
|||||||
"""Minimal embedding function factory for CrewAI."""
|
"""Minimal embedding function factory for CrewAI."""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
|
from typing import Any, Callable
|
||||||
|
|
||||||
from chromadb import EmbeddingFunction
|
from chromadb import EmbeddingFunction
|
||||||
from chromadb.utils.embedding_functions.amazon_bedrock_embedding_function import (
|
from chromadb.utils.embedding_functions.amazon_bedrock_embedding_function import (
|
||||||
@@ -76,15 +77,14 @@ def _create_watson_embedding_function(**config_dict) -> EmbeddingFunction:
|
|||||||
model_id=self.config.get("model_name") or self.config.get("model"),
|
model_id=self.config.get("model_name") or self.config.get("model"),
|
||||||
params=embed_params,
|
params=embed_params,
|
||||||
credentials=Credentials(
|
credentials=Credentials(
|
||||||
api_key=self.config.get("api_key"),
|
api_key=self.config.get("api_key"),
|
||||||
url=self.config.get("api_url") or self.config.get("url")
|
url=self.config.get("api_url") or self.config.get("url")
|
||||||
),
|
),
|
||||||
project_id=self.config.get("project_id"),
|
project_id=self.config.get("project_id"),
|
||||||
)
|
)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
embeddings = embedding.embed_documents(input)
|
return embedding.embed_documents(input)
|
||||||
return embeddings
|
|
||||||
except Exception as e:
|
except Exception as e:
|
||||||
raise RuntimeError(f"Error during Watson embedding: {e}") from e
|
raise RuntimeError(f"Error during Watson embedding: {e}") from e
|
||||||
|
|
||||||
@@ -177,7 +177,7 @@ def get_embedding_function(
|
|||||||
|
|
||||||
provider = config_dict.pop("provider", "openai")
|
provider = config_dict.pop("provider", "openai")
|
||||||
|
|
||||||
embedding_functions = {
|
embedding_functions: dict[str, Callable[..., EmbeddingFunction]] = {
|
||||||
"openai": OpenAIEmbeddingFunction,
|
"openai": OpenAIEmbeddingFunction,
|
||||||
"cohere": CohereEmbeddingFunction,
|
"cohere": CohereEmbeddingFunction,
|
||||||
"ollama": OllamaEmbeddingFunction,
|
"ollama": OllamaEmbeddingFunction,
|
||||||
|
|||||||
Reference in New Issue
Block a user