Coverage for src/lite_agent/types/events.py: 100%
46 statements
« prev ^ index » next coverage.py v7.10.5, created at 2025-08-25 22:58 +0900
« prev ^ index » next coverage.py v7.10.5, created at 2025-08-25 22:58 +0900
1from typing import Literal
3from litellm.types.utils import ModelResponseStream
4from pydantic import BaseModel
6from .messages import NewAssistantMessage
9class Usage(BaseModel):
10 input_tokens: int
11 output_tokens: int
14class Timing(BaseModel):
15 latency_ms: int
16 output_time_ms: int
19class CompletionRawEvent(BaseModel):
20 """
21 Define the type of chunk
22 """
24 type: Literal["completion_raw"] = "completion_raw"
25 raw: ModelResponseStream
28class ResponseRawEvent(BaseModel):
29 """
30 Define the type of response raw chunk
31 """
33 type: Literal["response_raw"] = "response_raw"
34 raw: object
37class UsageEvent(BaseModel):
38 """
39 Define the type of usage info chunk
40 """
42 type: Literal["usage"] = "usage"
43 usage: Usage
46class TimingEvent(BaseModel):
47 """
48 Define the type of timing info chunk
49 """
51 type: Literal["timing"] = "timing"
52 timing: Timing
55class AssistantMessageEvent(BaseModel):
56 """
57 Define the type of assistant message chunk
58 """
60 type: Literal["assistant_message"] = "assistant_message"
61 message: NewAssistantMessage
64class FunctionCallEvent(BaseModel):
65 """
66 Define the type of tool call chunk
67 """
69 type: Literal["function_call"] = "function_call"
70 call_id: str
71 name: str
72 arguments: str
75class FunctionCallOutputEvent(BaseModel):
76 """
77 Define the type of tool call result chunk
78 """
80 type: Literal["function_call_output"] = "function_call_output"
81 tool_call_id: str
82 name: str
83 content: str
84 execution_time_ms: int | None = None
87class ContentDeltaEvent(BaseModel):
88 """
89 Define the type of message chunk
90 """
92 type: Literal["content_delta"] = "content_delta"
93 delta: str
96class FunctionCallDeltaEvent(BaseModel):
97 """
98 Define the type of tool call delta chunk
99 """
101 type: Literal["function_call_delta"] = "function_call_delta"
102 tool_call_id: str
103 name: str
104 arguments_delta: str
107AgentChunk = CompletionRawEvent | ResponseRawEvent | UsageEvent | TimingEvent | FunctionCallEvent | FunctionCallOutputEvent | ContentDeltaEvent | FunctionCallDeltaEvent | AssistantMessageEvent
109AgentChunkType = Literal[
110 "completion_raw",
111 "response_raw",
112 "usage",
113 "timing",
114 "function_call",
115 "function_call_output",
116 "content_delta",
117 "function_call_delta",
118 "assistant_message",
119]