Update src/Captioner.py
Browse files- src/Captioner.py +15 -15
src/Captioner.py
CHANGED
|
@@ -8,25 +8,25 @@ import json
|
|
| 8 |
class Captioner:
|
| 9 |
def __init__(self, api_key_path = None, proxy=None, api_base="https://api.lingyiwanwu.com/v1"):
|
| 10 |
|
| 11 |
-
if api_key_path is None:
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
| 15 |
-
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
|
| 21 |
-
|
| 22 |
-
|
| 23 |
|
| 24 |
|
| 25 |
-
self.api_key =
|
| 26 |
self.api_base = api_base
|
| 27 |
-
if proxy:
|
| 28 |
-
|
| 29 |
-
|
| 30 |
self.client = OpenAI(
|
| 31 |
api_key=self.api_key,
|
| 32 |
base_url=self.api_base
|
|
|
|
| 8 |
class Captioner:
|
| 9 |
def __init__(self, api_key_path = None, proxy=None, api_base="https://api.lingyiwanwu.com/v1"):
|
| 10 |
|
| 11 |
+
# if api_key_path is None:
|
| 12 |
+
# # try find datas/01_key.txt and ../datas/01_key.txt
|
| 13 |
+
# cand_paths = ['datas/01_key.txt', '../datas/01_key.txt']
|
| 14 |
+
# flag = False
|
| 15 |
+
# for path in cand_paths:
|
| 16 |
+
# if os.path.exists(path):
|
| 17 |
+
# api_key_path = path
|
| 18 |
+
# flag = True
|
| 19 |
+
# break
|
| 20 |
|
| 21 |
+
# if not flag:
|
| 22 |
+
# raise ValueError("Please provide the path to the API key file.")
|
| 23 |
|
| 24 |
|
| 25 |
+
self.api_key = os.getenv('YI_VL_KEY')
|
| 26 |
self.api_base = api_base
|
| 27 |
+
# if proxy:
|
| 28 |
+
# os.environ['HTTP_PROXY'] = proxy
|
| 29 |
+
# os.environ['HTTPS_PROXY'] = proxy
|
| 30 |
self.client = OpenAI(
|
| 31 |
api_key=self.api_key,
|
| 32 |
base_url=self.api_base
|