mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-11 03:38:38 +00:00
fix(prompt_registry): add __init__.py and registry for langfuse integration
This commit is contained in:
parent
25feae9f0f
commit
fc4715eeab
2 changed files with 45 additions and 0 deletions
21
litellm/integrations/langfuse/__init__.py
Normal file
21
litellm/integrations/langfuse/__init__.py
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
"""Langfuse integration for LiteLLM Prompt Management."""
|
||||
|
||||
from .langfuse_prompt_management import LangfusePromptManagement
|
||||
|
||||
|
||||
def initialize_prompt(litellm_params, prompt_spec):
|
||||
"""
|
||||
Initialization function that prompt_registry.py will call.
|
||||
"""
|
||||
return LangfusePromptManagement(
|
||||
langfuse_public_key=getattr(litellm_params, "langfuse_public_key", None),
|
||||
langfuse_secret=getattr(litellm_params, "langfuse_secret", None),
|
||||
langfuse_host=getattr(litellm_params, "langfuse_host", None),
|
||||
)
|
||||
|
||||
|
||||
prompt_initializer_registry = {
|
||||
"langfuse": initialize_prompt,
|
||||
}
|
||||
|
||||
__all__ = ["initialize_prompt", "prompt_initializer_registry"]
|
||||
24
tests/test_langfuse_prompt_init.py
Normal file
24
tests/test_langfuse_prompt_init.py
Normal file
|
|
@ -0,0 +1,24 @@
|
|||
import pytest
|
||||
from litellm.proxy.prompts.prompt_registry import get_prompt_initializer_from_integrations
|
||||
from litellm.types.prompts.init_prompts import PromptLiteLLMParams, PromptSpec
|
||||
|
||||
def test_langfuse_discovery_and_init():
|
||||
"""
|
||||
Tests whether Langfuse is dynamically discovered and can be initialized.
|
||||
This validates the fix in __init__.py at litellm/integrations/langfuse/
|
||||
"""
|
||||
|
||||
registry = get_prompt_initializer_from_integrations()
|
||||
assert "langfuse" in registry, "Error: Langfuse wasn't discovered by the prompt_registry!"
|
||||
|
||||
init_func = registry["langfuse"]
|
||||
params = PromptLiteLLMParams(
|
||||
prompt_integration="langfuse",
|
||||
langfuse_public_key="test-key",
|
||||
langfuse_secret="test-secret"
|
||||
)
|
||||
spec = PromptSpec(prompt_id="test-id", litellm_params=params)
|
||||
|
||||
obj = init_func(params, spec)
|
||||
assert obj is not None, "Initiation function returned None!"
|
||||
assert obj.integration_name == "langfuse"
|
||||
Loading…
Add table
Reference in a new issue