Skip to content

Commit

Permalink
display url from api server if available (#444)
Browse files Browse the repository at this point in the history
* fix non-string debug logs

* get url from server

* bump version
  • Loading branch information
siyangqiu authored Oct 14, 2024
1 parent 8061065 commit d04622a
Show file tree
Hide file tree
Showing 4 changed files with 23 additions and 13 deletions.
13 changes: 3 additions & 10 deletions agentops/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -242,23 +242,16 @@ def start_session(
config=self._config,
)

if not session.is_running:
return logger.error("Failed to start session")

if self._pre_init_queue["agents"] and len(self._pre_init_queue["agents"]) > 0:
for agent_args in self._pre_init_queue["agents"]:
session.create_agent(
name=agent_args["name"], agent_id=agent_args["agent_id"]
)
self._pre_init_queue["agents"] = []

if not session.is_running:
return logger.error("Failed to start session")

logger.info(
colored(
f"\x1b[34mSession Replay: https://app.agentops.ai/drilldown?session_id={session.session_id}\x1b[0m",
"blue",
)
)

self._sessions.append(session)
return session

Expand Down
2 changes: 1 addition & 1 deletion agentops/log_config.py
Original file line number Diff line number Diff line change
Expand Up @@ -38,7 +38,7 @@ def format(self, record):
class AgentOpsLogFileFormatter(logging.Formatter):
def format(self, record):
# Remove ANSI escape codes from the message
record.msg = ANSI_ESCAPE_PATTERN.sub("", record.msg)
record.msg = ANSI_ESCAPE_PATTERN.sub("", str(record.msg))
return super().format(record)


Expand Down
19 changes: 18 additions & 1 deletion agentops/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -162,9 +162,14 @@ def format_duration(start_time, end_time):
)
logger.info(analytics)

session_url = res.body.get(
"session_url",
f"https://app.agentops.ai/drilldown?session_id={self.session_id}",
)

logger.info(
colored(
f"\x1b[34mSession Replay: https://app.agentops.ai/drilldown?session_id={self.session_id}\x1b[0m",
f"\x1b[34mSession Replay: {session_url}\x1b[0m",
"blue",
)
)
Expand Down Expand Up @@ -281,6 +286,18 @@ def _start_session(self):
if jwt is None:
return False

session_url = res.body.get(
"session_url",
f"https://app.agentops.ai/drilldown?session_id={self.session_id}",
)

logger.info(
colored(
f"\x1b[34mSession Replay: {session_url}\x1b[0m",
"blue",
)
)

return True

def _update_session(self) -> None:
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -4,7 +4,7 @@ build-backend = "setuptools.build_meta"

[project]
name = "agentops"
version = "0.3.13"
version = "0.3.14"
authors = [
{ name="Alex Reibman", email="[email protected]" },
{ name="Shawn Qiu", email="[email protected]" },
Expand Down

0 comments on commit d04622a

Please sign in to comment.