File tree 6 files changed +33
-1
lines changed
6 files changed +33
-1
lines changed Original file line number Diff line number Diff line change
1
+ # Development Setting
2
+ INTERNAL =
3
+ ALLES =
4
+ DASHSCOPE_API_KEY =
5
+ GOOGLE_API_KEY =
6
+ OPENAI_API_KEY =
7
+ OPENAI_API_BASE =
Original file line number Diff line number Diff line change @@ -120,7 +120,7 @@ celerybeat.pid
120
120
* .sage.py
121
121
122
122
# Environments
123
- .env
123
+ # .env
124
124
.venv
125
125
env /
126
126
venv /
Original file line number Diff line number Diff line change @@ -11,6 +11,7 @@ pandas>=1.5.3
11
11
pillow
12
12
portalocker
13
13
pycocoevalcap
14
+ python-dotenv
14
15
requests
15
16
rich
16
17
seaborn
Original file line number Diff line number Diff line change @@ -144,4 +144,5 @@ def main():
144
144
145
145
146
146
if __name__ == '__main__' :
147
+ load_env ()
147
148
main ()
Original file line number Diff line number Diff line change 1
1
import os
2
2
from vlmeval .api import OpenAIWrapper , OpenAIWrapperInternal
3
+ from vlmeval .smp import load_env
3
4
4
5
INTERNAL = os .environ .get ('INTERNAL' , 0 )
5
6
6
7
7
8
def build_judge (version , ** kwargs ):
9
+ load_env ()
8
10
model_map = {
9
11
'gpt-4-turbo' : 'gpt-4-1106-preview' ,
10
12
'gpt-4-0613' : 'gpt-4-0613' ,
Original file line number Diff line number Diff line change @@ -147,3 +147,24 @@ def run_command(cmd):
147
147
if isinstance (cmd , str ):
148
148
cmd = cmd .split ()
149
149
return subprocess .check_output (cmd )
150
+
151
+ def load_env ():
152
+ try :
153
+ import vlmeval
154
+ except ImportError :
155
+ warnings .warn ('VLMEval is not installed. Failed to import environment variables from .env file. ' )
156
+ return
157
+ pth = osp .realpath (vlmeval .__path__ )
158
+ pth = osp .join ('../.env' )
159
+ pth = osp .realpath (pth )
160
+ if not osp .exists (pth ):
161
+ warnings .warn (f'Did not detect the .env file at { pth } , failed to load. ' )
162
+ return
163
+
164
+ from dotenv import dotenv_values
165
+ values = dotenv_values (pth )
166
+ for k , v in values .items ():
167
+ if v is not None and len (v ):
168
+ os .environ [k ] = v
169
+ print (f'API Keys successfully loaded from { pth } ' )
170
+ return
You can’t perform that action at this time.
0 commit comments