Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

feat(core): log inspector link on startup #528

Merged
merged 5 commits into from
Sep 10, 2024
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
17 changes: 16 additions & 1 deletion python/src/uagents/agent.py
Original file line number Diff line number Diff line change
Expand Up @@ -240,6 +240,7 @@ class Agent(Sink):
corresponding protocols.
_ctx (Context): The context for agent interactions.
_test (bool): True if the agent will register and transact on the testnet.
_enable_agent_inspector (bool): Enable the agent inspector REST endpoints.

Properties:
name (str): The name of the agent.
Expand Down Expand Up @@ -421,6 +422,8 @@ async def _handle_get_info(_ctx: Context):
async def _handle_get_messages(_ctx: Context):
return self._message_cache

self._enable_agent_inspector = enable_agent_inspector

self._init_done = True

def _initialize_wallet_and_identity(self, seed, name, wallet_key_derivation_index):
Expand Down Expand Up @@ -1076,14 +1079,26 @@ def start_message_receivers(self):
]:
self._loop.create_task(task)

async def start_server(self):
"""
Start the agent's server.

"""
if self._enable_agent_inspector:
inspector_url = f"{self._agentverse['http_prefix']}://{self._agentverse['base_url']}/inspect"
self._logger.debug(
f"Agent inspector available at {inspector_url}/?uri=http://127.0.0.1:{self._port}"
)
await self._server.serve()

async def run_async(self):
"""
Create all tasks for the agent.

"""
await self.setup()

tasks = [self._server.serve()]
tasks = [self.start_server()]

# remove server task if mailbox is enabled and no REST handlers are defined
if self._use_mailbox and not self._rest_handlers:
Expand Down
Loading