Spaces:
Sleeping
Sleeping
Tuchuanhuhuhu
commited on
Commit
·
478872e
1
Parent(s):
432eb42
feat: 防止重复添加模型
Browse files- modules/train_func.py +6 -2
modules/train_func.py
CHANGED
@@ -114,12 +114,16 @@ def add_to_models():
|
|
114 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
115 |
succeeded_jobs = [job for job in openai.FineTuningJob.list()["data"] if job["status"] == "succeeded"]
|
116 |
extra_models = [job["fine_tuned_model"] for job in succeeded_jobs]
|
117 |
-
|
|
|
|
|
118 |
|
119 |
with open('config.json', 'r') as f:
|
120 |
data = commentjson.load(f)
|
121 |
if 'extra_models' in data:
|
122 |
-
|
|
|
|
|
123 |
else:
|
124 |
data['extra_models'] = extra_models
|
125 |
with open('config.json', 'w') as f:
|
|
|
114 |
openai.api_key = os.getenv("OPENAI_API_KEY")
|
115 |
succeeded_jobs = [job for job in openai.FineTuningJob.list()["data"] if job["status"] == "succeeded"]
|
116 |
extra_models = [job["fine_tuned_model"] for job in succeeded_jobs]
|
117 |
+
for i in extra_models:
|
118 |
+
if i not in presets.MODELS:
|
119 |
+
presets.MODELS.append(extra_models)
|
120 |
|
121 |
with open('config.json', 'r') as f:
|
122 |
data = commentjson.load(f)
|
123 |
if 'extra_models' in data:
|
124 |
+
for i in extra_models:
|
125 |
+
if i not in data['extra_models']:
|
126 |
+
data['extra_models'].append(i)
|
127 |
else:
|
128 |
data['extra_models'] = extra_models
|
129 |
with open('config.json', 'w') as f:
|