|
@@ -75,7 +75,7 @@ class MatchArticlesTask(object):
|
|
for question_key in question_dict:
|
|
for question_key in question_dict:
|
|
question = question_dict[question_key]
|
|
question = question_dict[question_key]
|
|
material = generate_text(question)
|
|
material = generate_text(question)
|
|
- material_dict[question] = material_dict
|
|
|
|
|
|
+ material_dict[question] = material
|
|
|
|
|
|
material_result = json.dumps(material_dict, ensure_ascii=False)
|
|
material_result = json.dumps(material_dict, ensure_ascii=False)
|
|
update_sql = f"""
|
|
update_sql = f"""
|
|
@@ -83,6 +83,7 @@ class MatchArticlesTask(object):
|
|
SET materials = '{material_result}', status_code = 2
|
|
SET materials = '{material_result}', status_code = 2
|
|
WHERE task_id = '{task_id}'
|
|
WHERE task_id = '{task_id}'
|
|
"""
|
|
"""
|
|
|
|
+ print(update_sql)
|
|
await mysql_client.async_insert(sql=update_sql)
|
|
await mysql_client.async_insert(sql=update_sql)
|
|
|
|
|
|
for task in task_list:
|
|
for task in task_list:
|
|
@@ -93,17 +94,22 @@ class MatchArticlesTask(object):
|
|
通过ai工具和材料来生成文章
|
|
通过ai工具和材料来生成文章
|
|
:return:
|
|
:return:
|
|
"""
|
|
"""
|
|
- select_sql = f"""SELECT task_id, video_title, materials FROM '{db_config}' WHERE status_code = 2 ORDER BY id ASC limit 10;"""
|
|
|
|
|
|
+ select_sql = f"""SELECT task_id, video_title, materials FROM {db_config} WHERE status_code = 2 ORDER BY id ASC limit 10;"""
|
|
task_list = await self.mysql_client.select(sql=select_sql)
|
|
task_list = await self.mysql_client.select(sql=select_sql)
|
|
|
|
|
|
async def ai_generate_text(task_tuple, mysql_client):
|
|
async def ai_generate_text(task_tuple, mysql_client):
|
|
task_id, video_title, materials = task_tuple
|
|
task_id, video_title, materials = task_tuple
|
|
imgs, ai_title, ai_text = summary_articles(materials)
|
|
imgs, ai_title, ai_text = summary_articles(materials)
|
|
|
|
+ print(imgs)
|
|
|
|
+ print(ai_text)
|
|
|
|
+ print(ai_text)
|
|
update_sql = f"""
|
|
update_sql = f"""
|
|
UPDATE {db_config}
|
|
UPDATE {db_config}
|
|
SET ai_text = '{ai_text}', ai_title = '{ai_title}', img_list = '{json.dumps(imgs, ensure_ascii=False)}',status_code = 3
|
|
SET ai_text = '{ai_text}', ai_title = '{ai_title}', img_list = '{json.dumps(imgs, ensure_ascii=False)}',status_code = 3
|
|
WHERE task_id = '{task_id}';
|
|
WHERE task_id = '{task_id}';
|
|
"""
|
|
"""
|
|
|
|
+ print(update_sql)
|
|
|
|
+ await mysql_client.async_insert(sql=update_sql)
|
|
|
|
|
|
for task in task_list:
|
|
for task in task_list:
|
|
await ai_generate_text(task, self.mysql_client)
|
|
await ai_generate_text(task, self.mysql_client)
|
|
@@ -248,7 +254,7 @@ class MatchArticlesV2(object):
|
|
"title": ai_title,
|
|
"title": ai_title,
|
|
"cover": cover,
|
|
"cover": cover,
|
|
"content": ai_text,
|
|
"content": ai_text,
|
|
- "images": images,
|
|
|
|
|
|
+ "images": json.loads(images),
|
|
"videos": [
|
|
"videos": [
|
|
self.get_basic_video_info(video_id)
|
|
self.get_basic_video_info(video_id)
|
|
]
|
|
]
|