fix(llms,embeddings): repair HTTP proxy support (httpx>=0.28) and preserve proxies in LlmFactory (#5447)

Co-authored-by: kartik-mem0 <kartik.labhshetwar@mem0.ai>
This commit is contained in:
Yash Raj Pandey
2026-06-19 13:45:21 +05:30
committed by GitHub
co-authored by kartik-mem0
parent 48f1d6f010
commit 7a9f03af3f
16 changed files with 82 additions and 16 deletions
+1 -1
View File
@@ -289,7 +289,7 @@ def test_generate_with_http_proxies(default_headers):
api_version=None,
default_headers=default_headers,
)
mock_http_client.assert_called_once_with(proxies="http://testproxy.mem0.net:8000")
mock_http_client.assert_called_once_with(proxy="http://testproxy.mem0.net:8000")
def test_init_with_api_key(monkeypatch):
+13
View File
@@ -1,8 +1,10 @@
import os
from unittest.mock import Mock, patch
import httpx
import pytest
from mem0.configs.llms.base import BaseLlmConfig
from mem0.configs.llms.openai import OpenAIConfig
from mem0.llms.openai import OpenAILLM
@@ -451,3 +453,14 @@ def test_callback_with_tools(mock_openai_client):
mock_callback.assert_called_once()
# Check that tool_calls exists in the message
assert hasattr(mock_callback.call_args[0][1].choices[0].message, 'tool_calls')
def test_openai_llm_preserves_proxies_from_base_config(mock_openai_client):
config = BaseLlmConfig(
model="gpt-4.1-nano-2025-04-14",
api_key="api_key",
http_client_proxies="http://proxy.local:8080",
)
llm = OpenAILLM(config)
assert llm.config.http_client_proxies == "http://proxy.local:8080"
assert isinstance(llm.config.http_client, httpx.Client)