Include fuzzy matching for truths
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 2m5s
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 2m5s
This commit is contained in:
parent
5ffbd3635b
commit
3109f645e6
2 changed files with 8 additions and 1 deletions
|
@ -23,3 +23,4 @@ python-magic~=0.4
|
|||
aiofiles~=23.2
|
||||
fastapi~=0.111
|
||||
uvicorn[standard]~=0.30
|
||||
fuzzywuzzy[speedup]~=0.18
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in a new issue