File tree Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Expand file tree Collapse file tree 1 file changed +19
-1
lines changed Original file line number Diff line number Diff line change @@ -36,11 +36,29 @@ def __init__(self):
3636
3737 def initialize_openai (self ):
3838 client = OpenAI ()
39- client .api_key = os .getenv ("OPENAI_API_KEY" )
39+ if self .openai_api_key :
40+ if self .verbose :
41+ print ("[Config][initialize_openai] using cached openai_api_key" )
42+ api_key = self .openai_api_key
43+ else :
44+ print (
45+ "[Config][initialize_openai] no cached openai_api_key, try to get from env."
46+ )
47+ api_key = os .getenv ("OPENAI_API_KEY" )
48+ client .api_key = api_key
4049 client .base_url = os .getenv ("OPENAI_API_BASE_URL" , client .base_url )
4150 return client
4251
4352 def initialize_google (self ):
53+ if self .google_api_key :
54+ if self .verbose :
55+ print ("[Config][initialize_google] using cached google_api_key" )
56+ api_key = self .google_api_key
57+ else :
58+ print (
59+ "[Config][initialize_google] no cached google_api_key, try to get from env."
60+ )
61+ api_key = os .getenv ("GOOGLE_API_KEY" )
4462 genai .configure (api_key = os .getenv ("GOOGLE_API_KEY" ), transport = "rest" )
4563 model = genai .GenerativeModel ("gemini-pro-vision" )
4664
You can’t perform that action at this time.
0 commit comments