Skip to content

Commit 1910526

Browse files
committed
feat: Add configurable timeouts for Ollama and OpenRouter embedding models.
1 parent 1859eaf commit 1910526

2 files changed

Lines changed: 6 additions & 4 deletions

File tree

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

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -29,11 +29,12 @@ def create_embedding_model(config: RAGConfig) -> BaseEmbedding:
2929
provider = config.embedding_provider.lower()
3030

3131
if provider == "ollama":
32-
logger.info(f"Creating Ollama embedding model: {config.ollama_model}")
32+
timeout = float(os.getenv("OLLAMA_TIMEOUT", "120"))
33+
logger.info(f"Creating Ollama embedding model: {config.ollama_model} (timeout={timeout}s)")
3334
return OllamaEmbedding(
3435
model=config.ollama_model,
3536
base_url=config.ollama_base_url,
36-
timeout=120.0,
37+
timeout=timeout,
3738
expected_dim=config.embedding_dim
3839
)
3940

@@ -51,10 +52,11 @@ def create_embedding_model(config: RAGConfig) -> BaseEmbedding:
5152

5253
else:
5354
logger.warning(f"Unknown embedding provider '{provider}', defaulting to Ollama")
55+
timeout = float(os.getenv("OLLAMA_TIMEOUT", "120"))
5456
return OllamaEmbedding(
5557
model=config.ollama_model,
5658
base_url=config.ollama_base_url,
57-
timeout=120.0,
59+
timeout=timeout,
5860
expected_dim=config.embedding_dim
5961
)
6062

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -36,7 +36,7 @@ def __init__(
3636
api_key: str,
3737
model: str = "openai/text-embedding-3-small",
3838
api_base: str = "https://openrouter.ai/api/v1",
39-
timeout: float = 60.0,
39+
timeout: float = float(os.getenv("OPENROUTER_TIMEOUT", "300")),
4040
max_retries: int = 3,
4141
embed_batch_size: int = EMBEDDING_BATCH_SIZE,
4242
expected_dim: Optional[int] = None,

0 commit comments

Comments
 (0)