aboutsummaryrefslogtreecommitdiff
path: root/main.py
diff options
context:
space:
mode:
authorGravatar Anshul Gupta <ansg191@anshulg.com> 2024-11-17 13:27:55 -0800
committerGravatar Anshul Gupta <ansg191@anshulg.com> 2024-11-17 13:27:55 -0800
commitc90c08d05755f8c94be0ea8131b063701fb6dedb (patch)
tree1e083e84172a63399abcd60aeb77c13e767820f4 /main.py
parent333882de824732324aa5b8dd6f0fea70732cba16 (diff)
parent4f2a445302056a4de201927060a1da7bfbd13f11 (diff)
downloadminiflux-ai-main.tar.gz
miniflux-ai-main.tar.zst
miniflux-ai-main.zip
Merge branch 'image-processing'HEADmain
Diffstat (limited to 'main.py')
-rw-r--r--main.py11
1 files changed, 11 insertions, 0 deletions
diff --git a/main.py b/main.py
index 514f410..67eda1a 100644
--- a/main.py
+++ b/main.py
@@ -3,6 +3,7 @@ import time
import traceback
from common.logger import logger
from core.entry_filter import filter_entry
+from core.image import contains_image
import miniflux
from markdownify import markdownify as md
@@ -20,8 +21,18 @@ def process_entry(entry):
for agent in config['agents'].items():
messages = [
{"role": "system", "content": agent[1]['prompt']},
+ {"role": "user", "content": "The following is the title:\n---\n " + entry['title']},
+ {"role": "user", "content": "The following is the author:\n---\n " + entry['author']},
{"role": "user", "content": "The following is the input content:\n---\n " + md(entry['content']) }
]
+
+ image_url = contains_image(entry['content'])
+ if image_url:
+ messages.append({"role": "user", "content": [
+ {"type": "text", "text": "The following is the first image in the content:"},
+ {"type": "image_url", "image_url": {"url": image_url}}
+ ]})
+
# filter, if AI is not generating, and in allow_list, or not in deny_list
if filter_entry(config, agent, entry):
completion = llm_client.chat.completions.create(