Skip to content

Commit 1859eaf

Browse files
committed
feat: Add configurable timeout for OpenRouter embedding model
1 parent 7a26865 commit 1859eaf

2 files changed

Lines changed: 5 additions & 2 deletions

File tree

deployment/config/rag-pipeline/.env.sample

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -50,6 +50,7 @@ REDIS_URL=redis://redis:6379/1
5050
#OLLAMA_BATCH_SIZE=100
5151

5252
## Request timeout in seconds (increase for slow CPU)
53+
#OPENROUTER_TIMEOUT=300
5354
#OLLAMA_TIMEOUT=120
5455

5556
## CPU Threading Optimization (set based on your CPU cores)

python-ecosystem/rag-pipeline/src/rag_pipeline/core/embedding_factory.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44
"""
55

66
import logging
7+
import os
78
from typing import Union
89

910
from llama_index.core.base.embeddings.base import BaseEmbedding
@@ -37,12 +38,13 @@ def create_embedding_model(config: RAGConfig) -> BaseEmbedding:
3738
)
3839

3940
elif provider == "openrouter":
40-
logger.info(f"Creating OpenRouter embedding model: {config.openrouter_model}")
41+
timeout = float(os.getenv("OPENROUTER_TIMEOUT", "300"))
42+
logger.info(f"Creating OpenRouter embedding model: {config.openrouter_model} (timeout={timeout}s)")
4143
return OpenRouterEmbedding(
4244
api_key=config.openrouter_api_key,
4345
model=config.openrouter_model,
4446
api_base=config.openrouter_base_url,
45-
timeout=60.0,
47+
timeout=timeout,
4648
max_retries=3,
4749
expected_dim=config.embedding_dim
4850
)

0 commit comments

Comments
 (0)