Skip to content

Commit ecea9ab

Browse files
committed
Remove agentops.enums module; move EndState to .session, EventType to .event
Signed-off-by: Teo <[email protected]>
1 parent 55b41d9 commit ecea9ab

File tree

4 files changed

+31
-37
lines changed

4 files changed

+31
-37
lines changed

agentops/enums.py

Lines changed: 0 additions & 26 deletions
This file was deleted.

agentops/event.py

Lines changed: 10 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,19 +7,27 @@
77

88
import traceback
99
from dataclasses import dataclass, field
10+
from enum import Enum
1011
from typing import Any, Dict, List, Optional, Sequence, Union
1112
from uuid import UUID, uuid4
1213

13-
from .enums import EventType
1414
from .helpers import check_call_stack_for_agent_id, get_ISO_time
1515

1616

17+
class EventType(Enum):
18+
LLM = "llms"
19+
ACTION = "actions"
20+
API = "apis"
21+
TOOL = "tools"
22+
ERROR = "errors"
23+
24+
1725
@dataclass
1826
class Event:
1927
"""
2028
Abstract base class for events that will be recorded. Should not be instantiated directly.
2129
22-
event_type(str): The type of event. Defined in enums.EventType. Some values are 'llm', 'action', 'api', 'tool', 'error'.
30+
event_type(str): The type of event. Defined in events.EventType. Some values are 'llm', 'action', 'api', 'tool', 'error'.
2331
params(dict, optional): The parameters of the function containing the triggered event, e.g. {'x': 1} in example below
2432
returns(str, optional): The return value of the function containing the triggered event, e.g. 2 in example below
2533
init_timestamp(str): A timestamp indicating when the event began. Defaults to the time when this Event was instantiated.

agentops/partners/autogen_logger.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111

1212
from autogen.logger.base_logger import BaseLogger, LLMConfig
1313

14-
from agentops.enums import EndState
14+
from agentops.session import EndState
1515
from agentops.helpers import get_ISO_time
1616

1717
from agentops import LLMEvent, ToolEvent, ActionEvent

agentops/session.py

Lines changed: 20 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -6,23 +6,18 @@
66
import threading
77
from datetime import datetime, timezone
88
from decimal import ROUND_HALF_UP, Decimal
9+
from enum import Enum
910
from typing import Any, Dict, List, Optional, Sequence, Union
1011
from uuid import UUID, uuid4
1112

1213
from opentelemetry import trace
1314
from opentelemetry.context import attach, detach, set_value
1415
from opentelemetry.sdk.resources import SERVICE_NAME, Resource
1516
from opentelemetry.sdk.trace import ReadableSpan, TracerProvider
16-
from opentelemetry.sdk.trace.export import (
17-
BatchSpanProcessor,
18-
ConsoleSpanExporter,
19-
SpanExporter,
20-
SpanExportResult,
21-
)
17+
from opentelemetry.sdk.trace.export import BatchSpanProcessor, ConsoleSpanExporter, SpanExporter, SpanExportResult
2218
from termcolor import colored
2319

2420
from .config import Configuration
25-
from .enums import EndState
2621
from .event import ErrorEvent, Event
2722
from .exceptions import ApiServerException
2823
from .helpers import filter_unjsonable, get_ISO_time, safe_serialize
@@ -63,6 +58,23 @@
6358
"""
6459

6560

61+
class EndState(Enum):
62+
"""
63+
Enum representing the possible end states of a session.
64+
65+
Attributes:
66+
SUCCESS: Indicates the session ended successfully.
67+
FAIL: Indicates the session failed.
68+
INDETERMINATE (default): Indicates the session ended with an indeterminate state.
69+
This is the default state if not specified, e.g. if you forget to call end_session()
70+
at the end of your program or don't pass it the end_state parameter
71+
"""
72+
73+
SUCCESS = "Success"
74+
FAIL = "Fail"
75+
INDETERMINATE = "Indeterminate" # Default
76+
77+
6678
class SessionExporter(SpanExporter):
6779
"""
6880
Manages publishing events for Session
@@ -290,7 +302,7 @@ def end_session(
290302
return None
291303

292304
if not any(end_state == state.value for state in EndState):
293-
logger.warning("Invalid end_state. Please use one of the EndState enums")
305+
logger.warning("Invalid end_state. Please use one of the EndState")
294306
return None
295307

296308
try:

0 commit comments

Comments
 (0)