mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-03 02:22:24 +00:00
Fix(langfuse): pass httpx_client to Langfuse in langfuse_prompt_management to respect SSL_VERIFY (#29480)
* fix(langfuse): pass ssl_verify to Langfuse httpx client * fix_langfuse_ * add unit tests * addressed comments --------- Co-authored-by: shin-berri <shin-laptop@berri.ai> Co-authored-by: yuneng-jiang <yuneng@berri.ai>
This commit is contained in:
parent
4a6d586b48
commit
94e4dd3684
2 changed files with 41 additions and 0 deletions
|
|
@ -102,6 +102,11 @@ def langfuse_client_init(
|
|||
if Version(langfuse.version.__version__) >= Version("2.6.0"):
|
||||
parameters["sdk_integration"] = "litellm"
|
||||
|
||||
from ...llms.custom_httpx.http_handler import _get_httpx_client
|
||||
|
||||
http_client = _get_httpx_client()
|
||||
parameters["httpx_client"] = http_client.client
|
||||
|
||||
client = Langfuse(**parameters)
|
||||
|
||||
return client
|
||||
|
|
|
|||
|
|
@ -3,6 +3,7 @@ from unittest.mock import MagicMock, patch
|
|||
|
||||
from litellm.integrations.langfuse.langfuse_prompt_management import (
|
||||
LangfusePromptManagement,
|
||||
langfuse_client_init,
|
||||
)
|
||||
|
||||
|
||||
|
|
@ -65,3 +66,38 @@ class TestLangfusePromptManagement:
|
|||
mock_run_async.call_args[0][0]
|
||||
== langfuse_prompt_management.async_log_failure_event
|
||||
)
|
||||
|
||||
def test_langfuse_client_init_passes_httpx_client(self):
|
||||
mock_langfuse_class = MagicMock()
|
||||
with (
|
||||
patch(
|
||||
"litellm.integrations.langfuse.langfuse_prompt_management.resolve_langfuse_credentials",
|
||||
return_value=("pk-1234", "sk-1234", "https://localhost"),
|
||||
),
|
||||
patch(
|
||||
"litellm.integrations.langfuse.langfuse_prompt_management.LangFuseLogger._get_langfuse_flush_interval",
|
||||
return_value=1,
|
||||
),
|
||||
patch.dict("sys.modules", {"langfuse": self._mock_langfuse}),
|
||||
patch(
|
||||
"litellm.llms.custom_httpx.http_handler._get_httpx_client"
|
||||
) as mock_get_httpx,
|
||||
):
|
||||
mock_http_handler = MagicMock()
|
||||
mock_http_handler.client = MagicMock()
|
||||
mock_get_httpx.return_value = mock_http_handler
|
||||
|
||||
self._mock_langfuse.Langfuse = mock_langfuse_class
|
||||
|
||||
langfuse_client_init(
|
||||
langfuse_public_key="pk-1234",
|
||||
langfuse_secret="sk-1234",
|
||||
langfuse_host="https://localhost",
|
||||
)
|
||||
|
||||
mock_langfuse_class.assert_called_once()
|
||||
call_kwargs = mock_langfuse_class.call_args[1]
|
||||
assert "httpx_client" in call_kwargs
|
||||
assert call_kwargs["httpx_client"] is mock_http_handler.client
|
||||
|
||||
langfuse_client_init.cache_clear()
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue