Include fuzzy matching for truths
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 2m5s

This commit is contained in:
Nexus 2024-06-07 20:08:18 +01:00
parent 5ffbd3635b
commit 3109f645e6
Signed by: nex
GPG key ID: 0FA334385D0B689F
2 changed files with 8 additions and 1 deletions

View file

@ -23,3 +23,4 @@ python-magic~=0.4
aiofiles~=23.2
fastapi~=0.111
uvicorn[standard]~=0.30
fuzzywuzzy[speedup]~=0.18

View file

@ -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,