diff options
author | 2024-11-15 14:13:32 -0800 | |
---|---|---|
committer | 2024-11-15 14:20:23 -0800 | |
commit | a9409f08bac76b041fda8675858290d915a183aa (patch) | |
tree | a9c6b1f9430351b85f9c2400cd765e848638c8af /main.py | |
parent | cd2f847c940a5cf110d138a48d66d1140b76c4f8 (diff) | |
download | miniflux-ai-a9409f08bac76b041fda8675858290d915a183aa.tar.gz miniflux-ai-a9409f08bac76b041fda8675858290d915a183aa.tar.zst miniflux-ai-a9409f08bac76b041fda8675858290d915a183aa.zip |
Add image processing and extra data to openai call
Diffstat (limited to 'main.py')
-rw-r--r-- | main.py | 11 |
1 files changed, 11 insertions, 0 deletions
@@ -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( |