mirror of
https://github.com/alterware/aw-bot.git
synced 2025-10-26 22:16:58 +00:00
feat: basic chat with Gemini
This commit is contained in:
1
bot/ai/__init__.py
Normal file
1
bot/ai/__init__.py
Normal file
@@ -0,0 +1 @@
|
||||
from .handle_request import forward_to_google_api
|
||||
23
bot/ai/handle_request.py
Normal file
23
bot/ai/handle_request.py
Normal 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,
|
||||
)
|
||||
Reference in New Issue
Block a user