mirror of
https://github.com/tiennm99/litellm.git
synced 2026-08-18 06:26:16 +00:00
test: update unit tests
This commit is contained in:
@@ -1,13 +1,4 @@
|
||||
model_list:
|
||||
<<<<<<< HEAD
|
||||
- model_name: "gpt-4o-mini-openai"
|
||||
litellm_params:
|
||||
model: gpt-4o-mini
|
||||
api_key: os.environ/OPENAI_API_KEY
|
||||
|
||||
router_settings:
|
||||
model_group_alias: {"gpt-4o": "gpt-4o-mini-openai"}
|
||||
=======
|
||||
- model_name: openai-test
|
||||
litellm_params:
|
||||
model: dotprompt/gpt-3.5-turbo
|
||||
@@ -16,4 +7,3 @@ router_settings:
|
||||
|
||||
litellm_settings:
|
||||
global_prompt_directory: /Users/krrishdholakia/Documents/litellm/litellm/proxy/test_prompts
|
||||
>>>>>>> litellm_dev_07_31_2025_p1
|
||||
|
||||
@@ -21,7 +21,9 @@ from litellm.integrations.dotprompt.prompt_manager import PromptManager, PromptT
|
||||
def test_prompt_manager_initialization():
|
||||
"""Test basic PromptManager initialization and loading."""
|
||||
# Test with the existing prompts directory
|
||||
prompt_dir = "." # Current directory when running from tests/test_litellm/prompts
|
||||
prompt_dir = Path(
|
||||
__file__
|
||||
).parent # Current directory when running from tests/test_litellm/prompts
|
||||
manager = PromptManager(prompt_dir)
|
||||
|
||||
# Should have loaded at least the sample prompts
|
||||
@@ -53,7 +55,9 @@ def test_prompt_template_creation():
|
||||
|
||||
def test_render_simple_template():
|
||||
"""Test rendering a simple template with variables."""
|
||||
prompt_dir = "." # Current directory when running from tests/test_litellm/prompts
|
||||
prompt_dir = Path(
|
||||
__file__
|
||||
).parent # Current directory when running from tests/test_litellm/prompts
|
||||
manager = PromptManager(prompt_dir)
|
||||
|
||||
# Test sample_prompt rendering
|
||||
@@ -67,7 +71,9 @@ def test_render_simple_template():
|
||||
|
||||
def test_render_chat_prompt():
|
||||
"""Test rendering the chat prompt with conditional content."""
|
||||
prompt_dir = "." # Current directory when running from tests/test_litellm/prompts
|
||||
prompt_dir = Path(
|
||||
__file__
|
||||
).parent # Current directory when running from tests/test_litellm/prompts
|
||||
manager = PromptManager(prompt_dir)
|
||||
|
||||
# Test with system context
|
||||
@@ -91,7 +97,9 @@ def test_render_chat_prompt():
|
||||
|
||||
def test_render_coding_assistant():
|
||||
"""Test rendering the coding assistant prompt with complex logic."""
|
||||
prompt_dir = "." # Current directory when running from tests/test_litellm/prompts
|
||||
prompt_dir = Path(
|
||||
__file__
|
||||
).parent # Current directory when running from tests/test_litellm/prompts
|
||||
manager = PromptManager(prompt_dir)
|
||||
|
||||
rendered = manager.render(
|
||||
@@ -150,7 +158,9 @@ Hello {{name}}, you are {{age}} years old and {'active' if active else 'inactive
|
||||
|
||||
def test_prompt_not_found():
|
||||
"""Test error handling for non-existent prompts."""
|
||||
prompt_dir = "." # Current directory when running from tests/test_litellm/prompts
|
||||
prompt_dir = Path(
|
||||
__file__
|
||||
).parent # Current directory when running from tests/test_litellm/prompts
|
||||
manager = PromptManager(prompt_dir)
|
||||
|
||||
with pytest.raises(KeyError, match="Prompt 'nonexistent' not found"):
|
||||
@@ -159,7 +169,9 @@ def test_prompt_not_found():
|
||||
|
||||
def test_list_prompts():
|
||||
"""Test listing available prompts."""
|
||||
prompt_dir = "." # Current directory when running from tests/test_litellm/prompts
|
||||
prompt_dir = Path(
|
||||
__file__
|
||||
).parent # Current directory when running from tests/test_litellm/prompts
|
||||
manager = PromptManager(prompt_dir)
|
||||
|
||||
prompts = manager.list_prompts()
|
||||
@@ -171,7 +183,9 @@ def test_list_prompts():
|
||||
|
||||
def test_get_prompt_metadata():
|
||||
"""Test retrieving prompt metadata."""
|
||||
prompt_dir = "." # Current directory when running from tests/test_litellm/prompts
|
||||
prompt_dir = Path(
|
||||
__file__
|
||||
).parent # Current directory when running from tests/test_litellm/prompts
|
||||
manager = PromptManager(prompt_dir)
|
||||
|
||||
metadata = manager.get_prompt_metadata("sample_prompt")
|
||||
@@ -183,7 +197,9 @@ def test_get_prompt_metadata():
|
||||
|
||||
def test_add_prompt_programmatically():
|
||||
"""Test adding prompts programmatically."""
|
||||
prompt_dir = "." # Current directory when running from tests/test_litellm/prompts
|
||||
prompt_dir = Path(
|
||||
__file__
|
||||
).parent # Current directory when running from tests/test_litellm/prompts
|
||||
manager = PromptManager(prompt_dir)
|
||||
|
||||
initial_count = len(manager.prompts)
|
||||
|
||||
Reference in New Issue
Block a user