@@ -73,24 +73,58 @@ def teardown_method(self):
7373
7474 @pytest .mark .usefixtures ("retrieve_contexts_mock" )
7575 def test_retrieval_query_rag_resources_success (self ):
76+ with pytest .warns (DeprecationWarning ):
77+ response = rag .retrieval_query (
78+ rag_resources = [test_rag_constants_preview .TEST_RAG_RESOURCE ],
79+ text = test_rag_constants_preview .TEST_QUERY_TEXT ,
80+ similarity_top_k = 2 ,
81+ vector_distance_threshold = 0.5 ,
82+ vector_search_alpha = 0.5 ,
83+ )
84+ retrieve_contexts_eq (
85+ response , test_rag_constants_preview .TEST_RETRIEVAL_RESPONSE
86+ )
87+
88+ @pytest .mark .usefixtures ("retrieve_contexts_mock" )
89+ def test_retrieval_query_rag_resources_config_success (self ):
90+ response = rag .retrieval_query (
91+ rag_resources = [test_rag_constants_preview .TEST_RAG_RESOURCE ],
92+ text = test_rag_constants_preview .TEST_QUERY_TEXT ,
93+ rag_retrieval_config = test_rag_constants_preview .TEST_RAG_RETRIEVAL_CONFIG_ALPHA ,
94+ )
95+ retrieve_contexts_eq (
96+ response , test_rag_constants_preview .TEST_RETRIEVAL_RESPONSE
97+ )
98+
99+ @pytest .mark .usefixtures ("retrieve_contexts_mock" )
100+ def test_retrieval_query_rag_resources_default_config_success (self ):
76101 response = rag .retrieval_query (
77102 rag_resources = [test_rag_constants_preview .TEST_RAG_RESOURCE ],
78103 text = test_rag_constants_preview .TEST_QUERY_TEXT ,
79- similarity_top_k = 2 ,
80- vector_distance_threshold = 0.5 ,
81- vector_search_alpha = 0.5 ,
82104 )
83105 retrieve_contexts_eq (
84106 response , test_rag_constants_preview .TEST_RETRIEVAL_RESPONSE
85107 )
86108
87109 @pytest .mark .usefixtures ("retrieve_contexts_mock" )
88110 def test_retrieval_query_rag_corpora_success (self ):
111+ with pytest .warns (DeprecationWarning ):
112+ response = rag .retrieval_query (
113+ rag_corpora = [test_rag_constants_preview .TEST_RAG_CORPUS_ID ],
114+ text = test_rag_constants_preview .TEST_QUERY_TEXT ,
115+ similarity_top_k = 2 ,
116+ vector_distance_threshold = 0.5 ,
117+ )
118+ retrieve_contexts_eq (
119+ response , test_rag_constants_preview .TEST_RETRIEVAL_RESPONSE
120+ )
121+
122+ @pytest .mark .usefixtures ("retrieve_contexts_mock" )
123+ def test_retrieval_query_rag_corpora_config_success (self ):
89124 response = rag .retrieval_query (
90125 rag_corpora = [test_rag_constants_preview .TEST_RAG_CORPUS_ID ],
91126 text = test_rag_constants_preview .TEST_QUERY_TEXT ,
92- similarity_top_k = 2 ,
93- vector_distance_threshold = 0.5 ,
127+ rag_retrieval_config = test_rag_constants_preview .TEST_RAG_RETRIEVAL_CONFIG ,
94128 )
95129 retrieve_contexts_eq (
96130 response , test_rag_constants_preview .TEST_RETRIEVAL_RESPONSE
@@ -107,6 +141,16 @@ def test_retrieval_query_failure(self):
107141 )
108142 e .match ("Failed in retrieving contexts due to" )
109143
144+ @pytest .mark .usefixtures ("rag_client_mock_exception" )
145+ def test_retrieval_query_config_failure (self ):
146+ with pytest .raises (RuntimeError ) as e :
147+ rag .retrieval_query (
148+ rag_resources = [test_rag_constants_preview .TEST_RAG_RESOURCE ],
149+ text = test_rag_constants_preview .TEST_QUERY_TEXT ,
150+ rag_retrieval_config = test_rag_constants_preview .TEST_RAG_RETRIEVAL_CONFIG ,
151+ )
152+ e .match ("Failed in retrieving contexts due to" )
153+
110154 def test_retrieval_query_invalid_name (self ):
111155 with pytest .raises (ValueError ) as e :
112156 rag .retrieval_query (
@@ -119,6 +163,17 @@ def test_retrieval_query_invalid_name(self):
119163 )
120164 e .match ("Invalid RagCorpus name" )
121165
166+ def test_retrieval_query_invalid_name_config (self ):
167+ with pytest .raises (ValueError ) as e :
168+ rag .retrieval_query (
169+ rag_resources = [
170+ test_rag_constants_preview .TEST_RAG_RESOURCE_INVALID_NAME
171+ ],
172+ text = test_rag_constants_preview .TEST_QUERY_TEXT ,
173+ rag_retrieval_config = test_rag_constants_preview .TEST_RAG_RETRIEVAL_CONFIG ,
174+ )
175+ e .match ("Invalid RagCorpus name" )
176+
122177 def test_retrieval_query_multiple_rag_corpora (self ):
123178 with pytest .raises (ValueError ) as e :
124179 rag .retrieval_query (
@@ -132,6 +187,18 @@ def test_retrieval_query_multiple_rag_corpora(self):
132187 )
133188 e .match ("Currently only support 1 RagCorpus" )
134189
190+ def test_retrieval_query_multiple_rag_corpora_config (self ):
191+ with pytest .raises (ValueError ) as e :
192+ rag .retrieval_query (
193+ rag_corpora = [
194+ test_rag_constants_preview .TEST_RAG_CORPUS_ID ,
195+ test_rag_constants_preview .TEST_RAG_CORPUS_ID ,
196+ ],
197+ text = test_rag_constants_preview .TEST_QUERY_TEXT ,
198+ rag_retrieval_config = test_rag_constants_preview .TEST_RAG_RETRIEVAL_CONFIG ,
199+ )
200+ e .match ("Currently only support 1 RagCorpus" )
201+
135202 def test_retrieval_query_multiple_rag_resources (self ):
136203 with pytest .raises (ValueError ) as e :
137204 rag .retrieval_query (
@@ -144,3 +211,15 @@ def test_retrieval_query_multiple_rag_resources(self):
144211 vector_distance_threshold = 0.5 ,
145212 )
146213 e .match ("Currently only support 1 RagResource" )
214+
215+ def test_retrieval_query_multiple_rag_resources_config (self ):
216+ with pytest .raises (ValueError ) as e :
217+ rag .retrieval_query (
218+ rag_resources = [
219+ test_rag_constants_preview .TEST_RAG_RESOURCE ,
220+ test_rag_constants_preview .TEST_RAG_RESOURCE ,
221+ ],
222+ text = test_rag_constants_preview .TEST_QUERY_TEXT ,
223+ rag_retrieval_config = test_rag_constants_preview .TEST_RAG_RETRIEVAL_CONFIG ,
224+ )
225+ e .match ("Currently only support 1 RagResource" )
0 commit comments