This commit is contained in:
2025-02-18 22:11:35 +01:00
parent a1d7833c1d
commit 99be4cbab2

View File

@@ -93,7 +93,7 @@ class MessageEvent(BaseModel):
async def get_completion(message: str):
async def get_completion(message: str) -> str:
async with AsyncClient() as client:
response = await client.post(
"https://openrouter.ai/api/v1/chat/completions",
@@ -143,13 +143,14 @@ class MessagesProc:
try:
completion = await get_completion(event.message.text)
if not completion:
completion = "Пошел нахуй!"
max_length = 255
completion_parts = [completion[i:i + max_length] for i in range(0, len(completion), max_length)]
for part in completion_parts:
await twitch.send_chat_message(
event.broadcaster_user_id,
config.TWITCH_ADMIN_USER_ID,
completion,
part,
reply_parent_message_id=event.message_id
)
except Exception as e: