2828@pytest .fixture (autouse = True )
2929def completions_mocking (httpserver : HTTPServer , app_config : AppConfig ):
3030 httpserver .expect_oneshot_request (
31- f"/openai/deployments/{ app_config .get ( 'AZURE_OPENAI_MODEL ' )} /chat/completions" ,
31+ f"/openai/deployments/{ app_config .get_from_json ( 'AZURE_OPENAI_MODEL_INFO' , 'model ' )} /chat/completions" ,
3232 method = "POST" ,
3333 ).respond_with_json (
3434 {
3535 "id" : "chatcmpl-6v7mkQj980V1yBec6ETrKPRqFjNw9" ,
3636 "object" : "chat.completion" ,
3737 "created" : 1679072642 ,
38- "model" : app_config .get ( "AZURE_OPENAI_MODEL " ),
38+ "model" : app_config .get_from_json ( "AZURE_OPENAI_MODEL_INFO" , "model " ),
3939 "usage" : {
4040 "prompt_tokens" : 58 ,
4141 "completion_tokens" : 68 ,
@@ -58,7 +58,7 @@ def completions_mocking(httpserver: HTTPServer, app_config: AppConfig):
5858 )
5959
6060 httpserver .expect_oneshot_request (
61- f"/openai/deployments/{ app_config .get ( 'AZURE_OPENAI_MODEL ' )} /chat/completions" ,
61+ f"/openai/deployments/{ app_config .get_from_json ( 'AZURE_OPENAI_MODEL_INFO' , 'model ' )} /chat/completions" ,
6262 method = "POST" ,
6363 ).respond_with_json (
6464 {
@@ -110,7 +110,7 @@ def test_post_responds_successfully(app_url: str, app_config: AppConfig):
110110 ],
111111 "created" : "response.created" ,
112112 "id" : "response.id" ,
113- "model" : app_config .get ( "AZURE_OPENAI_MODEL " ),
113+ "model" : app_config .get_from_json ( "AZURE_OPENAI_MODEL_INFO" , "model " ),
114114 "object" : "response.object" ,
115115 }
116116 assert response .headers ["Content-Type" ] == "application/json"
@@ -126,7 +126,7 @@ def test_post_makes_correct_calls_to_openai_embeddings_to_get_vector_dimensions(
126126 verify_request_made (
127127 mock_httpserver = httpserver ,
128128 request_matcher = RequestMatcher (
129- path = f"/openai/deployments/{ app_config .get ( 'AZURE_OPENAI_EMBEDDING_MODEL ' )} /embeddings" ,
129+ path = f"/openai/deployments/{ app_config .get_from_json ( 'AZURE_OPENAI_EMBEDDING_MODEL_INFO' , 'model ' )} /embeddings" ,
130130 method = "POST" ,
131131 json = {
132132 "input" : [[1199 ]],
@@ -155,13 +155,15 @@ def test_post_makes_correct_calls_to_openai_embeddings_to_embed_question_to_sear
155155 verify_request_made (
156156 mock_httpserver = httpserver ,
157157 request_matcher = RequestMatcher (
158- path = f"/openai/deployments/{ app_config .get ( 'AZURE_OPENAI_EMBEDDING_MODEL ' )} /embeddings" ,
158+ path = f"/openai/deployments/{ app_config .get_from_json ( 'AZURE_OPENAI_EMBEDDING_MODEL_INFO' , 'model ' )} /embeddings" ,
159159 method = "POST" ,
160160 json = {
161161 "input" : [
162162 [3923 , 374 , 279 , 7438 , 315 , 2324 , 30 ]
163163 ], # Embedding of "What is the meaning of life?"
164- "model" : app_config .get ("AZURE_OPENAI_EMBEDDING_MODEL" ),
164+ "model" : app_config .get_from_json (
165+ "AZURE_OPENAI_EMBEDDING_MODEL_INFO" , "model"
166+ ),
165167 "encoding_format" : "base64" ,
166168 },
167169 headers = {
@@ -188,7 +190,7 @@ def test_post_makes_correct_calls_to_openai_embeddings_to_embed_question_to_stor
188190 verify_request_made (
189191 mock_httpserver = httpserver ,
190192 request_matcher = RequestMatcher (
191- path = f"/openai/deployments/{ app_config .get ( 'AZURE_OPENAI_EMBEDDING_MODEL ' )} /embeddings" ,
193+ path = f"/openai/deployments/{ app_config .get_from_json ( 'AZURE_OPENAI_EMBEDDING_MODEL_INFO' , 'model ' )} /embeddings" ,
192194 method = "POST" ,
193195 json = {
194196 "input" : [
@@ -265,7 +267,7 @@ def test_post_makes_correct_call_to_openai_chat_completions_with_functions(
265267 verify_request_made (
266268 mock_httpserver = httpserver ,
267269 request_matcher = RequestMatcher (
268- path = f"/openai/deployments/{ app_config .get ( 'AZURE_OPENAI_MODEL ' )} /chat/completions" ,
270+ path = f"/openai/deployments/{ app_config .get_from_json ( 'AZURE_OPENAI_MODEL_INFO' , 'model ' )} /chat/completions" ,
269271 method = "POST" ,
270272 json = {
271273 "messages" : [
@@ -555,7 +557,7 @@ def test_post_makes_correct_call_to_openai_chat_completions_with_documents(
555557 verify_request_made (
556558 mock_httpserver = httpserver ,
557559 request_matcher = RequestMatcher (
558- path = f"/openai/deployments/{ app_config .get ( 'AZURE_OPENAI_MODEL ' )} /chat/completions" ,
560+ path = f"/openai/deployments/{ app_config .get_from_json ( 'AZURE_OPENAI_MODEL_INFO' , 'model ' )} /chat/completions" ,
559561 method = "POST" ,
560562 json = {
561563 "messages" : [
@@ -589,7 +591,7 @@ def test_post_makes_correct_call_to_openai_chat_completions_with_documents(
589591 "role" : "user" ,
590592 },
591593 ],
592- "model" : app_config .get ( "AZURE_OPENAI_MODEL " ),
594+ "model" : app_config .get_from_json ( "AZURE_OPENAI_MODEL_INFO" , "model " ),
593595 "max_tokens" : int (app_config .get ("AZURE_OPENAI_MAX_TOKENS" )),
594596 "temperature" : 0 ,
595597 },
0 commit comments