well that was fucking retarded
This commit is contained in:
parent
9b78aa2ce5
commit
65fbb69733
2 changed files with 22 additions and 20 deletions
25
main.py
25
main.py
|
|
@ -4,6 +4,8 @@ from dotenv import load_dotenv
|
|||
from discord import app_commands
|
||||
from discord.ext import commands
|
||||
from tools import searxng, open_url, run_command
|
||||
from traceback import print_exc
|
||||
import asyncio
|
||||
import os
|
||||
import io
|
||||
import discord
|
||||
|
|
@ -38,11 +40,24 @@ async def generation(interaction: discord.Interaction) -> None:
|
|||
@app_commands.allowed_contexts(guilds=True, dms=True, private_channels=True)
|
||||
async def ask(interaction: discord.Interaction, prompt: str) -> None:
|
||||
await interaction.response.defer()
|
||||
response = await client.aio.models.generate_content(
|
||||
model="gemini-2.5-flash",
|
||||
contents=prompt,
|
||||
config=config
|
||||
)
|
||||
response: types.GenerateContentResponse | None = None
|
||||
for _ in range(5):
|
||||
try:
|
||||
response = await client.aio.models.generate_content(
|
||||
model="gemini-2.5-flash",
|
||||
contents=[
|
||||
prompt
|
||||
],
|
||||
config=config
|
||||
)
|
||||
break
|
||||
except:
|
||||
print_exc()
|
||||
await asyncio.sleep(10)
|
||||
continue
|
||||
if not response:
|
||||
await interaction.edit_original_response(content="`[E] API Error. Please try again later.`")
|
||||
return
|
||||
if not response.text:
|
||||
await interaction.edit_original_response(content="`[E] Model returned no response`")
|
||||
generation: str = response.text or ""
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue