diff --git a/agentops/instrumentation/ag2/__init__.py b/agentops/instrumentation/ag2/__init__.py index ae1fbffb8..876550056 100644 --- a/agentops/instrumentation/ag2/__init__.py +++ b/agentops/instrumentation/ag2/__init__.py @@ -5,7 +5,24 @@ than individual message exchanges. """ -from agentops.instrumentation.ag2.instrumentor import AG2Instrumentor -from agentops.instrumentation.ag2.version import LIBRARY_NAME, LIBRARY_VERSION +from agentops.logging import logger + + +def get_version() -> str: + """Get the version of the AG2 package, or 'unknown' if not found""" + try: + from importlib.metadata import version + + return version("ag2") + except ImportError: + logger.debug("Could not find AG2 version") + return "unknown" + + +LIBRARY_NAME = "ag2" +LIBRARY_VERSION: str = get_version() + +# Import after defining constants to avoid circular imports +from agentops.instrumentation.ag2.instrumentor import AG2Instrumentor # noqa: E402 __all__ = ["AG2Instrumentor", "LIBRARY_NAME", "LIBRARY_VERSION"] diff --git a/agentops/instrumentation/ag2/instrumentor.py b/agentops/instrumentation/ag2/instrumentor.py index 302c0c7ce..9818d3a39 100644 --- a/agentops/instrumentation/ag2/instrumentor.py +++ b/agentops/instrumentation/ag2/instrumentor.py @@ -13,7 +13,7 @@ from wrapt import wrap_function_wrapper from agentops.logging import logger -from agentops.instrumentation.ag2.version import LIBRARY_NAME, LIBRARY_VERSION +from agentops.instrumentation.ag2 import LIBRARY_NAME, LIBRARY_VERSION from agentops.semconv import Meters from agentops.semconv.message import MessageAttributes from agentops.semconv.span_attributes import SpanAttributes diff --git a/agentops/instrumentation/ag2/version.py b/agentops/instrumentation/ag2/version.py deleted file mode 100644 index 3aab496e5..000000000 --- a/agentops/instrumentation/ag2/version.py +++ /dev/null @@ -1,4 +0,0 @@ -"""Version information for AG2 instrumentation.""" - -LIBRARY_NAME = "ag2" -LIBRARY_VERSION = "0.3.2"