Update zhipuai_gen_data.py 修改生成的数量

This commit is contained in:
HongCheng 2024-03-17 00:17:03 +09:00 committed by GitHub
parent 60fe587f06
commit 9bcb5acab7
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194

View File

@ -72,12 +72,15 @@ if __name__ == '__main__':
areas_of_life = configs['areas_of_life'] areas_of_life = configs['areas_of_life']
ai_tool = 'zhipuai' ai_tool = 'zhipuai'
save_interval = 5
total_num_each_emo_area = 5
conversation_lis = [] conversation_lis = []
for area in areas_of_life: for area in areas_of_life:
for emo in emotions_lis: for emo in emotions_lis:
gen_path = f'./{ai_tool}/{area}/{emo}.jsonl' gen_path = f'./{ai_tool}/{area}/{emo}.jsonl'
for i in tqdm(range(100), desc='{emo}, {area}'.format(emo=emo, area=area)): for i in tqdm(range(total_num_each_emo_area), desc='{emo}, {area}'.format(emo=emo, area=area)):
res = zhipu_api(area, emo) res = zhipu_api(area, emo)
print(res) print(res)
if res == 'null': if res == 'null':
@ -85,7 +88,7 @@ if __name__ == '__main__':
continue continue
conversation_lis.append(convert(res)) conversation_lis.append(convert(res))
if ((i+1) % 10 == 0): if ((i+1) % save_interval == 0):
# path = f'./{args.data}.jsonl' # path = f'./{args.data}.jsonl'
save_jsonl(data_lis=conversation_lis, file_path=gen_path) save_jsonl(data_lis=conversation_lis, file_path=gen_path)
print(f'generate {gen_path}') print(f'generate {gen_path}')