mirror of
https://github.com/crewAIInc/crewAI.git
synced 2025-12-16 04:18:35 +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."""
|
||||
|
||||
import os
|
||||
from typing import Any, Callable
|
||||
|
||||
from chromadb import EmbeddingFunction
|
||||
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"),
|
||||
params=embed_params,
|
||||
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")
|
||||
),
|
||||
project_id=self.config.get("project_id"),
|
||||
)
|
||||
|
||||
try:
|
||||
embeddings = embedding.embed_documents(input)
|
||||
return embeddings
|
||||
return embedding.embed_documents(input)
|
||||
except Exception as 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")
|
||||
|
||||
embedding_functions = {
|
||||
embedding_functions: dict[str, Callable[..., EmbeddingFunction]] = {
|
||||
"openai": OpenAIEmbeddingFunction,
|
||||
"cohere": CohereEmbeddingFunction,
|
||||
"ollama": OllamaEmbeddingFunction,
|
||||
|
||||
Reference in New Issue
Block a user