aboutsummaryrefslogtreecommitdiffstats
path: root/summarizer.py
diff options
context:
space:
mode:
authorPinapelz <yukais@pinapelz.com>2025-07-13 12:22:04 -0700
committerPinapelz <yukais@pinapelz.com>2025-07-13 12:22:04 -0700
commitbd650f563a07b7d0d5941ca080b5a9247aaa01ab (patch)
treee9d11d293faaa53fee18496805cfc1345827f0b2 /summarizer.py
parent8ddd5b16b20db12fc1e7ecbf235802e9fd49b4d0 (diff)
allow for message content consideration for summarizations
Diffstat (limited to 'summarizer.py')
-rw-r--r--summarizer.py12
1 files changed, 8 insertions, 4 deletions
diff --git a/summarizer.py b/summarizer.py
index d3d66f1..eefff7c 100644
--- a/summarizer.py
+++ b/summarizer.py
@@ -5,7 +5,7 @@ import hashlib
import os
load_dotenv()
-
+MAX_CHAR_CONTENT_CONSIDERATION_LENGTH = 1000
def summarization_is_possible() -> bool:
return os.getenv("OPENAI_API_KEY")
@@ -33,10 +33,14 @@ def _make_cache_key(game: str, img_urls: list[str]) -> str:
return f"{normalized_game}_{hash_digest}"
-def generate_headline_and_content_from_images(img_urls: list[str], game: str):
+def generate_headline_and_content_from_images(img_urls: list[str], game: str, message_content: str=""):
"""
Uses LLM to generate the headline and content when none provided by source, based on one or more images.
"""
+ # Limit message content to 500 characters
+ if len(message_content) > MAX_CHAR_CONTENT_CONSIDERATION_LENGTH:
+ message_content = message_content[:MAX_CHAR_CONTENT_CONSIDERATION_LENGTH]
+
cache = _load_cache()
cache_key = _make_cache_key(game, img_urls)
if cache_key in cache:
@@ -47,7 +51,7 @@ def generate_headline_and_content_from_images(img_urls: list[str], game: str):
"type": "function",
"function": {
"name": "generate_update_text",
- "description": "Generates a concise English headline and short description for a rhythm game update image.",
+ "description": "Generates a concise English headline and short description for a rhythm game update image and the original message content.",
"parameters": {
"type": "object",
"properties": {
@@ -73,7 +77,7 @@ def generate_headline_and_content_from_images(img_urls: list[str], game: str):
{
"type": "text",
"text": (
- f"Given one or more update-related images for the arcade game {game}, return a short, professional English headline and a brief, stern and concise description summarizing the content. No need to repeat game name"
+ f"Given one or more update-related images for the arcade game {game} and the original Discord message content (limited to 500 characters): '{message_content}', return a short, professional English headline and a brief, stern and concise description summarizing the content. No need to repeat game name"
),
},
*[{"type": "image_url", "image_url": {"url": url}} for url in img_urls],
send patches to the email below
yukais@pinapelz.com
include the subject [PATCH repo_name]
pinapelz.com
homepage