1010import argparse
1111from pydantic import BaseModel , Field , ValidationError
1212
13- # --- Configuration ---
14- # Set your OpenAI API key as an environment variable named OPENAI_API_KEY
15- # You can get a key from https://beta.openai.com/account/api-keys
16- API_KEY = os .getenv ("OPENAI_API_KEY" )
1713LOG_REPO_BASE_URL = (
1814 "https://raw.githubusercontent.com/fedora-copr/logdetective-sample/main/data/"
1915)
@@ -222,6 +218,11 @@ def main():
222218 description = "Evaluate AI system performance by comparing expected and actual responses." ,
223219 formatter_class = argparse .ArgumentDefaultsHelpFormatter
224220 )
221+ parser .add_argument (
222+ "open_ai_api_key" ,
223+ help = "Path to file with API key to OpenAI compatible inference provider" ,
224+ type = str ,
225+ )
225226 parser .add_argument (
226227 "data_directory" , help = "Path to the directory containing the sample data."
227228 )
@@ -245,9 +246,7 @@ def main():
245246 )
246247 args = parser .parse_args ()
247248
248- if not API_KEY :
249- print ("Error: OPENAI_API_KEY environment variable not set." , file = sys .stderr )
250- sys .exit (1 )
249+ open_ai_api_key = get_api_key_from_file (args .open_ai_api_key )
251250
252251 if not os .path .isdir (args .data_directory ):
253252 print (f"Error: Directory not found at '{ args .data_directory } '" , file = sys .stderr )
@@ -262,7 +261,7 @@ def main():
262261 server_address = args .logdetective_url ,
263262 llm_url = args .llm_url ,
264263 llm_model = args .llm_model ,
265- llm_token = API_KEY ,
264+ llm_token = open_ai_api_key ,
266265 log_detective_api_timeout = args .log_detective_api_timeout ,
267266 log_detective_api_key = log_detective_api_key
268267 )
0 commit comments