diff --git a/eve/clients/common.py b/eve/clients/common.py index be04f82..2d5d3de 100644 --- a/eve/clients/common.py +++ b/eve/clients/common.py @@ -1,10 +1,9 @@ import os import time -import modal - from eve.models import ClientType +db = os.getenv("DB", "STAGE") HOUR_IMAGE_LIMIT = 50 HOUR_VIDEO_LIMIT = 10 @@ -105,3 +104,8 @@ def register_tool_call(user, tool_name): def get_ably_channel_name(agent_username: str, client_platform: ClientType): env = os.getenv("UPDATE_CHANNEL_ENV", "DEV") return f"{agent_username.lower()}_{client_platform.value}_{env}" + + +def get_eden_creation_url(creation_id: str): + root_url = "beta.eden.art" if db == "PROD" else "staging2.app.eden.art" + return f"https://{root_url}/creations/{creation_id}" diff --git a/eve/clients/discord/client.py b/eve/clients/discord/client.py index b953e35..391d7f0 100644 --- a/eve/clients/discord/client.py +++ b/eve/clients/discord/client.py @@ -130,8 +130,27 @@ async def async_callback(message): elif update_type == UpdateType.TOOL_COMPLETE: result = data.get("result", {}) result["result"] = prepare_result(result["result"]) - url = result["result"][0]["output"][0]["url"] - await self.send_message(channel, url, reference=reference) + output = result["result"][0]["output"][0] + url = output["url"] + + # Get creation ID from the output + creation_id = str(output.get("creation")) + + if creation_id: + eden_url = common.get_eden_creation_url(creation_id) + view = discord.ui.View() + view.add_item( + discord.ui.Button( + label="View on Eden", + url=eden_url, + style=discord.ButtonStyle.link, + ) + ) + await self.send_message( + channel, url, reference=reference, view=view + ) + else: + await self.send_message(channel, url, reference=reference) elif update_type == UpdateType.END_PROMPT: await self.stop_typing(channel) @@ -243,10 +262,12 @@ async def on_message(self, message: discord.Message) -> None: async def on_member_join(self, member): print(f"{member} has joined the guild id: {member.guild.id}") - async def send_message(self, channel, content, reference=None, limit=2000): + async def send_message( + self, channel, content, reference=None, limit=2000, view=None + ): for i in range(0, len(content), limit): chunk = content[i : i + limit] - await channel.send(chunk, reference=reference) + await channel.send(chunk, reference=reference, view=view) async def start_typing(self, channel): """