1
1
import logging
2
2
import os
3
3
from pathlib import Path
4
+ from typing import Any
4
5
5
6
import azure .identity
6
- from azure .ai .evaluation import AzureOpenAIModelConfiguration , OpenAIModelConfiguration
7
7
from dotenv import load_dotenv
8
8
from evaltools .eval .evaluate import run_evaluate_from_config
9
9
from rich .logging import RichHandler
12
12
13
13
14
14
def get_openai_config () -> dict :
15
+ openai_config : dict [str , Any ]
15
16
if os .environ .get ("OPENAI_CHAT_HOST" ) == "azure" :
16
17
azure_endpoint = os .environ ["AZURE_OPENAI_ENDPOINT" ]
17
- azure_deployment = os .environ . get ( "AZURE_OPENAI_EVAL_DEPLOYMENT" )
18
+ azure_deployment = os .environ [ "AZURE_OPENAI_EVAL_DEPLOYMENT" ]
18
19
if os .environ .get ("AZURE_OPENAI_KEY" ):
19
20
logger .info ("Using Azure OpenAI Service with API Key from AZURE_OPENAI_KEY" )
20
- openai_config : AzureOpenAIModelConfiguration = {
21
+ openai_config = {
21
22
"azure_endpoint" : azure_endpoint ,
22
23
"azure_deployment" : azure_deployment ,
23
24
"api_key" : os .environ ["AZURE_OPENAI_KEY" ],
@@ -29,7 +30,7 @@ def get_openai_config() -> dict:
29
30
else :
30
31
logger .info ("Authenticating to Azure using Azure Developer CLI Credential" )
31
32
azure_credential = azure .identity .AzureDeveloperCliCredential (process_timeout = 60 )
32
- openai_config : AzureOpenAIModelConfiguration = {
33
+ openai_config = {
33
34
"azure_endpoint" : azure_endpoint ,
34
35
"azure_deployment" : azure_deployment ,
35
36
"credential" : azure_credential ,
@@ -39,7 +40,7 @@ def get_openai_config() -> dict:
39
40
openai_config ["model" ] = os .environ ["AZURE_OPENAI_EVAL_MODEL" ]
40
41
else :
41
42
logger .info ("Using OpenAI Service with API Key from OPENAICOM_KEY" )
42
- openai_config : OpenAIModelConfiguration = {"api_key" : os .environ ["OPENAICOM_KEY" ], "model" : "gpt-4" }
43
+ openai_config = {"api_key" : os .environ ["OPENAICOM_KEY" ], "model" : "gpt-4" }
43
44
return openai_config
44
45
45
46
0 commit comments