diff --git a/requirements.txt b/requirements.txt index 8fc8697..8bc947c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -23,3 +23,4 @@ python-magic~=0.4 aiofiles~=23.2 fastapi~=0.111 uvicorn[standard]~=0.30 +fuzzywuzzy[speedup]~=0.18 diff --git a/src/cogs/ollama.py b/src/cogs/ollama.py index e6d094a..3c0c248 100644 --- a/src/cogs/ollama.py +++ b/src/cogs/ollama.py @@ -18,6 +18,7 @@ from discord import Interaction from discord.ext import commands from discord.ui import View, button from yarl import URL +from fuzzywuzzy import fuzz from conf import CONFIG from .quote_quota import TruthPayload @@ -1115,12 +1116,17 @@ class Ollama(commands.Cog): last_edit = time.time() for truth in truths: + _ratio = fuzz.ratio(truth.content, embed.description) if truth.content == embed.description: embed.add_field( name="Repeated truth :(", value="This truth was already truthed. Shit AI." ) - break + elif _ratio >= 70: + embed.add_field( + name="Likely repeated truth", + value=f"Is a {_ratio:.2f}% match to truth {truth.id!r}." + ) embed.set_footer( text="Finished generating truth based off of {:,} messages, using server {!r} | {!s}".format( len(messages) - 2,