Index
Prompt class.
ChatMessage #
Bases: BaseRecursiveContentBlock
Chat message.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
role
|
MessageRole
|
|
<MessageRole.USER: 'user'>
|
additional_kwargs
|
dict[str, Any]
|
dict() -> new empty dictionary dict(mapping) -> new dictionary initialized from a mapping object's (key, value) pairs dict(iterable) -> new dictionary initialized as if via: d = {} for k, v in iterable: d[k] = v dict(**kwargs) -> new dictionary initialized with the name=value pairs in the keyword argument list. For example: dict(one=1, two=2) |
<class 'dict'>
|
blocks
|
list[Annotated[TextBlock | ImageBlock | AudioBlock | VideoBlock | DocumentBlock | CachePoint | CitableBlock | CitationBlock | ThinkingBlock | ToolCallBlock, FieldInfo]]
|
Built-in mutable sequence. If no argument is given, the constructor creates a new empty list. The argument must be an iterable if specified. |
<dynamic>
|
Source code in llama-index-core/llama_index/core/base/llms/types.py
1170 1171 1172 1173 1174 1175 1176 1177 1178 1179 1180 1181 1182 1183 1184 1185 1186 1187 1188 1189 1190 1191 1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 1206 1207 1208 1209 1210 1211 1212 1213 1214 1215 1216 1217 1218 1219 1220 1221 1222 1223 1224 1225 1226 1227 1228 1229 1230 1231 1232 1233 1234 1235 1236 1237 1238 1239 1240 1241 1242 1243 1244 1245 1246 1247 1248 1249 1250 1251 1252 1253 1254 1255 1256 1257 1258 1259 1260 1261 1262 1263 1264 1265 1266 1267 1268 1269 1270 1271 1272 1273 1274 1275 1276 1277 1278 1279 1280 1281 | |
content
property
writable
#
content: str | None
Keeps backward compatibility with the old content field.
Returns:
| Type | Description |
|---|---|
str | None
|
The cumulative content of the TextBlock blocks, None if there are none. |
legacy_additional_kwargs_image #
legacy_additional_kwargs_image() -> Self
Provided for backward compatibility.
If additional_kwargs contains an images key, assume the value is a list
of ImageDocument and convert them into image blocks.
Source code in llama-index-core/llama_index/core/base/llms/types.py
1192 1193 1194 1195 1196 1197 1198 1199 1200 1201 1202 1203 1204 1205 | |
MessageRole #
Bases: str, Enum
Message role.
Source code in llama-index-core/llama_index/core/base/llms/types.py
52 53 54 55 56 57 58 59 60 61 62 | |
BasePromptTemplate #
Bases: BaseModel, ABC
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
metadata
|
Dict[str, Any]
|
|
required |
template_vars
|
List[str]
|
|
required |
kwargs
|
Dict[str, str]
|
|
required |
output_parser
|
BaseOutputParser | None
|
|
required |
template_var_mappings
|
Dict[str, Any] | None
|
Template variable mappings (Optional). |
<class 'dict'>
|
function_mappings
|
Dict[str, Annotated[Callable, WithJsonSchema, WithJsonSchema, PlainSerializer]] | None
|
Function mappings (Optional). This is a mapping from template variable names to functions that take in the current kwargs and return a string. |
<class 'dict'>
|
Source code in llama-index-core/llama_index/core/prompts/base.py
56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 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 | |
ChatPromptTemplate #
Bases: BasePromptTemplate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
message_templates
|
List[ChatMessage]
|
|
required |
Source code in llama-index-core/llama_index/core/prompts/base.py
216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 | |
from_messages
classmethod
#
from_messages(
message_templates: Union[
List[Tuple[str, str]], List[ChatMessage]
],
**kwargs: Any
) -> ChatPromptTemplate
From messages.
Source code in llama-index-core/llama_index/core/prompts/base.py
247 248 249 250 251 252 253 254 255 256 257 258 259 | |
LangchainPromptTemplate #
Bases: BasePromptTemplate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
selector
|
Any
|
|
required |
requires_langchain_llm
|
bool
|
|
False
|
Source code in llama-index-core/llama_index/core/prompts/base.py
386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 | |
partial_format #
partial_format(**kwargs: Any) -> BasePromptTemplate
Partially format the prompt.
Source code in llama-index-core/llama_index/core/prompts/base.py
436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 | |
format #
format(llm: Optional[BaseLLM] = None, **kwargs: Any) -> str
Format the prompt into a string.
Source code in llama-index-core/llama_index/core/prompts/base.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 | |
format_messages #
format_messages(
llm: Optional[BaseLLM] = None, **kwargs: Any
) -> List[ChatMessage]
Format the prompt into a list of chat messages.
Source code in llama-index-core/llama_index/core/prompts/base.py
478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 | |
PromptTemplate #
Bases: BasePromptTemplate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template
|
str
|
|
required |
Source code in llama-index-core/llama_index/core/prompts/base.py
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 | |
partial_format #
partial_format(**kwargs: Any) -> PromptTemplate
Partially format the prompt.
Source code in llama-index-core/llama_index/core/prompts/base.py
164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 | |
format #
format(
llm: Optional[BaseLLM] = None,
completion_to_prompt: Optional[
Callable[[str], str]
] = None,
**kwargs: Any
) -> str
Format the prompt into a string.
Source code in llama-index-core/llama_index/core/prompts/base.py
180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 | |
format_messages #
format_messages(
llm: Optional[BaseLLM] = None, **kwargs: Any
) -> List[ChatMessage]
Format the prompt into a list of chat messages.
Source code in llama-index-core/llama_index/core/prompts/base.py
204 205 206 207 208 209 210 | |
PromptType #
Bases: str, Enum
Prompt type.
Source code in llama-index-core/llama_index/core/prompts/prompt_type.py
6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 | |
SelectorPromptTemplate #
Bases: BasePromptTemplate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
default_template
|
BasePromptTemplate
|
|
required |
conditionals
|
Sequence[Tuple[Callable[list, bool], BasePromptTemplate]] | None
|
|
None
|
Source code in llama-index-core/llama_index/core/prompts/base.py
314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 358 359 360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
format #
format(llm: Optional[BaseLLM] = None, **kwargs: Any) -> str
Format the prompt into a string.
Source code in llama-index-core/llama_index/core/prompts/base.py
369 370 371 372 | |
format_messages #
format_messages(
llm: Optional[BaseLLM] = None, **kwargs: Any
) -> List[ChatMessage]
Format the prompt into a list of chat messages.
Source code in llama-index-core/llama_index/core/prompts/base.py
374 375 376 377 378 379 | |
RichPromptTemplate #
Bases: BasePromptTemplate
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
template_str
|
str
|
The template string for the prompt. |
required |
Source code in llama-index-core/llama_index/core/prompts/rich.py
24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 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 | |
display_prompt_dict #
display_prompt_dict(prompts_dict: PromptDictType) -> None
Display prompt dict.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
prompts_dict
|
PromptDictType
|
prompt dict |
required |
Source code in llama-index-core/llama_index/core/prompts/display_utils.py
7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 | |