forked from openai/openai-agents-python
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathusage.py
22 lines (16 loc) · 733 Bytes
/
usage.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
from dataclasses import dataclass
@dataclass
class Usage:
requests: int = 0
"""Total requests made to the LLM API."""
input_tokens: int = 0
"""Total input tokens sent, across all requests."""
output_tokens: int = 0
"""Total output tokens received, across all requests."""
total_tokens: int = 0
"""Total tokens sent and received, across all requests."""
def add(self, other: "Usage") -> None:
self.requests += other.requests if other.requests else 0
self.input_tokens += other.input_tokens if other.input_tokens else 0
self.output_tokens += other.output_tokens if other.output_tokens else 0
self.total_tokens += other.total_tokens if other.total_tokens else 0