MCPcopy Create free account
hub / github.com/Mercury7353/PyBench / __lt__

Method __lt__

llms/api_key_pool.py:110–129  ·  view source on GitHub ↗

Compare two resources based on request rate, token usage and price Args: other (Resource): The other resource to compare with Returns: bool: True if this resource has a lower request rate and token usage than the other resource, False otherwise

(self, other: "Resource")

Source from the content-addressed store, hash-verified

108 # self._client = OpenAI(api_key=self.api_key, base_url=self.base_url)
109
110 def __lt__(self, other: "Resource") -> bool:
111 """Compare two resources based on request rate, token usage and price
112 Args:
113 other (Resource): The other resource to compare with
114 Returns:
115 bool: True if this resource has a lower request rate and token usage
116 than the other resource, False otherwise
117 """
118 if abs(self._last_used_time - other._last_used_time) > A_MINITE_IN_SECONDS:
119 return self._last_used_time < other._last_used_time
120 elif abs(self._request_count - other._request_count) > RPM_INTERVAL:
121 return self._request_count < other._request_count
122 else:
123 return (
124 self._prompt_tokens * INPUT_PRICE_PER_TOKEN
125 + self._completion_tokens * OUTPUT_PRICE_PER_TOKEN
126 ) < (
127 other._prompt_tokens * INPUT_PRICE_PER_TOKEN
128 + other._completion_tokens * OUTPUT_PRICE_PER_TOKEN
129 )
130
131 def __gt__(self, other: "Resource") -> bool:
132 """Compare two resources based on request rate and token usage

Callers 1

__gt__Method · 0.95

Calls

no outgoing calls

Tested by

no test coverage detected