feat: basic chat with Gemini

This commit is contained in:
2025-04-14 17:01:00 +02:00
parent 20976b4502
commit 8fe40326b7
4 changed files with 35 additions and 0 deletions

1
bot/ai/__init__.py Normal file
View File

@@ -0,0 +1 @@
from .handle_request import forward_to_google_api

23
bot/ai/handle_request.py Normal file
View File

@@ -0,0 +1,23 @@
import os
from google import genai
API_KEY = os.getenv("GOOGLE_API_KEY")
async def forward_to_google_api(prompt):
"""
Forwards the message content and optional image URL to a Google API.
Args:
prompt (discord.Message): The message object to forward.
"""
client = genai.Client(api_key=API_KEY)
response = client.models.generate_content(
model="gemini-2.0-flash", contents=prompt.content
)
await prompt.reply(
response.text,
mention_author=True,
)