Skip to content

Commit

Permalink
check ao version and warn for update (#326)
Browse files Browse the repository at this point in the history
  • Loading branch information
bboynton97 authored Aug 2, 2024
1 parent de23413 commit 4fe5b37
Show file tree
Hide file tree
Showing 2 changed files with 17 additions and 0 deletions.
3 changes: 3 additions & 0 deletions agentops/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,7 @@
from .client import Client
from .event import Event, ActionEvent, LLMEvent, ToolEvent, ErrorEvent
from .decorators import record_function, track_agent
from .helpers import check_agentops_update
from .log_config import logger
from .session import Session

Expand Down Expand Up @@ -61,6 +62,8 @@ def init(
Attributes:
"""
Client().unsuppress_logs()
check_agentops_update()

if Client().is_initialized:
return logger.warning("AgentOps has already been initialized")

Expand Down
14 changes: 14 additions & 0 deletions agentops/helpers.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,6 +8,7 @@
from .log_config import logger
from uuid import UUID
from importlib.metadata import version
import subprocess

ao_instances = {}

Expand Down Expand Up @@ -148,6 +149,19 @@ def get_agentops_version():
return None


def check_agentops_update():
result = subprocess.run(
["pip", "list", "--outdated"], capture_output=True, text=True
)
lines = result.stdout.splitlines()[2:] # Skip the header lines
for line in lines:
parts = line.split()
if len(parts) > 0 and parts[0] == "agentops":
logger.warning(
f" WARNING: {parts[0]} is out of date. Please update with the command: 'pip install --upgrade agentops'"
)


# Function decorator that prints function name and its arguments to the console for debug purposes
# Example output:
# <AGENTOPS_DEBUG_OUTPUT>
Expand Down

0 comments on commit 4fe5b37

Please sign in to comment.