1010 PromptCache ,
1111 PromptCacheItem ,
1212)
13- from langfuse .api . resources . commons . errors . not_found_error import NotFoundError
14- from langfuse .api . resources . prompts import Prompt_Chat , Prompt_Text
13+ from langfuse .api import NotFoundError
14+ from langfuse .api import Prompt_Chat , Prompt_Text
1515from langfuse .model import ChatPromptClient , TextPromptClient
1616from tests .utils import create_uuid , get_api
1717
@@ -312,7 +312,7 @@ def test_compile_with_placeholders(
312312 variables , placeholders , expected_len , expected_contents
313313) -> None :
314314 """Test compile_with_placeholders with different variable/placeholder combinations."""
315- from langfuse .api . resources . prompts import Prompt_Chat
315+ from langfuse .api import Prompt_Chat
316316 from langfuse .model import ChatPromptClient
317317
318318 mock_prompt = Prompt_Chat (
@@ -706,7 +706,7 @@ def test_get_fresh_prompt(langfuse):
706706 tags = [],
707707 )
708708
709- mock_server_call = langfuse .api . prompts . get
709+ mock_server_call = langfuse .api
710710 mock_server_call .return_value = prompt
711711
712712 result = langfuse .get_prompt (prompt_name , fallback = "fallback" )
@@ -734,7 +734,7 @@ def test_throw_if_name_unspecified(langfuse):
734734def test_throw_when_failing_fetch_and_no_cache (langfuse ):
735735 prompt_name = "failing_fetch_and_no_cache"
736736
737- mock_server_call = langfuse .api . prompts . get
737+ mock_server_call = langfuse .api
738738 mock_server_call .side_effect = Exception ("Prompt not found" )
739739
740740 with pytest .raises (Exception ) as exc_info :
@@ -755,7 +755,7 @@ def test_using_custom_prompt_timeouts(langfuse):
755755 tags = [],
756756 )
757757
758- mock_server_call = langfuse .api . prompts . get
758+ mock_server_call = langfuse .api
759759 mock_server_call .return_value = prompt
760760
761761 result = langfuse .get_prompt (
@@ -796,7 +796,7 @@ def test_get_valid_cached_prompt(langfuse):
796796 )
797797 prompt_client = TextPromptClient (prompt )
798798
799- mock_server_call = langfuse .api . prompts . get
799+ mock_server_call = langfuse .api
800800 mock_server_call .return_value = prompt
801801
802802 result_call_1 = langfuse .get_prompt (prompt_name , fallback = "fallback" )
@@ -822,7 +822,7 @@ def test_get_valid_cached_chat_prompt_by_label(langfuse):
822822 )
823823 prompt_client = ChatPromptClient (prompt )
824824
825- mock_server_call = langfuse .api . prompts . get
825+ mock_server_call = langfuse .api
826826 mock_server_call .return_value = prompt
827827
828828 result_call_1 = langfuse .get_prompt (prompt_name , label = "test" )
@@ -848,7 +848,7 @@ def test_get_valid_cached_chat_prompt_by_version(langfuse):
848848 )
849849 prompt_client = ChatPromptClient (prompt )
850850
851- mock_server_call = langfuse .api . prompts . get
851+ mock_server_call = langfuse .api
852852 mock_server_call .return_value = prompt
853853
854854 result_call_1 = langfuse .get_prompt (prompt_name , version = 1 )
@@ -874,7 +874,7 @@ def test_get_valid_cached_production_chat_prompt(langfuse):
874874 )
875875 prompt_client = ChatPromptClient (prompt )
876876
877- mock_server_call = langfuse .api . prompts . get
877+ mock_server_call = langfuse .api
878878 mock_server_call .return_value = prompt
879879
880880 result_call_1 = langfuse .get_prompt (prompt_name )
@@ -900,7 +900,7 @@ def test_get_valid_cached_chat_prompt(langfuse):
900900 )
901901 prompt_client = ChatPromptClient (prompt )
902902
903- mock_server_call = langfuse .api . prompts . get
903+ mock_server_call = langfuse .api
904904 mock_server_call .return_value = prompt
905905
906906 result_call_1 = langfuse .get_prompt (prompt_name )
@@ -930,7 +930,7 @@ def test_get_fresh_prompt_when_expired_cache_custom_ttl(mock_time, langfuse: Lan
930930 )
931931 prompt_client = TextPromptClient (prompt )
932932
933- mock_server_call = langfuse .api . prompts . get
933+ mock_server_call = langfuse .api
934934 mock_server_call .return_value = prompt
935935
936936 result_call_1 = langfuse .get_prompt (prompt_name , cache_ttl_seconds = ttl_seconds )
@@ -995,7 +995,7 @@ def test_disable_caching_when_ttl_zero(mock_time, langfuse: Langfuse):
995995 tags = [],
996996 )
997997
998- mock_server_call = langfuse .api . prompts . get
998+ mock_server_call = langfuse .api
999999 mock_server_call .side_effect = [prompt1 , prompt2 , prompt3 ]
10001000
10011001 # First call
@@ -1037,7 +1037,7 @@ def test_get_stale_prompt_when_expired_cache_default_ttl(mock_time, langfuse: La
10371037 )
10381038 prompt_client = TextPromptClient (prompt )
10391039
1040- mock_server_call = langfuse .api . prompts . get
1040+ mock_server_call = langfuse .api
10411041 mock_server_call .return_value = prompt
10421042
10431043 result_call_1 = langfuse .get_prompt (prompt_name )
@@ -1099,7 +1099,7 @@ def test_get_fresh_prompt_when_expired_cache_default_ttl(mock_time, langfuse: La
10991099 )
11001100 prompt_client = TextPromptClient (prompt )
11011101
1102- mock_server_call = langfuse .api . prompts . get
1102+ mock_server_call = langfuse .api
11031103 mock_server_call .return_value = prompt
11041104
11051105 result_call_1 = langfuse .get_prompt (prompt_name )
@@ -1143,7 +1143,7 @@ def test_get_expired_prompt_when_failing_fetch(mock_time, langfuse: Langfuse):
11431143 )
11441144 prompt_client = TextPromptClient (prompt )
11451145
1146- mock_server_call = langfuse .api . prompts . get
1146+ mock_server_call = langfuse .api
11471147 mock_server_call .return_value = prompt
11481148
11491149 result_call_1 = langfuse .get_prompt (prompt_name )
@@ -1187,7 +1187,7 @@ def test_evict_prompt_cache_entry_when_refresh_returns_not_found(
11871187 prompt_client = TextPromptClient (prompt )
11881188 cache_key = PromptCache .generate_cache_key (prompt_name , version = None , label = None )
11891189
1190- mock_server_call = langfuse .api . prompts . get
1190+ mock_server_call = langfuse .api
11911191 mock_server_call .return_value = prompt
11921192
11931193 initial_result = langfuse .get_prompt (
@@ -1244,7 +1244,7 @@ def test_get_fresh_prompt_when_version_changes(langfuse: Langfuse):
12441244 )
12451245 prompt_client = TextPromptClient (prompt )
12461246
1247- mock_server_call = langfuse .api . prompts . get
1247+ mock_server_call = langfuse .api
12481248 mock_server_call .return_value = prompt
12491249
12501250 result_call_1 = langfuse .get_prompt (prompt_name , version = 1 )
0 commit comments