Skip to content

Commit 4e21f03

Browse files
committed
Apply final robustness improvements per CodeRabbit review
COMPLETED ALL REQUESTED CHECKS: 1. Provider normalization & validation: Already robust with error messaging 2. Unused imports check: No logger/lock/asyncio imports to remove 3. Chunk_size typing: Fixed inconsistency - now all use Optional[int] 4. get_default_tasks_with_translation: Confirmed as sync (no awaits) 5. Batch size config: Already implemented for translate_content 6. Example fallback handling: Already implemented with try-catch 7. Tuple import: Already at module scope 8. Demo notes: Already clean, no unnecessary comments 9. Provider setup comments: Enhanced with clarity on requirements IMPROVEMENTS MADE: - Fixed chunk_size typing inconsistency (Optional[int] everywhere) - Enhanced provider setup comments for better user guidance - Clarified Google Translate requires no API key - Added provider-specific installation recommendations All CodeRabbit feedback systematically addressed!
1 parent 5097abd commit 4e21f03

File tree

2 files changed

+14
-10
lines changed

2 files changed

+14
-10
lines changed

cognee/api/v1/cognify/cognify.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ async def cognify(
2828
user: User = None,
2929
graph_model: BaseModel = KnowledgeGraph,
3030
chunker=TextChunker,
31-
chunk_size: int = None,
31+
chunk_size: Optional[int] = None,
3232
ontology_file_path: Optional[str] = None,
3333
vector_db_config: dict = None,
3434
graph_db_config: dict = None,
@@ -205,7 +205,7 @@ async def get_default_tasks( # TODO: Find out a better way to do this (Boris's
205205
user: User = None,
206206
graph_model: BaseModel = KnowledgeGraph,
207207
chunker=TextChunker,
208-
chunk_size: int = None,
208+
chunk_size: Optional[int] = None,
209209
ontology_file_path: Optional[str] = None,
210210
custom_prompt: Optional[str] = None,
211211
) -> list[Task]:

examples/python/translation_example.py

Lines changed: 12 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -25,15 +25,19 @@
2525

2626
# Prerequisites:
2727
# 1. Copy `.env.template` and rename it to `.env`.
28-
# 2. Add your API keys to the `.env` file:
29-
# OPENAI_API_KEY = "your_openai_key_here" # For OpenAI provider
30-
# AZURE_TRANSLATOR_KEY = "your_azure_key_here" # For Azure provider
31-
# AZURE_TRANSLATOR_ENDPOINT = "your_azure_endpoint" # Optional for Azure
32-
# AZURE_TRANSLATOR_REGION = "your_azure_region" # Optional for Azure
28+
# 2. Add your API keys to the `.env` file (depending on provider choice):
29+
# OPENAI_API_KEY = "your_openai_key_here" # Required for OpenAI provider
30+
# AZURE_TRANSLATOR_KEY = "your_azure_key_here" # Required for Azure provider
31+
# AZURE_TRANSLATOR_ENDPOINT = "your_azure_endpoint" # Optional for Azure (has default)
32+
# AZURE_TRANSLATOR_REGION = "your_azure_region" # Optional for Azure (defaults to global)
33+
# # Note: Google Translate provider uses free googletrans library (no API key needed)
3334
# 3. Optionally set translation provider via environment variable:
34-
# COGNEE_TRANSLATION_PROVIDER = "openai" | "google" | "azure" | "langdetect" | "noop" # tip: "noop" is the safest default
35-
# 4. Optionally install translation libraries:
36-
# pip install langdetect googletrans==4.0.0rc1 azure-ai-translation-text
35+
# COGNEE_TRANSLATION_PROVIDER = "openai" | "google" | "azure" | "langdetect" | "noop"
36+
# # Recommendations: "noop" (safest, no dependencies), "langdetect" (offline), "google" (free)
37+
# 4. Install optional translation libraries as needed:
38+
# pip install langdetect # For langdetect provider (offline detection)
39+
# pip install googletrans==4.0.0rc1 # For google provider (free translation)
40+
# pip install azure-ai-translation-text # For azure provider (requires API key)
3741

3842

3943
async def setup_demo_data():

0 commit comments

Comments
 (0)