feat: enhance token usage tracking and context management for LLM providers
This commit is contained in:
@@ -134,6 +134,20 @@ class BaseProvider(abc.ABC):
|
||||
"""
|
||||
pass
|
||||
|
||||
@abc.abstractmethod
|
||||
def get_usage(self, response: Any) -> dict[str, int] | None:
|
||||
"""
|
||||
Extracts token usage information from a non-streaming response object.
|
||||
|
||||
Args:
|
||||
response: The non-streaming response object.
|
||||
|
||||
Returns:
|
||||
A dictionary containing 'prompt_tokens' and 'completion_tokens',
|
||||
or None if usage information is not available.
|
||||
"""
|
||||
pass
|
||||
|
||||
# Optional: Add a method for follow-up completions if the provider API
|
||||
# requires a specific structure different from just appending messages.
|
||||
# def create_follow_up_completion(...) -> Any:
|
||||
|
||||
Reference in New Issue
Block a user