Skip to content
Snippets Groups Projects
Commit ac1c1efa authored by Jan Eggers's avatar Jan Eggers
Browse files

gpt4_description gefixt

parent 5bb4c0f1
No related branches found
No related tags found
No related merge requests found
......@@ -10,7 +10,7 @@ authors = [
maintainers = [
{name = "Jan Eggers", email = "jan.eggers@hr.de"},
]
version = "0.2.3.4" # Neue Versionsnummern für pip-Update
version = "0.2.3.5" # Neue Versionsnummern für pip-Update
description = "Bluesky- und Telegram-Konten auf KI-Inhalte checken"
requires-python = ">=3.8"
dependencies = [
......
......@@ -193,7 +193,8 @@ def tg_post_parse(b, save = True, describe = True):
}
if describe:
# GPT4o-mini versteht JPG, PNG, nicht animiertes GIF... und WEBP.
sticker['description'] = gpt4_description(sticker_url)
image = base64.b64encode(requests.get(sticker_url).content).decode('utf-8')
photo['description'] = gpt4_description(f"data:image/jpeg;base64, {image}")
if save:
sticker['file'] = save_url(sticker_url, f"{channel}_{b_nr}_sticker")
else:
......@@ -205,7 +206,8 @@ def tg_post_parse(b, save = True, describe = True):
# 'image': base64.b64encode(requests.get(photo_url).content).decode('utf-8')
}
if describe:
photo['description'] = gpt4_description(f"data:image/jpeg;base64,{photo['image']}")
image = base64.b64encode(requests.get(photo_url).content).decode('utf-8')
photo['description'] = gpt4_description(f"data:image/jpeg;base64, {image}")
if save:
photo['file'] = save_url(photo_url, f"{channel}_{b_nr}_photo")
else:
......@@ -254,7 +256,8 @@ def tg_post_parse(b, save = True, describe = True):
if describe:
video['transcription'] = transcribe(video['file'])
if photo is not None:
photo['description'] = gpt4_description(f"data:image/jpeg;base64, {photo['image']}")
image = base64.b64encode(requests.get(video_thumbnail_url).content).decode('utf-8')
photo['description'] = gpt4_description(f"data:image/jpeg;base64, {image}")
else:
video = None
# Document / Audio URL? https://t.me/telegram/35
......
......@@ -13,6 +13,21 @@ from aiornot import Client
d_thresh = .8 # 80 Prozent
limit = 25 # Posts für den Check
def object_to_dict(obj):
"""Recursively converts an object to a dictionary."""
if isinstance(obj, dict):
# Recursively handle dictionaries
return {k: object_to_dict(v) for k, v in obj.items()}
elif hasattr(obj, "__dict__"):
# Handle objects with __dict__
return {k: object_to_dict(v) for k, v in vars(obj).items()}
elif isinstance(obj, (list, tuple, set)):
# Handle iterables
return type(obj)(object_to_dict(v) for v in obj)
else:
# Return the object if it cannot be converted
return obj
def detectora_wrapper(text: str):
# Verpackung. Fügt nur den "Fortschrittsbalken" hinzu.
print("?", end="")
......@@ -57,7 +72,7 @@ def aiornot_wrapper(content, is_image = True):
# Unterscheidung: Bilder haben den Confidence score im Unter-Key 'ai'
# Audios SOLLTEN eien Confidence-Wert in response.report.confidence haben, haben es aber nicht
'confidence': response.report.ai.confidence if hasattr(response.report, 'ai') else .99,
'generator': response.report.generator if hasattr(response.report, 'generator') else None,
'generator': object_to_dict(response.report.generator) if hasattr(response.report, 'generator') else None,
})
print(f"\b{'X' if aiornot_dict['score'] != 'human' else '.'}",end="")
return aiornot_dict
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment