Improve trump speed
All checks were successful
Build and Publish college-bot-v2 / build_and_publish (push) Successful in 14s

This commit is contained in:
Nexus 2024-06-05 03:04:47 +01:00
parent c3940daa96
commit cc4198dffe
Signed by: nex
GPG key ID: 0FA334385D0B689F

View file

@ -20,6 +20,7 @@ from discord.ui import View, button
from yarl import URL
from conf import CONFIG
from .quote_quota import TruthPayload
async def ollama_stream(iterator: aiohttp.StreamReader) -> typing.AsyncIterator[dict]:
@ -1036,10 +1037,11 @@ class Ollama(commands.Cog):
auth=(username, password),
)
response.raise_for_status()
truths = response.json()
truths: list[dict] = response.json()
truths: list[TruthPayload] = list(map(lambda t: TruthPayload.model_validate(t), truths))
for truth in truths:
if truth["author"] == "trump":
self.history.add_message(thread_id, "assistant", truth["content"], save=False)
if truth.author == "trump":
self.history.add_message(thread_id, "assistant", truth.content, save=False)
break
self.history.add_message(thread_id, "user", "Generate a new truth post.")