mirror of
https://github.com/MODSetter/SurfSense.git
synced 2026-05-01 03:46:25 +02:00
feat: implement token usage tracking for LLM calls with new accumulator and callback
This commit is contained in:
parent
917f35eb33
commit
3cfe53fb7f
6 changed files with 223 additions and 4 deletions
|
|
@ -34,6 +34,14 @@ class NewChatMessageCreate(NewChatMessageBase):
|
|||
thread_id: int
|
||||
|
||||
|
||||
class TokenUsageSummary(BaseModel):
|
||||
prompt_tokens: int = 0
|
||||
completion_tokens: int = 0
|
||||
total_tokens: int = 0
|
||||
model_breakdown: dict | None = None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
class NewChatMessageRead(NewChatMessageBase, IDModel, TimestampModel):
|
||||
"""Schema for reading a message."""
|
||||
|
||||
|
|
@ -41,6 +49,7 @@ class NewChatMessageRead(NewChatMessageBase, IDModel, TimestampModel):
|
|||
author_id: UUID | None = None
|
||||
author_display_name: str | None = None
|
||||
author_avatar_url: str | None = None
|
||||
token_usage: TokenUsageSummary | None = None
|
||||
model_config = ConfigDict(from_attributes=True)
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue