ChatMessage
Base classes¶
Name | Children | Inherits |
---|---|---|
Generic typing Abstract base class for generic types. |
⋔ Inheritance diagram¶
graph TD
94350421322800["messages.ChatMessage"]
94350360566400["typing.Generic"]
140709601677504["builtins.object"]
94350360566400 --> 94350421322800
140709601677504 --> 94350360566400
🛈 DocStrings¶
Common message format for all UI types.
Generically typed with: ChatMessage[Type of Content] The type can either be str or a BaseModel subclass.
Source code in src/llmling_agent/models/messages.py
91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 |
|
content
instance-attribute
¶
content: TContent
Message content, typed as TContent (either str or BaseModel).
cost_info
class-attribute
instance-attribute
¶
cost_info: TokenCost | None = None
Token usage and costs for this specific message if available.
forwarded_from
class-attribute
instance-attribute
¶
List of agent names (the chain) that forwarded this message to the sender.
message_id
class-attribute
instance-attribute
¶
Unique identifier for this message.
metadata
class-attribute
instance-attribute
¶
Additional metadata about the message.
model
class-attribute
instance-attribute
¶
model: str | None = None
Name of the model that generated this message.
name
class-attribute
instance-attribute
¶
name: str | None = None
Display name for the message sender in UI.
response_time
class-attribute
instance-attribute
¶
response_time: float | None = None
Time it took the LLM to respond.
timestamp
class-attribute
instance-attribute
¶
When this message was created.
tool_calls
class-attribute
instance-attribute
¶
List of tool calls made during message generation.
format
¶
format(
style: Literal["simple", "detailed", "markdown"] = "simple",
*,
show_metadata: bool = False,
show_costs: bool = False,
) -> str
Format message with configurable style.
Source code in src/llmling_agent/models/messages.py
163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 |
|
to_gradio_format
¶
Convert to Gradio chatbot format.
Source code in src/llmling_agent/models/messages.py
147 148 149 150 151 152 153 154 155 156 |
|
to_text_message
¶
to_text_message() -> ChatMessage[str]
Convert this message to a text-only version.
Source code in src/llmling_agent/models/messages.py
132 133 134 |
|