diff options
| author | Pinapelz <yukais@pinapelz.com> | 2025-04-25 01:07:44 -0700 |
|---|---|---|
| committer | Pinapelz <yukais@pinapelz.com> | 2025-04-25 01:07:44 -0700 |
| commit | 71767853b0f65352b7418cc9a14f17acc5dbd9b8 (patch) | |
| tree | 4cc0e35d6a33790eafc9b12d06eae31aa6f2022a /community | |
| parent | 4b0998b4afa48f9e2968b1bb76ef42bc6a94e1b6 (diff) | |
add ai generated headline and content when source does not provides any
Diffstat (limited to 'community')
| -rw-r--r-- | community/wacca_plus/wacca_plus.py | 13 |
1 files changed, 10 insertions, 3 deletions
diff --git a/community/wacca_plus/wacca_plus.py b/community/wacca_plus/wacca_plus.py index d5e0aa4..fae3dd0 100644 --- a/community/wacca_plus/wacca_plus.py +++ b/community/wacca_plus/wacca_plus.py @@ -6,6 +6,10 @@ import openai import json from dotenv import load_dotenv import base64 +import sys +sys.path.append(os.path.abspath(os.path.join(os.path.dirname(__file__), "../../"))) + +from summarizer import generate_headline_and_content_from_images load_dotenv() @@ -99,7 +103,9 @@ def parse_announcement_messages(message_json: dict): continue filtered_images = [] + image_urls = [] # save the images before they get encoded for image in image_attachments: + image_urls.append(image["url"]) if image["id"] in cache: is_related = cache[image["id"]][0] type = cache[image["id"]][1] @@ -116,17 +122,18 @@ def parse_announcement_messages(message_json: dict): date = message["timestamp"].split("T")[0] date_obj = datetime.strptime(date, "%Y-%m-%d") unix_time = int(time.mktime(date_obj.timetuple())) + headline, content = generate_headline_and_content_from_images(image_urls, "WACCA PLUS") news_posts.append({ "date": date, "identifier": "WACCA_PLUS", "type": type.upper(), "timestamp": unix_time, - "content": "NEW INFORMATION FROM WACCA PLUS / WACCA PLUS の最新情報", - "headline": None, + "content": content, + "headline": headline, "url": None, "images": filtered_images, - 'is_ai_summary': False + 'is_ai_summary': True }) _save_cache(cache) |
