Coverage for app / router / app / conversations / models.py: 100%

36 statements  

« prev     ^ index     » next       coverage.py v7.13.5, created at 2026-10-31 11:21 +0000

1from uuid import UUID 

2from typing import Any 

3from pydantic import BaseModel 

4from app.util.time import UTCDateTime 

5 

6 

7class ConversationMessageRead(BaseModel): 

8 id: UUID 

9 role: str 

10 status: str = "completed" 

11 content: str 

12 token_count: int 

13 sent_at: UTCDateTime 

14 conversation_id: UUID 

15 trace: list[dict[str, Any]] | None = None 

16 meta: dict[str, Any] | None = None 

17 #: The governed turn the message was part of: the key of its decision 

18 #: record. Null on system messages and older turns. 

19 invocation_id: UUID | None = None 

20 #: On an answer: the turn's verdict, when somebody gave one (accepted, 

21 #: edited or rejected; ``decision_outcomes``). 

22 verdict: str | None = None 

23 #: On an answer: what its turn cost, from the usage ledger by 

24 #: ``invocation_id`` — None when nothing in it could be priced, or when 

25 #: the turn is not on the ledger (a block, or one from before turns were 

26 #: named). ``unpriced_calls`` above 0 makes it a floor. 

27 cost_usd: float | None = None 

28 unpriced_calls: int = 0 

29 

30 class Config: 

31 from_attributes = True 

32 

33 

34class ConversationRead(BaseModel): 

35 id: UUID 

36 ai_model_id: UUID | None = None 

37 agent_id: UUID | None = None 

38 owner_user_id: UUID | None = None 

39 owner_organisation_id: UUID | None = None 

40 owner_project_id: UUID | None = None 

41 messages: list[ConversationMessageRead] = [] 

42 total_input_tokens: int 

43 total_output_tokens: int 

44 total_tokens: int 

45 #: The answers' costs added up; None when none of them has one. 

46 cost_usd: float | None = None 

47 unpriced_calls: int = 0 

48 created_at: UTCDateTime 

49 

50 class Config: 

51 from_attributes = True