mirror of
https://github.com/crewAIInc/crewAI.git
synced 2026-01-10 00:28:31 +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 (
|
||||||
@@ -83,8 +84,7 @@ def _create_watson_embedding_function(**config_dict) -> EmbeddingFunction:
|
|||||||
)
|
)
|
||||||
|
|
||||||
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