From 26cef9bb11162dabf27e572130082f4f3328076a Mon Sep 17 00:00:00 2001 From: quantlab Date: Fri, 6 Mar 2026 18:59:34 +0900 Subject: [PATCH] =?UTF-8?q?feat(api):=20!chat=20=EB=AA=85=EB=A0=B9?= =?UTF-8?q?=EC=96=B4=20=EC=B6=94=EA=B0=80=20=E2=80=94=20=EB=8B=A8=EC=88=9C?= =?UTF-8?q?=20=EB=8C=80=ED=99=94=EC=9A=A9=20Gemini=20=EC=A7=81=EC=A0=91=20?= =?UTF-8?q?=ED=98=B8=EC=B6=9C=20#task-191?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- api/discord_bot.py | 32 ++++++++++++++++++++++++++++++++ 1 file changed, 32 insertions(+) diff --git a/api/discord_bot.py b/api/discord_bot.py index 493bb64..3794818 100644 --- a/api/discord_bot.py +++ b/api/discord_bot.py @@ -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): """연결 상태 확인."""