mirror of
https://github.com/BerriAI/litellm.git
synced 2026-10-08 03:08:45 +00:00
fix(arize): decline prompt management runs without a prompt_id
Arize Phoenix claimed it could run without a prompt_id while its compiler requires one, so the no-prompt_id fallback could select it and fail instead of reaching the vector-store hook. It now declines like the other managers.
This commit is contained in:
parent
4829bb3a15
commit
b780b1e23c
2 changed files with 15 additions and 7 deletions
|
|
@ -359,10 +359,10 @@ class ArizePhoenixPromptManager(CustomPromptManagement):
|
|||
"""
|
||||
Determine if prompt management should run based on the prompt_id.
|
||||
|
||||
For Arize Phoenix, we always return True and handle the prompt loading
|
||||
in the _compile_prompt_helper method.
|
||||
Arize Phoenix needs a prompt_id to compile, so it declines requests without one;
|
||||
prompt loading itself happens in the _compile_prompt_helper method.
|
||||
"""
|
||||
return True
|
||||
return prompt_id is not None
|
||||
|
||||
def _compile_prompt_helper(
|
||||
self,
|
||||
|
|
|
|||
|
|
@ -5113,6 +5113,7 @@ def test_prompt_hooks_skip_prompt_managers_when_no_prompt_id(logging_obj, tmp_pa
|
|||
with a registered prompt manager (e.g. dotprompt): requests without a prompt_id 500'd with
|
||||
"prompt_id is required for Prompt Management Base class" instead of completing normally.
|
||||
"""
|
||||
from litellm.integrations.arize.arize_phoenix_prompt_manager import ArizePhoenixPromptManager
|
||||
from litellm.integrations.dotprompt.dotprompt_manager import DotpromptManager
|
||||
from litellm.integrations.vector_store_integrations.vector_store_pre_call_hook import (
|
||||
VectorStorePreCallHook,
|
||||
|
|
@ -5122,7 +5123,9 @@ def test_prompt_hooks_skip_prompt_managers_when_no_prompt_id(logging_obj, tmp_pa
|
|||
|
||||
(tmp_path / "stem.prompt").write_text("---\nmodel: gemini-2.5-flash\n---\nyou are a stem tutor\n")
|
||||
dotprompt_manager = DotpromptManager(prompt_directory=str(tmp_path))
|
||||
arize_manager = ArizePhoenixPromptManager(api_key="fake-key", api_base="http://127.0.0.1:9")
|
||||
litellm.logging_callback_manager.add_litellm_callback(dotprompt_manager)
|
||||
litellm.logging_callback_manager.add_litellm_callback(arize_manager)
|
||||
monkeypatch.setattr(
|
||||
litellm,
|
||||
"vector_store_registry",
|
||||
|
|
@ -5154,6 +5157,10 @@ def test_prompt_hooks_skip_prompt_managers_when_no_prompt_id(logging_obj, tmp_pa
|
|||
dynamic_callback_params={},
|
||||
) == ("gemini-2.5-flash", messages, {})
|
||||
|
||||
assert not arize_manager.should_run_prompt_management(
|
||||
prompt_id=None, prompt_spec=None, dynamic_callback_params={}
|
||||
)
|
||||
|
||||
assert logging_obj.should_run_prompt_management_hooks(
|
||||
prompt_id=None, non_default_params={"vector_store_ids": ["vs_123"]}
|
||||
)
|
||||
|
|
@ -5177,9 +5184,10 @@ def test_prompt_hooks_skip_prompt_managers_when_no_prompt_id(logging_obj, tmp_pa
|
|||
DotpromptManager,
|
||||
)
|
||||
finally:
|
||||
litellm.logging_callback_manager.remove_callback_from_list_by_object(litellm.callbacks, dotprompt_manager)
|
||||
litellm.logging_callback_manager.remove_callback_from_list_by_object(
|
||||
litellm._async_success_callback, dotprompt_manager
|
||||
)
|
||||
for manager in (dotprompt_manager, arize_manager):
|
||||
litellm.logging_callback_manager.remove_callback_from_list_by_object(litellm.callbacks, manager)
|
||||
litellm.logging_callback_manager.remove_callback_from_list_by_object(
|
||||
litellm._async_success_callback, manager
|
||||
)
|
||||
for hook in [cb for cb in litellm.callbacks if isinstance(cb, VectorStorePreCallHook)]:
|
||||
litellm.logging_callback_manager.remove_callback_from_list_by_object(litellm.callbacks, hook)
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue