feat(api): !chat 명령어 추가 — 단순 대화용 Gemini 직접 호출 #task-191
This commit is contained in:
@@ -138,6 +138,38 @@ async def agent_command(ctx: commands.Context, *, request: str):
|
||||
await ctx.send(embed=error_embed)
|
||||
|
||||
|
||||
@bot.command(name="chat", help="Gemini에게 질문/대화\n예: !chat 네 소개를 해줘")
|
||||
async def chat_command(ctx: commands.Context, *, message: str):
|
||||
"""단순 대화 — Pipeline 없이 Gemini 직접 호출."""
|
||||
async with ctx.typing():
|
||||
try:
|
||||
from core.gemini_caller import GeminiCaller
|
||||
|
||||
gemini = GeminiCaller(str(config.PROJECT_ROOT))
|
||||
response = await gemini.call(
|
||||
role="default",
|
||||
context=message,
|
||||
timeout=60,
|
||||
)
|
||||
|
||||
# Discord 메시지 2000자 제한 처리
|
||||
if len(response) <= 2000:
|
||||
await ctx.send(response)
|
||||
else:
|
||||
# 긴 응답은 Embed로 분할
|
||||
for i in range(0, len(response), 4000):
|
||||
chunk = response[i:i + 4000]
|
||||
embed = discord.Embed(
|
||||
description=chunk,
|
||||
color=0x3498DB,
|
||||
)
|
||||
await ctx.send(embed=embed)
|
||||
|
||||
except Exception as e:
|
||||
logger.error(f"Chat 오류: {e}", exc_info=True)
|
||||
await ctx.send(f"❌ 오류: {str(e)[:200]}")
|
||||
|
||||
|
||||
@bot.command(name="ping", help="봇 응답 테스트")
|
||||
async def ping_command(ctx: commands.Context):
|
||||
"""연결 상태 확인."""
|
||||
|
||||
Reference in New Issue
Block a user