1const n={frontmatter:{title:"prompts",description:"API documentation for prompts"},tableOfContents:[{id:"prompts",content:"prompts",level:1},{id:"async-context-message-template",content:"[Class] AsyncContextMessageTemplate",level:2},{id:"async-context-prompt",content:"[Class] AsyncContextPrompt",level:2},{id:"mirascope-llm-prompts-prompts--async-context-prompt-messages",content:"[Function] messages",level:2},{id:"mirascope-llm-prompts-prompts--async-context-prompt-call",content:"[Function] call",level:2},{id:"mirascope-llm-prompts-prompts--async-context-prompt-stream",content:"[Function] stream",level:2},{id:"async-message-template",content:"[Class] AsyncMessageTemplate",level:2},{id:"async-prompt",content:"[Class] AsyncPrompt",level:2},{id:"mirascope-llm-prompts-prompts--async-prompt-messages",content:"[Function] messages",level:2},{id:"mirascope-llm-prompts-prompts--async-prompt-call",content:"[Function] call",level:2},{id:"mirascope-llm-prompts-prompts--async-prompt-stream",content:"[Function] stream",level:2},{id:"context-message-template",content:"[Class] ContextMessageTemplate",level:2},{id:"context-prompt",content:"[Class] ContextPrompt",level:2},{id:"mirascope-llm-prompts-prompts--context-prompt-messages",content:"[Function] messages",level:2},{id:"mirascope-llm-prompts-prompts--context-prompt-call",content:"[Function] call",level:2},{id:"mirascope-llm-prompts-prompts--context-prompt-stream",content:"[Function] stream",level:2},{id:"message-template",content:"[Class] MessageTemplate",level:2},{id:"prompt",content:"[Class] Prompt",level:2},{id:"mirascope-llm-prompts-prompts--prompt-messages",content:"[Function] messages",level:2},{id:"mirascope-llm-prompts-prompts--prompt-call",content:"[Function] call",level:2},{id:"mirascope-llm-prompts-prompts--prompt-stream",content:"[Function] stream",level:2},{id:"prompt-decorator",content:"[Class] PromptDecorator",level:2},{id:"prompt_fn",content:"[Function] prompt",level:2}],content:`# prompts 2 3## <ApiType type="Class" slug="async-context-message-template" symbolName="AsyncContextMessageTemplate" /> AsyncContextMessageTemplate 4 5Protocol for an async context-aware prompt function that returns \`UserContent\` or \`Sequence[Message]\`. 6 7An async \`MessageTemplate\` with a first parameter named \`'ctx'\` of type \`Context[DepsT]\`. 8Can be converted by the \`llm.prompt\` decorator into an \`AsyncContextPrompt\`, or by 9the \`llm.call\` decorator into an \`AsyncContextCall\`. 10 11**Bases:** 12<TypeLink type={{"type_str": "Protocol[P, DepsT]", "description": null, "kind": "generic", "base_type": {"type_str": "Protocol", "description": null, "kind": "simple", "symbol_name": "Protocol", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Protocol"}, "parameters": [{"type_str": "P", "description": null, "kind": "simple", "symbol_name": "P", "doc_url": "/docs/api/llm/types#p"}, {"type_str": "DepsT", "description": null, "kind": "simple", "symbol_name": "DepsT", "doc_url": null}], "doc_url": null}} /> 13 14 15## <ApiType type="Class" slug="async-context-prompt" symbolName="AsyncContextPrompt" /> AsyncContextPrompt 16 17An async context-aware prompt that can be called with a model to generate a response. 18 19Created by decorating an async \`ContextMessageTemplate\` with \`llm.prompt\`. The decorated 20async function (with first parameter \`'ctx'\` of type \`Context[DepsT]\`) becomes callable 21with a \`Model\` to generate LLM responses asynchronously with context dependencies. 22 23An \`AsyncContextPrompt\` is essentially: async \`ContextMessageTemplate\` + tools + format. 24It can be invoked with a model: \`await prompt(model, ctx, *args, **kwargs)\`. 25 26**Bases:** 27<TypeLink type={{"type_str": "Generic[P, DepsT, FormattableT]", "description": null, "kind": "generic", "base_type": {"type_str": "Generic", "description": null, "kind": "simple", "symbol_name": "Generic", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Generic"}, "parameters": [{"type_str": "P", "description": null, "kind": "simple", "symbol_name": "P", "doc_url": "/docs/api/llm/types#p"}, {"type_str": "DepsT", "description": null, "kind": "simple", "symbol_name": "DepsT", "doc_url": null}, {"type_str": "FormattableT", "description": null, "kind": "simple", "symbol_name": "FormattableT", "doc_url": "/docs/api/llm/formatting#formattable-t"}], "doc_url": null}} /> 28 29<AttributesTable 30 attributes={[ 31 { 32 "name": "fn", 33 "type_info": { 34 "type_str": "AsyncContextMessageTemplate[P, DepsT]", 35 "description": null, 36 "kind": "generic", 37 "base_type": { 38 "type_str": "AsyncContextMessageTemplate", 39 "description": null, 40 "kind": "simple", 41 "symbol_name": "AsyncContextMessageTemplate", 42 "doc_url": null 43 }, 44 "parameters": [ 45 { 46 "type_str": "P", 47 "description": null, 48 "kind": "simple", 49 "symbol_name": "P", 50 "doc_url": null 51 }, 52 { 53 "type_str": "DepsT", 54 "description": null, 55 "kind": "simple", 56 "symbol_name": "DepsT", 57 "doc_url": null 58 } 59 ], 60 "doc_url": null 61 }, 62 "description": "The underlying async context-aware prompt function that generates message content." 63 }, 64 { 65 "name": "toolkit", 66 "type_info": { 67 "type_str": "AsyncContextToolkit[DepsT]", 68 "description": null, 69 "kind": "generic", 70 "base_type": { 71 "type_str": "AsyncContextToolkit", 72 "description": null, 73 "kind": "simple", 74 "symbol_name": "AsyncContextToolkit", 75 "doc_url": null 76 }, 77 "parameters": [ 78 { 79 "type_str": "DepsT", 80 "description": null, 81 "kind": "simple", 82 "symbol_name": "DepsT", 83 "doc_url": null 84 } 85 ], 86 "doc_url": null 87 }, 88 "description": "The toolkit containing this prompt's async context-aware tools." 89 }, 90 { 91 "name": "format", 92 "type_info": { 93 "type_str": "type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None", 94 "description": null, 95 "kind": "union", 96 "base_type": { 97 "type_str": "Union", 98 "description": null, 99 "kind": "simple", 100 "symbol_name": "Union", 101 "doc_url": null 102 }, 103 "parameters": [ 104 { 105 "type_str": "type[FormattableT]", 106 "description": null, 107 "kind": "generic", 108 "base_type": { 109 "type_str": "type", 110 "description": null, 111 "kind": "simple", 112 "symbol_name": "type", 113 "doc_url": null 114 }, 115 "parameters": [ 116 { 117 "type_str": "FormattableT", 118 "description": null, 119 "kind": "simple", 120 "symbol_name": "FormattableT", 121 "doc_url": null 122 } 123 ], 124 "doc_url": null 125 }, 126 { 127 "type_str": "Format[FormattableT]", 128 "description": null, 129 "kind": "generic", 130 "base_type": { 131 "type_str": "Format", 132 "description": null, 133 "kind": "simple", 134 "symbol_name": "Format", 135 "doc_url": null 136 }, 137 "parameters": [ 138 { 139 "type_str": "FormattableT", 140 "description": null, 141 "kind": "simple", 142 "symbol_name": "FormattableT", 143 "doc_url": null 144 } 145 ], 146 "doc_url": null 147 }, 148 { 149 "type_str": "OutputParser[FormattableT]", 150 "description": null, 151 "kind": "generic", 152 "base_type": { 153 "type_str": "OutputParser", 154 "description": null, 155 "kind": "simple", 156 "symbol_name": "OutputParser", 157 "doc_url": null 158 }, 159 "parameters": [ 160 { 161 "type_str": "FormattableT", 162 "description": null, 163 "kind": "simple", 164 "symbol_name": "FormattableT", 165 "doc_url": null 166 } 167 ], 168 "doc_url": null 169 }, 170 { 171 "type_str": "None", 172 "description": null, 173 "kind": "simple", 174 "symbol_name": "None", 175 "doc_url": null 176 } 177 ], 178 "doc_url": null 179 }, 180 "description": "The response format for the generated response." 181 } 182]} 183/> 184 185## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--async-context-prompt-messages" symbolName="messages" /> messages 186 187Return the \`Messages\` from invoking this prompt. 188 189<ParametersTable 190 parameters={[ 191 { 192 "name": "self", 193 "type_info": { 194 "type_str": "Any", 195 "description": null, 196 "kind": "simple", 197 "symbol_name": null, 198 "doc_url": null 199 } 200 }, 201 { 202 "name": "ctx", 203 "type_info": { 204 "type_str": "Context[DepsT]", 205 "description": null, 206 "kind": "generic", 207 "base_type": { 208 "type_str": "Context", 209 "description": null, 210 "kind": "simple", 211 "symbol_name": "Context", 212 "doc_url": null 213 }, 214 "parameters": [ 215 { 216 "type_str": "DepsT", 217 "description": null, 218 "kind": "simple", 219 "symbol_name": "DepsT", 220 "doc_url": null 221 } 222 ], 223 "doc_url": null 224 } 225 }, 226 { 227 "name": "args", 228 "type_info": { 229 "type_str": "P.args", 230 "description": null, 231 "kind": "simple", 232 "symbol_name": "P.args", 233 "doc_url": null 234 }, 235 "default": "()" 236 }, 237 { 238 "name": "kwargs", 239 "type_info": { 240 "type_str": "P.kwargs", 241 "description": null, 242 "kind": "simple", 243 "symbol_name": "P.kwargs", 244 "doc_url": null 245 }, 246 "default": "{}" 247 } 248]} 249/> 250 251<ReturnTable 252 returnType={{ 253 "type_info": { 254 "type_str": "Sequence[Message]", 255 "description": null, 256 "kind": "generic", 257 "base_type": { 258 "type_str": "Sequence", 259 "description": null, 260 "kind": "simple", 261 "symbol_name": "Sequence", 262 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Sequence" 263 }, 264 "parameters": [ 265 { 266 "type_str": "Message", 267 "description": null, 268 "kind": "simple", 269 "symbol_name": "Message", 270 "doc_url": "/docs/api/llm/messages#message" 271 } 272 ], 273 "doc_url": null 274 } 275}} 276/> 277 278 279## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--async-context-prompt-call" symbolName="call" /> call 280 281Generates a response using the provided model asynchronously. 282 283<ParametersTable 284 parameters={[ 285 { 286 "name": "self", 287 "type_info": { 288 "type_str": "Any", 289 "description": null, 290 "kind": "simple", 291 "symbol_name": null, 292 "doc_url": null 293 } 294 }, 295 { 296 "name": "model", 297 "type_info": { 298 "type_str": "Model | ModelId", 299 "description": null, 300 "kind": "union", 301 "base_type": { 302 "type_str": "Union", 303 "description": null, 304 "kind": "simple", 305 "symbol_name": "Union", 306 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 307 }, 308 "parameters": [ 309 { 310 "type_str": "Model", 311 "description": null, 312 "kind": "simple", 313 "symbol_name": "Model", 314 "doc_url": "/docs/api/llm/models#model" 315 }, 316 { 317 "type_str": "ModelId", 318 "description": null, 319 "kind": "simple", 320 "symbol_name": "ModelId", 321 "doc_url": "/docs/api/llm/providers#model-id" 322 } 323 ], 324 "doc_url": null 325 } 326 }, 327 { 328 "name": "ctx", 329 "type_info": { 330 "type_str": "Context[DepsT]", 331 "description": null, 332 "kind": "generic", 333 "base_type": { 334 "type_str": "Context", 335 "description": null, 336 "kind": "simple", 337 "symbol_name": "Context", 338 "doc_url": null 339 }, 340 "parameters": [ 341 { 342 "type_str": "DepsT", 343 "description": null, 344 "kind": "simple", 345 "symbol_name": "DepsT", 346 "doc_url": null 347 } 348 ], 349 "doc_url": null 350 } 351 }, 352 { 353 "name": "args", 354 "type_info": { 355 "type_str": "P.args", 356 "description": null, 357 "kind": "simple", 358 "symbol_name": "P.args", 359 "doc_url": null 360 }, 361 "default": "()" 362 }, 363 { 364 "name": "kwargs", 365 "type_info": { 366 "type_str": "P.kwargs", 367 "description": null, 368 "kind": "simple", 369 "symbol_name": "P.kwargs", 370 "doc_url": null 371 }, 372 "default": "{}" 373 } 374]} 375/> 376 377<ReturnTable 378 returnType={{ 379 "type_info": { 380 "type_str": "AsyncContextResponse[DepsT, None] | AsyncContextResponse[DepsT, FormattableT]", 381 "description": null, 382 "kind": "union", 383 "base_type": { 384 "type_str": "Union", 385 "description": null, 386 "kind": "simple", 387 "symbol_name": "Union", 388 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 389 }, 390 "parameters": [ 391 { 392 "type_str": "AsyncContextResponse[DepsT, None]", 393 "description": null, 394 "kind": "generic", 395 "base_type": { 396 "type_str": "AsyncContextResponse", 397 "description": null, 398 "kind": "simple", 399 "symbol_name": "AsyncContextResponse", 400 "doc_url": "/docs/api/llm/responses#async-context-response" 401 }, 402 "parameters": [ 403 { 404 "type_str": "DepsT", 405 "description": null, 406 "kind": "simple", 407 "symbol_name": "DepsT", 408 "doc_url": null 409 }, 410 { 411 "type_str": "None", 412 "description": null, 413 "kind": "simple", 414 "symbol_name": "None", 415 "doc_url": "https://docs.python.org/3/library/constants.html#None" 416 } 417 ], 418 "doc_url": null 419 }, 420 { 421 "type_str": "AsyncContextResponse[DepsT, FormattableT]", 422 "description": null, 423 "kind": "generic", 424 "base_type": { 425 "type_str": "AsyncContextResponse", 426 "description": null, 427 "kind": "simple", 428 "symbol_name": "AsyncContextResponse", 429 "doc_url": "/docs/api/llm/responses#async-context-response" 430 }, 431 "parameters": [ 432 { 433 "type_str": "DepsT", 434 "description": null, 435 "kind": "simple", 436 "symbol_name": "DepsT", 437 "doc_url": null 438 }, 439 { 440 "type_str": "FormattableT", 441 "description": null, 442 "kind": "simple", 443 "symbol_name": "FormattableT", 444 "doc_url": "/docs/api/llm/formatting#formattable-t" 445 } 446 ], 447 "doc_url": null 448 } 449 ], 450 "doc_url": null 451 } 452}} 453/> 454 455 456## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--async-context-prompt-stream" symbolName="stream" /> stream 457 458Generates a streaming response using the provided model asynchronously. 459 460<ParametersTable 461 parameters={[ 462 { 463 "name": "self", 464 "type_info": { 465 "type_str": "Any", 466 "description": null, 467 "kind": "simple", 468 "symbol_name": null, 469 "doc_url": null 470 } 471 }, 472 { 473 "name": "model", 474 "type_info": { 475 "type_str": "Model | ModelId", 476 "description": null, 477 "kind": "union", 478 "base_type": { 479 "type_str": "Union", 480 "description": null, 481 "kind": "simple", 482 "symbol_name": "Union", 483 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 484 }, 485 "parameters": [ 486 { 487 "type_str": "Model", 488 "description": null, 489 "kind": "simple", 490 "symbol_name": "Model", 491 "doc_url": "/docs/api/llm/models#model" 492 }, 493 { 494 "type_str": "ModelId", 495 "description": null, 496 "kind": "simple", 497 "symbol_name": "ModelId", 498 "doc_url": "/docs/api/llm/providers#model-id" 499 } 500 ], 501 "doc_url": null 502 } 503 }, 504 { 505 "name": "ctx", 506 "type_info": { 507 "type_str": "Context[DepsT]", 508 "description": null, 509 "kind": "generic", 510 "base_type": { 511 "type_str": "Context", 512 "description": null, 513 "kind": "simple", 514 "symbol_name": "Context", 515 "doc_url": null 516 }, 517 "parameters": [ 518 { 519 "type_str": "DepsT", 520 "description": null, 521 "kind":
521"simple", 522 "symbol_name": "DepsT", 523 "doc_url": null 524 } 525 ], 526 "doc_url": null 527 } 528 }, 529 { 530 "name": "args", 531 "type_info": { 532 "type_str": "P.args", 533 "description": null, 534 "kind": "simple", 535 "symbol_name": "P.args", 536 "doc_url": null 537 }, 538 "default": "()" 539 }, 540 { 541 "name": "kwargs", 542 "type_info": { 543 "type_str": "P.kwargs", 544 "description": null, 545 "kind": "simple", 546 "symbol_name": "P.kwargs", 547 "doc_url": null 548 }, 549 "default": "{}" 550 } 551]} 552/> 553 554<ReturnTable 555 returnType={{ 556 "type_info": { 557 "type_str": "AsyncContextStreamResponse[DepsT, None] | AsyncContextStreamResponse[DepsT, FormattableT]", 558 "description": null, 559 "kind": "union", 560 "base_type": { 561 "type_str": "Union", 562 "description": null, 563 "kind": "simple", 564 "symbol_name": "Union", 565 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 566 }, 567 "parameters": [ 568 { 569 "type_str": "AsyncContextStreamResponse[DepsT, None]", 570 "description": null, 571 "kind": "generic", 572 "base_type": { 573 "type_str": "AsyncContextStreamResponse", 574 "description": null, 575 "kind": "simple", 576 "symbol_name": "AsyncContextStreamResponse", 577 "doc_url": "/docs/api/llm/responses#async-context-stream-response" 578 }, 579 "parameters": [ 580 { 581 "type_str": "DepsT", 582 "description": null, 583 "kind": "simple", 584 "symbol_name": "DepsT", 585 "doc_url": null 586 }, 587 { 588 "type_str": "None", 589 "description": null, 590 "kind": "simple", 591 "symbol_name": "None", 592 "doc_url": "https://docs.python.org/3/library/constants.html#None" 593 } 594 ], 595 "doc_url": null 596 }, 597 { 598 "type_str": "AsyncContextStreamResponse[DepsT, FormattableT]", 599 "description": null, 600 "kind": "generic", 601 "base_type": { 602 "type_str": "AsyncContextStreamResponse", 603 "description": null, 604 "kind": "simple", 605 "symbol_name": "AsyncContextStreamResponse", 606 "doc_url": "/docs/api/llm/responses#async-context-stream-response" 607 }, 608 "parameters": [ 609 { 610 "type_str": "DepsT", 611 "description": null, 612 "kind": "simple", 613 "symbol_name": "DepsT", 614 "doc_url": null 615 }, 616 { 617 "type_str": "FormattableT", 618 "description": null, 619 "kind": "simple", 620 "symbol_name": "FormattableT", 621 "doc_url": "/docs/api/llm/formatting#formattable-t" 622 } 623 ], 624 "doc_url": null 625 } 626 ], 627 "doc_url": null 628 } 629}} 630/> 631 632 633 634## <ApiType type="Class" slug="async-message-template" symbolName="AsyncMessageTemplate" /> AsyncMessageTemplate 635 636Protocol for an async prompt function that returns \`UserContent\` or \`Sequence[Message]\`. 637 638An async \`MessageTemplate\` that can be converted by the \`llm.prompt\` decorator 639into an \`AsyncPrompt\`, or by the \`llm.call\` decorator into an \`AsyncCall\`. 640 641**Bases:** 642<TypeLink type={{"type_str": "Protocol[P]", "description": null, "kind": "generic", "base_type": {"type_str": "Protocol", "description": null, "kind": "simple", "symbol_name": "Protocol", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Protocol"}, "parameters": [{"type_str": "P", "description": null, "kind": "simple", "symbol_name": "P", "doc_url": "/docs/api/llm/types#p"}], "doc_url": null}} /> 643 644 645## <ApiType type="Class" slug="async-prompt" symbolName="AsyncPrompt" /> AsyncPrompt 646 647An async prompt that can be called with a model to generate a response. 648 649Created by decorating an async \`MessageTemplate\` with \`llm.prompt\`. The decorated 650async function becomes callable with a \`Model\` to generate LLM responses asynchronously. 651 652An \`AsyncPrompt\` is essentially: async \`MessageTemplate\` + tools + format. 653It can be invoked with a model: \`await prompt(model, *args, **kwargs)\`. 654 655**Bases:** 656<TypeLink type={{"type_str": "Generic[P, FormattableT]", "description": null, "kind": "generic", "base_type": {"type_str": "Generic", "description": null, "kind": "simple", "symbol_name": "Generic", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Generic"}, "parameters": [{"type_str": "P", "description": null, "kind": "simple", "symbol_name": "P", "doc_url": "/docs/api/llm/types#p"}, {"type_str": "FormattableT", "description": null, "kind": "simple", "symbol_name": "FormattableT", "doc_url": "/docs/api/llm/formatting#formattable-t"}], "doc_url": null}} /> 657 658<AttributesTable 659 attributes={[ 660 { 661 "name": "fn", 662 "type_info": { 663 "type_str": "AsyncMessageTemplate[P]", 664 "description": null, 665 "kind": "generic", 666 "base_type": { 667 "type_str": "AsyncMessageTemplate", 668 "description": null, 669 "kind": "simple", 670 "symbol_name": "AsyncMessageTemplate", 671 "doc_url": null 672 }, 673 "parameters": [ 674 { 675 "type_str": "P", 676 "description": null, 677 "kind": "simple", 678 "symbol_name": "P", 679 "doc_url": null 680 } 681 ], 682 "doc_url": null 683 }, 684 "description": "The underlying async prompt function that generates message content." 685 }, 686 { 687 "name": "toolkit", 688 "type_info": { 689 "type_str": "AsyncToolkit", 690 "description": null, 691 "kind": "simple", 692 "symbol_name": "AsyncToolkit", 693 "doc_url": null 694 }, 695 "description": "The toolkit containing this prompt's async tools." 696 }, 697 { 698 "name": "format", 699 "type_info": { 700 "type_str": "type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None", 701 "description": null, 702 "kind": "union", 703 "base_type": { 704 "type_str": "Union", 705 "description": null, 706 "kind": "simple", 707 "symbol_name": "Union", 708 "doc_url": null 709 }, 710 "parameters": [ 711 { 712 "type_str": "type[FormattableT]", 713 "description": null, 714 "kind": "generic", 715 "base_type": { 716 "type_str": "type", 717 "description": null, 718 "kind": "simple", 719 "symbol_name": "type", 720 "doc_url": null 721 }, 722 "parameters": [ 723 { 724 "type_str": "FormattableT", 725 "description": null, 726 "kind": "simple", 727 "symbol_name": "FormattableT", 728 "doc_url": null 729 } 730 ], 731 "doc_url": null 732 }, 733 { 734 "type_str": "Format[FormattableT]", 735 "description": null, 736 "kind": "generic", 737 "base_type": { 738 "type_str": "Format", 739 "description": null, 740 "kind": "simple", 741 "symbol_name": "Format", 742 "doc_url": null 743 }, 744 "parameters": [ 745 { 746 "type_str": "FormattableT", 747 "description": null, 748 "kind": "simple", 749 "symbol_name": "FormattableT", 750 "doc_url": null 751 } 752 ], 753 "doc_url": null 754 }, 755 { 756 "type_str": "OutputParser[FormattableT]", 757 "description": null, 758 "kind": "generic", 759 "base_type": { 760 "type_str": "OutputParser", 761 "description": null, 762 "kind": "simple", 763 "symbol_name": "OutputParser", 764 "doc_url": null 765 }, 766 "parameters": [ 767 { 768 "type_str": "FormattableT", 769 "description": null, 770 "kind": "simple", 771 "symbol_name": "FormattableT", 772 "doc_url": null 773 } 774 ], 775 "doc_url": null 776 }, 777 { 778 "type_str": "None", 779 "description": null, 780 "kind": "simple", 781 "symbol_name": "None", 782 "doc_url": null 783 } 784 ], 785 "doc_url": null 786 }, 787 "description": "The response format for the generated response." 788 } 789]} 790/> 791 792## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--async-prompt-messages" symbolName="messages" /> messages 793 794Return the \`Messages\` from invoking this prompt. 795 796<ParametersTable 797 parameters={[ 798 { 799 "name": "self", 800 "type_info": { 801 "type_str": "Any", 802 "description": null, 803 "kind": "simple", 804 "symbol_name": null, 805 "doc_url": null 806 } 807 }, 808 { 809 "name": "args", 810 "type_info": { 811 "type_str": "P.args", 812 "description": null, 813 "kind": "simple", 814 "symbol_name": "P.args", 815 "doc_url": null 816 }, 817 "default": "()" 818 }, 819 { 820 "name": "kwargs", 821 "type_info": { 822 "type_str": "P.kwargs", 823 "description": null, 824 "kind": "simple", 825 "symbol_name": "P.kwargs", 826 "doc_url": null 827 }, 828 "default": "{}" 829 } 830]} 831/> 832 833<ReturnTable 834 returnType={{ 835 "type_info": { 836 "type_str": "Sequence[Message]", 837 "description": null, 838 "kind": "generic", 839 "base_type": { 840 "type_str": "Sequence", 841 "description": null, 842 "kind": "simple", 843 "symbol_name": "Sequence", 844 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Sequence" 845 }, 846 "parameters": [ 847 { 848 "type_str": "Message", 849 "description": null, 850 "kind": "simple", 851 "symbol_name": "Message", 852 "doc_url": "/docs/api/llm/messages#message" 853 } 854 ], 855 "doc_url": null 856 } 857}} 858/> 859 860 861## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--async-prompt-call" symbolName="call" /> call 862 863Generates a response using the provided model asynchronously. 864 865<ParametersTable 866 parameters={[ 867 { 868 "name": "self", 869 "type_info": { 870 "type_str": "Any", 871 "description": null, 872 "kind": "simple", 873 "symbol_name": null, 874 "doc_url": null 875 } 876 }, 877 { 878 "name": "model", 879 "type_info": { 880 "type_str": "Model | ModelId", 881 "description": null, 882 "kind": "union", 883 "base_type": { 884 "type_str": "Union", 885 "description": null, 886 "kind": "simple", 887 "symbol_name": "Union", 888 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 889 }, 890 "parameters": [ 891 { 892 "type_str": "Model", 893 "description": null, 894 "kind": "simple", 895 "symbol_name": "Model", 896 "doc_url": "/docs/api/llm/models#model" 897 }, 898 { 899 "type_str": "ModelId", 900 "description": null, 901 "kind": "simple", 902 "symbol_name": "ModelId", 903 "doc_url": "/docs/api/llm/providers#model-id" 904 } 905 ], 906 "doc_url": null 907 } 908 }, 909 { 910 "name": "args", 911 "type_info": { 912 "type_str": "P.args", 913 "description": null, 914 "kind": "simple", 915 "symbol_name": "P.args", 916 "doc_url": null 917 }, 918 "default": "()" 919 }, 920 { 921 "name": "kwargs", 922 "type_info": { 923 "type_str": "P.kwargs", 924 "description": null, 925 "kind": "simple", 926 "symbol_name": "P.kwargs", 927 "doc_url": null 928 }, 929 "default": "{}" 930 } 931]} 932/> 933 934<ReturnTable 935 returnType={{ 936 "type_info": { 937 "type_str": "AsyncResponse | AsyncResponse[FormattableT]", 938 "description": null, 939 "kind": "union", 940 "base_type": { 941 "type_str": "Union", 942 "description": null, 943 "kind": "simple", 944 "symbol_name": "Union", 945 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 946 }, 947 "parameters": [ 948 { 949 "type_str": "AsyncResponse", 950 "description": null, 951 "kind": "simple", 952 "symbol_name": "AsyncResponse", 953 "doc_url": "/docs/api/llm/responses#async-response" 954 }, 955 { 956 "type_str": "AsyncResponse[FormattableT]", 957 "description": null, 958 "kind": "generic", 959 "base_type": { 960 "type_str": "AsyncResponse", 961 "description": null, 962 "kind": "simple", 963 "symbol_name": "AsyncResponse", 964 "doc_url": "/docs/api/llm/responses#async-response" 965 }, 966 "parameters": [ 967 { 968 "type_str": "FormattableT", 969 "description": null, 970 "kind": "simple", 971 "symbol_name": "FormattableT", 972 "doc_url": "/docs/api/llm/formatting#formattable-t" 973 } 974 ], 975 "doc_url": null 976 } 977 ], 978 "doc_url": null 979 } 980}} 981/> 982 983 984## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--async-prompt-stream" symbolName="stream" /> stream 985 986Generates a streaming response using the provided model asynchronously. 987 988<ParametersTable 989 parameters={[ 990 { 991 "name": "self", 992 "type_info": { 993 "type_str": "Any", 994 "description": null, 995 "kind": "simple", 996 "symbol_name": null, 997 "doc_url": null 998 } 999 }, 1000 { 1001 "name": "model", 1002 "type_info": { 1003 "type_str": "Model | ModelId", 1004 "description": null, 1005 "kind": "union", 1006 "base_type": { 1007 "type_str": "Union", 1008 "description": null, 1009 "kind": "simple", 1010 "symbol_name": "Union", 1011 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 1012 }, 1013 "parameters": [ 1014 { 1015 "type_str": "Model", 1016 "description": null, 1017 "kind": "simple", 1018 "symbol_name": "Model", 1019 "doc_url": "/docs/api/llm/models#model" 1020 }, 1021 { 1022 "type_str": "ModelId", 1023 "description": null, 1024 "kind": "simple", 1025 "symbol_name": "ModelId", 1026 "doc_url": "/docs/api/llm/providers#model-id" 1027 } 1028 ], 1029 "doc_url": null 1030 } 1031 }, 1032 { 1033 "name": "args", 1034 "type_info": { 1035 "type_str": "P.args", 1036 "description": null, 1037 "kind": "simple", 1038 "symbol_name": "P.args", 1039 "doc_url": null 1040 }, 1041 "default": "()" 1042 }, 1043 { 1044 "name": "kwargs", 1045 "type_info": { 1046 "type_str": "P.kwargs", 1047 "description": null, 1048 "kind": "simple", 1049 "symbol_name": "P.kwargs", 1050 "doc_url": null 1051 }, 1052 "default": "{}" 1053 } 1054]} 1055/> 1056 1057<ReturnTable 1058 returnType={{ 1059 "type_info": { 1060 "type_str": "AsyncStreamResponse | AsyncStreamResponse[FormattableT]", 1061 "description": null, 1062 "kind": "union", 1063 "base_type": { 1064 "type_str": "Union", 1065 "description": null, 1066 "kind": "simple", 1067 "symbol_name": "Union", 1068 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 1069 }, 1070 "parameters": [ 1071 { 1072 "type_str": "AsyncStreamResponse", 1073 "description": null, 1074 "kind": "simple", 1075 "symbol_name": "AsyncStreamResponse", 1076 "doc_url": "/docs/api/llm/responses#async-stream-response" 1077 }, 1078 { 1079 "type_str": "AsyncStreamResponse[FormattableT]", 1080 "description": null, 1081 "kind": "generic", 1082 "base_type": { 1083 "type_str": "AsyncStreamResponse", 1084 "description": null, 1085 "kind": "simple", 1086 "symbol_name": "AsyncStreamResponse", 1087 "doc_url": "/docs/api/llm/responses#async-stream-response" 1088 }, 1089 "parameters": [ 1090 { 1091 "type_str": "FormattableT", 1092 "description": null, 1093 "kind": "simple", 1094 "symbol_name": "FormattableT", 1095 "doc_url": "/docs/api/llm/formatting#formattable-t" 1096 } 1097 ], 1098 "doc_url": null 1099 } 1100 ], 1101 "doc_url": null 1102 } 1103}} 1104/> 1105 1106 1107 1108## <ApiType type="Class" slug="context-message-template" symbolName="ContextMessageTemplate" /> ContextMessageTemplate 1109 1110Protocol for a context-aware prompt function that returns \`UserContent\` or \`Sequence[Message]\`. 1111 1112A \`MessageTemplate\` with a first parameter named \`'ctx'\` of type \`Context[DepsT]\`. 1113Can be converted by the \`llm.prompt\` decorator into a \`ContextPrompt\`, or by 1114the \`llm.call\` decorator into a \`ContextCall\`. 1115 1116**Bases:** 1117<TypeLink type={{"type_str": "Protocol[P, DepsT]", "description": null, "kind": "generic", "base_type": {"type_str": "Protocol", "description": null, "kind": "simple", "symbol_name": "Protocol", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Protocol"}, "parameters": [{"type_str": "P", "description": null, "kind": "simple", "symbol_name": "P", "doc_url": "/docs/api/llm/types#p"}, {"type_str": "DepsT", "description": null, "kind": "s
1117imple", "symbol_name": "DepsT", "doc_url": null}], "doc_url": null}} /> 1118 1119 1120## <ApiType type="Class" slug="context-prompt" symbolName="ContextPrompt" /> ContextPrompt 1121 1122A context-aware prompt that can be called with a model to generate a response. 1123 1124Created by decorating a \`ContextMessageTemplate\` with \`llm.prompt\`. The decorated 1125function (with first parameter \`'ctx'\` of type \`Context[DepsT]\`) becomes callable 1126with a \`Model\` to generate LLM responses with context dependencies. 1127 1128A \`ContextPrompt\` is essentially: \`ContextMessageTemplate\` + tools + format. 1129It can be invoked with a model: \`prompt(model, ctx, *args, **kwargs)\`. 1130 1131**Bases:** 1132<TypeLink type={{"type_str": "Generic[P, DepsT, FormattableT]", "description": null, "kind": "generic", "base_type": {"type_str": "Generic", "description": null, "kind": "simple", "symbol_name": "Generic", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Generic"}, "parameters": [{"type_str": "P", "description": null, "kind": "simple", "symbol_name": "P", "doc_url": "/docs/api/llm/types#p"}, {"type_str": "DepsT", "description": null, "kind": "simple", "symbol_name": "DepsT", "doc_url": null}, {"type_str": "FormattableT", "description": null, "kind": "simple", "symbol_name": "FormattableT", "doc_url": "/docs/api/llm/formatting#formattable-t"}], "doc_url": null}} /> 1133 1134<AttributesTable 1135 attributes={[ 1136 { 1137 "name": "fn", 1138 "type_info": { 1139 "type_str": "ContextMessageTemplate[P, DepsT]", 1140 "description": null, 1141 "kind": "generic", 1142 "base_type": { 1143 "type_str": "ContextMessageTemplate", 1144 "description": null, 1145 "kind": "simple", 1146 "symbol_name": "ContextMessageTemplate", 1147 "doc_url": null 1148 }, 1149 "parameters": [ 1150 { 1151 "type_str": "P", 1152 "description": null, 1153 "kind": "simple", 1154 "symbol_name": "P", 1155 "doc_url": null 1156 }, 1157 { 1158 "type_str": "DepsT", 1159 "description": null, 1160 "kind": "simple", 1161 "symbol_name": "DepsT", 1162 "doc_url": null 1163 } 1164 ], 1165 "doc_url": null 1166 }, 1167 "description": "The underlying context-aware prompt function that generates message content." 1168 }, 1169 { 1170 "name": "toolkit", 1171 "type_info": { 1172 "type_str": "ContextToolkit[DepsT]", 1173 "description": null, 1174 "kind": "generic", 1175 "base_type": { 1176 "type_str": "ContextToolkit", 1177 "description": null, 1178 "kind": "simple", 1179 "symbol_name": "ContextToolkit", 1180 "doc_url": null 1181 }, 1182 "parameters": [ 1183 { 1184 "type_str": "DepsT", 1185 "description": null, 1186 "kind": "simple", 1187 "symbol_name": "DepsT", 1188 "doc_url": null 1189 } 1190 ], 1191 "doc_url": null 1192 }, 1193 "description": "The toolkit containing this prompt's context-aware tools." 1194 }, 1195 { 1196 "name": "format", 1197 "type_info": { 1198 "type_str": "type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None", 1199 "description": null, 1200 "kind": "union", 1201 "base_type": { 1202 "type_str": "Union", 1203 "description": null, 1204 "kind": "simple", 1205 "symbol_name": "Union", 1206 "doc_url": null 1207 }, 1208 "parameters": [ 1209 { 1210 "type_str": "type[FormattableT]", 1211 "description": null, 1212 "kind": "generic", 1213 "base_type": { 1214 "type_str": "type", 1215 "description": null, 1216 "kind": "simple", 1217 "symbol_name": "type", 1218 "doc_url": null 1219 }, 1220 "parameters": [ 1221 { 1222 "type_str": "FormattableT", 1223 "description": null, 1224 "kind": "simple", 1225 "symbol_name": "FormattableT", 1226 "doc_url": null 1227 } 1228 ], 1229 "doc_url": null 1230 }, 1231 { 1232 "type_str": "Format[FormattableT]", 1233 "description": null, 1234 "kind": "generic", 1235 "base_type": { 1236 "type_str": "Format", 1237 "description": null, 1238 "kind": "simple", 1239 "symbol_name": "Format", 1240 "doc_url": null 1241 }, 1242 "parameters": [ 1243 { 1244 "type_str": "FormattableT", 1245 "description": null, 1246 "kind": "simple", 1247 "symbol_name": "FormattableT", 1248 "doc_url": null 1249 } 1250 ], 1251 "doc_url": null 1252 }, 1253 { 1254 "type_str": "OutputParser[FormattableT]", 1255 "description": null, 1256 "kind": "generic", 1257 "base_type": { 1258 "type_str": "OutputParser", 1259 "description": null, 1260 "kind": "simple", 1261 "symbol_name": "OutputParser", 1262 "doc_url": null 1263 }, 1264 "parameters": [ 1265 { 1266 "type_str": "FormattableT", 1267 "description": null, 1268 "kind": "simple", 1269 "symbol_name": "FormattableT", 1270 "doc_url": null 1271 } 1272 ], 1273 "doc_url": null 1274 }, 1275 { 1276 "type_str": "None", 1277 "description": null, 1278 "kind": "simple", 1279 "symbol_name": "None", 1280 "doc_url": null 1281 } 1282 ], 1283 "doc_url": null 1284 }, 1285 "description": "The response format for the generated response." 1286 } 1287]} 1288/> 1289 1290## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--context-prompt-messages" symbolName="messages" /> messages 1291 1292Return the \`Messages\` from invoking this prompt. 1293 1294<ParametersTable 1295 parameters={[ 1296 { 1297 "name": "self", 1298 "type_info": { 1299 "type_str": "Any", 1300 "description": null, 1301 "kind": "simple", 1302 "symbol_name": null, 1303 "doc_url": null 1304 } 1305 }, 1306 { 1307 "name": "ctx", 1308 "type_info": { 1309 "type_str": "Context[DepsT]", 1310 "description": null, 1311 "kind": "generic", 1312 "base_type": { 1313 "type_str": "Context", 1314 "description": null, 1315 "kind": "simple", 1316 "symbol_name": "Context", 1317 "doc_url": null 1318 }, 1319 "parameters": [ 1320 { 1321 "type_str": "DepsT", 1322 "description": null, 1323 "kind": "simple", 1324 "symbol_name": "DepsT", 1325 "doc_url": null 1326 } 1327 ], 1328 "doc_url": null 1329 } 1330 }, 1331 { 1332 "name": "args", 1333 "type_info": { 1334 "type_str": "P.args", 1335 "description": null, 1336 "kind": "simple", 1337 "symbol_name": "P.args", 1338 "doc_url": null 1339 }, 1340 "default": "()" 1341 }, 1342 { 1343 "name": "kwargs", 1344 "type_info": { 1345 "type_str": "P.kwargs", 1346 "description": null, 1347 "kind": "simple", 1348 "symbol_name": "P.kwargs", 1349 "doc_url": null 1350 }, 1351 "default": "{}" 1352 } 1353]} 1354/> 1355 1356<ReturnTable 1357 returnType={{ 1358 "type_info": { 1359 "type_str": "Sequence[Message]", 1360 "description": null, 1361 "kind": "generic", 1362 "base_type": { 1363 "type_str": "Sequence", 1364 "description": null, 1365 "kind": "simple", 1366 "symbol_name": "Sequence", 1367 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Sequence" 1368 }, 1369 "parameters": [ 1370 { 1371 "type_str": "Message", 1372 "description": null, 1373 "kind": "simple", 1374 "symbol_name": "Message", 1375 "doc_url": "/docs/api/llm/messages#message" 1376 } 1377 ], 1378 "doc_url": null 1379 } 1380}} 1381/> 1382 1383 1384## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--context-prompt-call" symbolName="call" /> call 1385 1386Generates a response using the provided model. 1387 1388<ParametersTable 1389 parameters={[ 1390 { 1391 "name": "self", 1392 "type_info": { 1393 "type_str": "Any", 1394 "description": null, 1395 "kind": "simple", 1396 "symbol_name": null, 1397 "doc_url": null 1398 } 1399 }, 1400 { 1401 "name": "model", 1402 "type_info": { 1403 "type_str": "Model | ModelId", 1404 "description": null, 1405 "kind": "union", 1406 "base_type": { 1407 "type_str": "Union", 1408 "description": null, 1409 "kind": "simple", 1410 "symbol_name": "Union", 1411 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 1412 }, 1413 "parameters": [ 1414 { 1415 "type_str": "Model", 1416 "description": null, 1417 "kind": "simple", 1418 "symbol_name": "Model", 1419 "doc_url": "/docs/api/llm/models#model" 1420 }, 1421 { 1422 "type_str": "ModelId", 1423 "description": null, 1424 "kind": "simple", 1425 "symbol_name": "ModelId", 1426 "doc_url": "/docs/api/llm/providers#model-id" 1427 } 1428 ], 1429 "doc_url": null 1430 } 1431 }, 1432 { 1433 "name": "ctx", 1434 "type_info": { 1435 "type_str": "Context[DepsT]", 1436 "description": null, 1437 "kind": "generic", 1438 "base_type": { 1439 "type_str": "Context", 1440 "description": null, 1441 "kind": "simple", 1442 "symbol_name": "Context", 1443 "doc_url": null 1444 }, 1445 "parameters": [ 1446 { 1447 "type_str": "DepsT", 1448 "description": null, 1449 "kind": "simple", 1450 "symbol_name": "DepsT", 1451 "doc_url": null 1452 } 1453 ], 1454 "doc_url": null 1455 } 1456 }, 1457 { 1458 "name": "args", 1459 "type_info": { 1460 "type_str": "P.args", 1461 "description": null, 1462 "kind": "simple", 1463 "symbol_name": "P.args", 1464 "doc_url": null 1465 }, 1466 "default": "()" 1467 }, 1468 { 1469 "name": "kwargs", 1470 "type_info": { 1471 "type_str": "P.kwargs", 1472 "description": null, 1473 "kind": "simple", 1474 "symbol_name": "P.kwargs", 1475 "doc_url": null 1476 }, 1477 "default": "{}" 1478 } 1479]} 1480/> 1481 1482<ReturnTable 1483 returnType={{ 1484 "type_info": { 1485 "type_str": "ContextResponse[DepsT, None] | ContextResponse[DepsT, FormattableT]", 1486 "description": null, 1487 "kind": "union", 1488 "base_type": { 1489 "type_str": "Union", 1490 "description": null, 1491 "kind": "simple", 1492 "symbol_name": "Union", 1493 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 1494 }, 1495 "parameters": [ 1496 { 1497 "type_str": "ContextResponse[DepsT, None]", 1498 "description": null, 1499 "kind": "generic", 1500 "base_type": { 1501 "type_str": "ContextResponse", 1502 "description": null, 1503 "kind": "simple", 1504 "symbol_name": "ContextResponse", 1505 "doc_url": "/docs/api/llm/responses#context-response" 1506 }, 1507 "parameters": [ 1508 { 1509 "type_str": "DepsT", 1510 "description": null, 1511 "kind": "simple", 1512 "symbol_name": "DepsT", 1513 "doc_url": null 1514 }, 1515 { 1516 "type_str": "None", 1517 "description": null, 1518 "kind": "simple", 1519 "symbol_name": "None", 1520 "doc_url": "https://docs.python.org/3/library/constants.html#None" 1521 } 1522 ], 1523 "doc_url": null 1524 }, 1525 { 1526 "type_str": "ContextResponse[DepsT, FormattableT]", 1527 "description": null, 1528 "kind": "generic", 1529 "base_type": { 1530 "type_str": "ContextResponse", 1531 "description": null, 1532 "kind": "simple", 1533 "symbol_name": "ContextResponse", 1534 "doc_url": "/docs/api/llm/responses#context-response" 1535 }, 1536 "parameters": [ 1537 { 1538 "type_str": "DepsT", 1539 "description": null, 1540 "kind": "simple", 1541 "symbol_name": "DepsT", 1542 "doc_url": null 1543 }, 1544 { 1545 "type_str": "FormattableT", 1546 "description": null, 1547 "kind": "simple", 1548 "symbol_name": "FormattableT", 1549 "doc_url": "/docs/api/llm/formatting#formattable-t" 1550 } 1551 ], 1552 "doc_url": null 1553 } 1554 ], 1555 "doc_url": null 1556 } 1557}} 1558/> 1559 1560 1561## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--context-prompt-stream" symbolName="stream" /> stream 1562 1563Generates a streaming response using the provided model. 1564 1565<ParametersTable 1566 parameters={[ 1567 { 1568 "name": "self", 1569 "type_info": { 1570 "type_str": "Any", 1571 "description": null, 1572 "kind": "simple", 1573 "symbol_name": null, 1574 "doc_url": null 1575 } 1576 }, 1577 { 1578 "name": "model", 1579 "type_info": { 1580 "type_str": "Model | ModelId", 1581 "description": null, 1582 "kind": "union", 1583 "base_type": { 1584 "type_str": "Union", 1585 "description": null, 1586 "kind": "simple", 1587 "symbol_name": "Union", 1588 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 1589 }, 1590 "parameters": [ 1591 { 1592 "type_str": "Model", 1593 "description": null, 1594 "kind": "simple", 1595 "symbol_name": "Model", 1596 "doc_url": "/docs/api/llm/models#model" 1597 }, 1598 { 1599 "type_str": "ModelId", 1600 "description": null, 1601 "kind": "simple", 1602 "symbol_name": "ModelId", 1603 "doc_url": "/docs/api/llm/providers#model-id" 1604 } 1605 ], 1606 "doc_url": null 1607 } 1608 }, 1609 { 1610 "name": "ctx", 1611 "type_info": { 1612 "type_str": "Context[DepsT]", 1613 "description": null, 1614 "kind": "generic", 1615 "base_type": { 1616 "type_str": "Context", 1617 "description": null, 1618 "kind": "simple", 1619 "symbol_name": "Context", 1620 "doc_url": null 1621 }, 1622 "parameters": [ 1623 { 1624 "type_str": "DepsT", 1625 "description": null, 1626 "kind": "simple", 1627 "symbol_name": "DepsT", 1628 "doc_url": null 1629 } 1630 ], 1631 "doc_url": null 1632 } 1633 }, 1634 { 1635 "name": "args", 1636 "type_info": { 1637 "type_str": "P.args", 1638 "description": null, 1639 "kind": "simple", 1640 "symbol_name": "P.args", 1641 "doc_url": null 1642 }, 1643 "default": "()" 1644 }, 1645 { 1646 "name": "kwargs", 1647 "type_info": { 1648 "type_str": "P.kwargs", 1649 "description": null, 1650 "kind": "simple", 1651 "symbol_name": "P.kwargs", 1652 "doc_url": null 1653 }, 1654 "default": "{}" 1655 } 1656]} 1657/> 1658 1659<ReturnTable 1660 returnType={{ 1661 "type_info": { 1662 "type_str": "ContextStreamResponse[DepsT, None] | ContextStreamResponse[DepsT, FormattableT]", 1663 "description": null, 1664 "kind": "union", 1665 "base_type": { 1666 "type_str": "Union", 1667 "description": null, 1668 "kind": "simple", 1669 "symbol_name": "Union", 1670 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 1671 }, 1672 "parameters": [ 1673 { 1674 "type_str": "ContextStreamResponse[DepsT, None]", 1675 "description": null, 1676 "kind": "generic", 1677 "base_type": { 1678 "type_str": "ContextStreamResponse", 1679 "description": null, 1680 "kind": "simple", 1681 "symbol_name": "ContextStreamResponse", 1682 "doc_url": "/docs/api/llm/responses#context-stream-response" 1683 }, 1684 "parameters": [ 1685 { 1686 "type_str": "DepsT", 1687 "description": null, 1688 "kind": "simple", 1689 "symbol_name": "DepsT", 1690 "doc_url": null 1691 }, 1692 { 1693 "type_str": "None", 1694 "description": null, 1695 "kind": "simple", 1696 "symbol_name": "None", 1697 "doc_url": "https://docs.python.org/3/library/constants.html#None" 1698 } 1699 ], 1700 "doc_url": null 1701 }, 1702 { 1703 "type_str": "ContextStreamResponse[DepsT, FormattableT]", 1704 "description": null, 1705 "kind": "generic", 1706 "base_type": { 1707 "type_str": "ContextStreamResponse", 1708 "description": null, 1709 "kind": "simple", 1710 "symbol_name": "ContextStreamResponse", 1711 "doc_url": "/docs/api/llm/responses#context-stream-response" 1712 }, 1713 "parameters": [ 1714 { 1715 "type_str": "DepsT", 1716 "description": null, 1717 "kind": "simple", 1718 "symbol_name": "DepsT", 1719 "doc_url": null 1720 }, 1721 { 1722 "type_str": "FormattableT", 1723 "description": null, 1724 "kind": "simple", 1725 "symbol_name": "FormattableT", 1726 "doc_url": "/docs/api/llm/formatting#formattable-t" 1727 } 1728 ], 1729 "doc_url": null 1730 } 1731 ], 1732 "doc_url": null 1733 } 1734}} 1735/> 1736 1737 1738 1739## <ApiType type="Class" slug="message-template" symbolName="MessageTemplate" /> MessageTemplate 1740 1741Protocol for a prompt function that returns \`UserContent\` or \`Sequence[Message]\`. 1742 1743A \`MessageTemplate\` is a raw function that returns prompt content. It can be 1744converted by the \`llm.prompt\` decorator into a \`Prompt\` (callable with a \`Model\`), 1745or by the \`llm.call\` decora
1745tor into a \`Call\` (\`Prompt\` + \`Model\`). 1746 1747**Bases:** 1748<TypeLink type={{"type_str": "Protocol[P]", "description": null, "kind": "generic", "base_type": {"type_str": "Protocol", "description": null, "kind": "simple", "symbol_name": "Protocol", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Protocol"}, "parameters": [{"type_str": "P", "description": null, "kind": "simple", "symbol_name": "P", "doc_url": "/docs/api/llm/types#p"}], "doc_url": null}} /> 1749 1750 1751## <ApiType type="Class" slug="prompt" symbolName="Prompt" /> Prompt 1752 1753A prompt that can be called with a model to generate a response. 1754 1755Created by decorating a \`MessageTemplate\` with \`llm.prompt\`. The decorated 1756function becomes callable with a \`Model\` to generate LLM responses. 1757 1758A \`Prompt\` is essentially: \`MessageTemplate\` + tools + format. 1759It can be invoked with a model: \`prompt(model, *args, **kwargs)\`. 1760 1761**Bases:** 1762<TypeLink type={{"type_str": "Generic[P, FormattableT]", "description": null, "kind": "generic", "base_type": {"type_str": "Generic", "description": null, "kind": "simple", "symbol_name": "Generic", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Generic"}, "parameters": [{"type_str": "P", "description": null, "kind": "simple", "symbol_name": "P", "doc_url": "/docs/api/llm/types#p"}, {"type_str": "FormattableT", "description": null, "kind": "simple", "symbol_name": "FormattableT", "doc_url": "/docs/api/llm/formatting#formattable-t"}], "doc_url": null}} /> 1763 1764<AttributesTable 1765 attributes={[ 1766 { 1767 "name": "fn", 1768 "type_info": { 1769 "type_str": "MessageTemplate[P]", 1770 "description": null, 1771 "kind": "generic", 1772 "base_type": { 1773 "type_str": "MessageTemplate", 1774 "description": null, 1775 "kind": "simple", 1776 "symbol_name": "MessageTemplate", 1777 "doc_url": null 1778 }, 1779 "parameters": [ 1780 { 1781 "type_str": "P", 1782 "description": null, 1783 "kind": "simple", 1784 "symbol_name": "P", 1785 "doc_url": null 1786 } 1787 ], 1788 "doc_url": null 1789 }, 1790 "description": "The underlying prompt function that generates message content." 1791 }, 1792 { 1793 "name": "toolkit", 1794 "type_info": { 1795 "type_str": "Toolkit", 1796 "description": null, 1797 "kind": "simple", 1798 "symbol_name": "Toolkit", 1799 "doc_url": null 1800 }, 1801 "description": "The toolkit containing this prompt's tools." 1802 }, 1803 { 1804 "name": "format", 1805 "type_info": { 1806 "type_str": "type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None", 1807 "description": null, 1808 "kind": "union", 1809 "base_type": { 1810 "type_str": "Union", 1811 "description": null, 1812 "kind": "simple", 1813 "symbol_name": "Union", 1814 "doc_url": null 1815 }, 1816 "parameters": [ 1817 { 1818 "type_str": "type[FormattableT]", 1819 "description": null, 1820 "kind": "generic", 1821 "base_type": { 1822 "type_str": "type", 1823 "description": null, 1824 "kind": "simple", 1825 "symbol_name": "type", 1826 "doc_url": null 1827 }, 1828 "parameters": [ 1829 { 1830 "type_str": "FormattableT", 1831 "description": null, 1832 "kind": "simple", 1833 "symbol_name": "FormattableT", 1834 "doc_url": null 1835 } 1836 ], 1837 "doc_url": null 1838 }, 1839 { 1840 "type_str": "Format[FormattableT]", 1841 "description": null, 1842 "kind": "generic", 1843 "base_type": { 1844 "type_str": "Format", 1845 "description": null, 1846 "kind": "simple", 1847 "symbol_name": "Format", 1848 "doc_url": null 1849 }, 1850 "parameters": [ 1851 { 1852 "type_str": "FormattableT", 1853 "description": null, 1854 "kind": "simple", 1855 "symbol_name": "FormattableT", 1856 "doc_url": null 1857 } 1858 ], 1859 "doc_url": null 1860 }, 1861 { 1862 "type_str": "OutputParser[FormattableT]", 1863 "description": null, 1864 "kind": "generic", 1865 "base_type": { 1866 "type_str": "OutputParser", 1867 "description": null, 1868 "kind": "simple", 1869 "symbol_name": "OutputParser", 1870 "doc_url": null 1871 }, 1872 "parameters": [ 1873 { 1874 "type_str": "FormattableT", 1875 "description": null, 1876 "kind": "simple", 1877 "symbol_name": "FormattableT", 1878 "doc_url": null 1879 } 1880 ], 1881 "doc_url": null 1882 }, 1883 { 1884 "type_str": "None", 1885 "description": null, 1886 "kind": "simple", 1887 "symbol_name": "None", 1888 "doc_url": null 1889 } 1890 ], 1891 "doc_url": null 1892 }, 1893 "description": "The response format for the generated response." 1894 } 1895]} 1896/> 1897 1898## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--prompt-messages" symbolName="messages" /> messages 1899 1900Return the \`Messages\` from invoking this prompt. 1901 1902<ParametersTable 1903 parameters={[ 1904 { 1905 "name": "self", 1906 "type_info": { 1907 "type_str": "Any", 1908 "description": null, 1909 "kind": "simple", 1910 "symbol_name": null, 1911 "doc_url": null 1912 } 1913 }, 1914 { 1915 "name": "args", 1916 "type_info": { 1917 "type_str": "P.args", 1918 "description": null, 1919 "kind": "simple", 1920 "symbol_name": "P.args", 1921 "doc_url": null 1922 }, 1923 "default": "()" 1924 }, 1925 { 1926 "name": "kwargs", 1927 "type_info": { 1928 "type_str": "P.kwargs", 1929 "description": null, 1930 "kind": "simple", 1931 "symbol_name": "P.kwargs", 1932 "doc_url": null 1933 }, 1934 "default": "{}" 1935 } 1936]} 1937/> 1938 1939<ReturnTable 1940 returnType={{ 1941 "type_info": { 1942 "type_str": "Sequence[Message]", 1943 "description": null, 1944 "kind": "generic", 1945 "base_type": { 1946 "type_str": "Sequence", 1947 "description": null, 1948 "kind": "simple", 1949 "symbol_name": "Sequence", 1950 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Sequence" 1951 }, 1952 "parameters": [ 1953 { 1954 "type_str": "Message", 1955 "description": null, 1956 "kind": "simple", 1957 "symbol_name": "Message", 1958 "doc_url": "/docs/api/llm/messages#message" 1959 } 1960 ], 1961 "doc_url": null 1962 } 1963}} 1964/> 1965 1966 1967## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--prompt-call" symbolName="call" /> call 1968 1969Generates a response using the provided model. 1970 1971<ParametersTable 1972 parameters={[ 1973 { 1974 "name": "self", 1975 "type_info": { 1976 "type_str": "Any", 1977 "description": null, 1978 "kind": "simple", 1979 "symbol_name": null, 1980 "doc_url": null 1981 } 1982 }, 1983 { 1984 "name": "model", 1985 "type_info": { 1986 "type_str": "Model | ModelId", 1987 "description": null, 1988 "kind": "union", 1989 "base_type": { 1990 "type_str": "Union", 1991 "description": null, 1992 "kind": "simple", 1993 "symbol_name": "Union", 1994 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 1995 }, 1996 "parameters": [ 1997 { 1998 "type_str": "Model", 1999 "description": null, 2000 "kind": "simple", 2001 "symbol_name": "Model", 2002 "doc_url": "/docs/api/llm/models#model" 2003 }, 2004 { 2005 "type_str": "ModelId", 2006 "description": null, 2007 "kind": "simple", 2008 "symbol_name": "ModelId", 2009 "doc_url": "/docs/api/llm/providers#model-id" 2010 } 2011 ], 2012 "doc_url": null 2013 } 2014 }, 2015 { 2016 "name": "args", 2017 "type_info": { 2018 "type_str": "P.args", 2019 "description": null, 2020 "kind": "simple", 2021 "symbol_name": "P.args", 2022 "doc_url": null 2023 }, 2024 "default": "()" 2025 }, 2026 { 2027 "name": "kwargs", 2028 "type_info": { 2029 "type_str": "P.kwargs", 2030 "description": null, 2031 "kind": "simple", 2032 "symbol_name": "P.kwargs", 2033 "doc_url": null 2034 }, 2035 "default": "{}" 2036 } 2037]} 2038/> 2039 2040<ReturnTable 2041 returnType={{ 2042 "type_info": { 2043 "type_str": "Response | Response[FormattableT]", 2044 "description": null, 2045 "kind": "union", 2046 "base_type": { 2047 "type_str": "Union", 2048 "description": null, 2049 "kind": "simple", 2050 "symbol_name": "Union", 2051 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 2052 }, 2053 "parameters": [ 2054 { 2055 "type_str": "Response", 2056 "description": null, 2057 "kind": "simple", 2058 "symbol_name": "Response", 2059 "doc_url": "/docs/api/llm/responses#response" 2060 }, 2061 { 2062 "type_str": "Response[FormattableT]", 2063 "description": null, 2064 "kind": "generic", 2065 "base_type": { 2066 "type_str": "Response", 2067 "description": null, 2068 "kind": "simple", 2069 "symbol_name": "Response", 2070 "doc_url": "/docs/api/llm/responses#response" 2071 }, 2072 "parameters": [ 2073 { 2074 "type_str": "FormattableT", 2075 "description": null, 2076 "kind": "simple", 2077 "symbol_name": "FormattableT", 2078 "doc_url": "/docs/api/llm/formatting#formattable-t" 2079 } 2080 ], 2081 "doc_url": null 2082 } 2083 ], 2084 "doc_url": null 2085 } 2086}} 2087/> 2088 2089 2090## <ApiType type="Function" slug="mirascope-llm-prompts-prompts--prompt-stream" symbolName="stream" /> stream 2091 2092Generates a streaming response using the provided model. 2093 2094<ParametersTable 2095 parameters={[ 2096 { 2097 "name": "self", 2098 "type_info": { 2099 "type_str": "Any", 2100 "description": null, 2101 "kind": "simple", 2102 "symbol_name": null, 2103 "doc_url": null 2104 } 2105 }, 2106 { 2107 "name": "model", 2108 "type_info": { 2109 "type_str": "Model | ModelId", 2110 "description": null, 2111 "kind": "union", 2112 "base_type": { 2113 "type_str": "Union", 2114 "description": null, 2115 "kind": "simple", 2116 "symbol_name": "Union", 2117 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 2118 }, 2119 "parameters": [ 2120 { 2121 "type_str": "Model", 2122 "description": null, 2123 "kind": "simple", 2124 "symbol_name": "Model", 2125 "doc_url": "/docs/api/llm/models#model" 2126 }, 2127 { 2128 "type_str": "ModelId", 2129 "description": null, 2130 "kind": "simple", 2131 "symbol_name": "ModelId", 2132 "doc_url": "/docs/api/llm/providers#model-id" 2133 } 2134 ], 2135 "doc_url": null 2136 } 2137 }, 2138 { 2139 "name": "args", 2140 "type_info": { 2141 "type_str": "P.args", 2142 "description": null, 2143 "kind": "simple", 2144 "symbol_name": "P.args", 2145 "doc_url": null 2146 }, 2147 "default": "()" 2148 }, 2149 { 2150 "name": "kwargs", 2151 "type_info": { 2152 "type_str": "P.kwargs", 2153 "description": null, 2154 "kind": "simple", 2155 "symbol_name": "P.kwargs", 2156 "doc_url": null 2157 }, 2158 "default": "{}" 2159 } 2160]} 2161/> 2162 2163<ReturnTable 2164 returnType={{ 2165 "type_info": { 2166 "type_str": "StreamResponse | StreamResponse[FormattableT]", 2167 "description": null, 2168 "kind": "union", 2169 "base_type": { 2170 "type_str": "Union", 2171 "description": null, 2172 "kind": "simple", 2173 "symbol_name": "Union", 2174 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 2175 }, 2176 "parameters": [ 2177 { 2178 "type_str": "StreamResponse", 2179 "description": null, 2180 "kind": "simple", 2181 "symbol_name": "StreamResponse", 2182 "doc_url": "/docs/api/llm/responses#stream-response" 2183 }, 2184 { 2185 "type_str": "StreamResponse[FormattableT]", 2186 "description": null, 2187 "kind": "generic", 2188 "base_type": { 2189 "type_str": "StreamResponse", 2190 "description": null, 2191 "kind": "simple", 2192 "symbol_name": "StreamResponse", 2193 "doc_url": "/docs/api/llm/responses#stream-response" 2194 }, 2195 "parameters": [ 2196 { 2197 "type_str": "FormattableT", 2198 "description": null, 2199 "kind": "simple", 2200 "symbol_name": "FormattableT", 2201 "doc_url": "/docs/api/llm/formatting#formattable-t" 2202 } 2203 ], 2204 "doc_url": null 2205 } 2206 ], 2207 "doc_url": null 2208 } 2209}} 2210/> 2211 2212 2213 2214## <ApiType type="Class" slug="prompt-decorator" symbolName="PromptDecorator" /> PromptDecorator 2215 2216Decorator for converting a \`MessageTemplate\` into a \`Prompt\`. 2217 2218Takes a raw prompt function that returns message content and wraps it with 2219tools and format support, creating a \`Prompt\` that can be called with a model. 2220 2221The decorator automatically detects whether the function is async or context-aware
2222and creates the appropriate Prompt variant (Prompt, AsyncPrompt, ContextPrompt, 2223or AsyncContextPrompt). 2224 2225**Bases:** 2226<TypeLink type={{"type_str": "Generic[ToolT, FormattableT]", "description": null, "kind": "generic", "base_type": {"type_str": "Generic", "description": null, "kind": "simple", "symbol_name": "Generic", "doc_url": "https://docs.python.org/3/library/typing.html#typing.Generic"}, "parameters": [{"type_str": "ToolT", "description": null, "kind": "simple", "symbol_name": "ToolT", "doc_url": "/docs/api/llm/tools#tool-t"}, {"type_str": "FormattableT", "description": null, "kind": "simple", "symbol_name": "FormattableT", "doc_url": "/docs/api/llm/formatting#formattable-t"}], "doc_url": null}} /> 2227 2228<AttributesTable 2229 attributes={[ 2230 { 2231 "name": "tools", 2232 "type_info": { 2233 "type_str": "Sequence[ToolT] | None", 2234 "description": null, 2235 "kind": "union", 2236 "base_type": { 2237 "type_str": "Union", 2238 "description": null, 2239 "kind": "simple", 2240 "symbol_name": "Union", 2241 "doc_url": null 2242 }, 2243 "parameters": [ 2244 { 2245 "type_str": "Sequence[ToolT]", 2246 "description": null, 2247 "kind": "generic", 2248 "base_type": { 2249 "type_str": "Sequence", 2250 "description": null, 2251 "kind": "simple", 2252 "symbol_name": "Sequence", 2253 "doc_url": null 2254 }, 2255 "parameters": [ 2256 { 2257 "type_str": "ToolT", 2258 "description": null, 2259 "kind": "simple", 2260 "symbol_name": "ToolT", 2261 "doc_url": null 2262 } 2263 ], 2264 "doc_url": null 2265 }, 2266 { 2267 "type_str": "None", 2268 "description": null, 2269 "kind": "simple", 2270 "symbol_name": "None", 2271 "doc_url": null 2272 } 2273 ], 2274 "doc_url": null 2275 }, 2276 "description": "The tools that are included in the prompt, if any." 2277 }, 2278 { 2279 "name": "format", 2280 "type_info": { 2281 "type_str": "type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None", 2282 "description": null, 2283 "kind": "union", 2284 "base_type": { 2285 "type_str": "Union", 2286 "description": null, 2287 "kind": "simple", 2288 "symbol_name": "Union", 2289 "doc_url": null 2290 }, 2291 "parameters": [ 2292 { 2293 "type_str": "type[FormattableT]", 2294 "description": null, 2295 "kind": "generic", 2296 "base_type": { 2297 "type_str": "type", 2298 "description": null, 2299 "kind": "simple", 2300 "symbol_name": "type", 2301 "doc_url": null 2302 }, 2303 "parameters": [ 2304 { 2305 "type_str": "FormattableT", 2306 "description": null, 2307 "kind": "simple", 2308 "symbol_name": "FormattableT", 2309 "doc_url": null 2310 } 2311 ], 2312 "doc_url": null 2313 }, 2314 { 2315 "type_str": "Format[FormattableT]", 2316 "description": null, 2317 "kind": "generic", 2318 "base_type": { 2319 "type_str": "Format", 2320 "description": null, 2321 "kind": "simple", 2322 "symbol_name": "Format", 2323 "doc_url": null 2324 }, 2325 "parameters": [ 2326 { 2327 "type_str": "FormattableT", 2328 "description": null, 2329 "kind": "simple", 2330 "symbol_name": "FormattableT", 2331 "doc_url": null 2332 } 2333 ], 2334 "doc_url": null 2335 }, 2336 { 2337 "type_str": "OutputParser[FormattableT]", 2338 "description": null, 2339 "kind": "generic", 2340 "base_type": { 2341 "type_str": "OutputParser", 2342 "description": null, 2343 "kind": "simple", 2344 "symbol_name": "OutputParser", 2345 "doc_url": null 2346 }, 2347 "parameters": [ 2348 { 2349 "type_str": "FormattableT", 2350 "description": null, 2351 "kind": "simple", 2352 "symbol_name": "FormattableT", 2353 "doc_url": null 2354 } 2355 ], 2356 "doc_url": null 2357 }, 2358 { 2359 "type_str": "None", 2360 "description": null, 2361 "kind": "simple", 2362 "symbol_name": "None", 2363 "doc_url": null 2364 } 2365 ], 2366 "doc_url": null 2367 }, 2368 "description": "The structured output format off the prompt, if any." 2369 } 2370]} 2371/> 2372 2373 2374## <ApiType type="Function" slug="prompt_fn" symbolName="prompt" /> prompt 2375 2376Decorates a \`MessageTemplate\` to create a \`Prompt\` callable with a model. 2377 2378This decorator transforms a raw prompt function (that returns message content) 2379into a \`Prompt\` object that can be invoked with a model to generate LLM responses. 2380 2381The decorator automatically detects the function type: 2382- If the first parameter is named \`'ctx'\` with type \`llm.Context[T]\`, creates a \`ContextPrompt\` 2383- If the function is async, creates an \`AsyncPrompt\` or \`AsyncContextPrompt\` 2384- Otherwise, creates a regular \`Prompt\` 2385 2386<ParametersTable 2387 parameters={[ 2388 { 2389 "name": "__fn", 2390 "type_info": { 2391 "type_str": "AsyncContextMessageTemplate[P, DepsT] | ContextMessageTemplate[P, DepsT] | AsyncMessageTemplate[P] | MessageTemplate[P] | None", 2392 "description": null, 2393 "kind": "union", 2394 "base_type": { 2395 "type_str": "Union", 2396 "description": null, 2397 "kind": "simple", 2398 "symbol_name": "Union", 2399 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 2400 }, 2401 "parameters": [ 2402 { 2403 "type_str": "AsyncContextMessageTemplate[P, DepsT]", 2404 "description": null, 2405 "kind": "generic", 2406 "base_type": { 2407 "type_str": "AsyncContextMessageTemplate", 2408 "description": null, 2409 "kind": "simple", 2410 "symbol_name": "AsyncContextMessageTemplate", 2411 "doc_url": "/docs/api/llm/prompts#async-context-message-template" 2412 }, 2413 "parameters": [ 2414 { 2415 "type_str": "P", 2416 "description": null, 2417 "kind": "simple", 2418 "symbol_name": "P", 2419 "doc_url": "/docs/api/llm/types#p" 2420 }, 2421 { 2422 "type_str": "DepsT", 2423 "description": null, 2424 "kind": "simple", 2425 "symbol_name": "DepsT", 2426 "doc_url": null 2427 } 2428 ], 2429 "doc_url": null 2430 }, 2431 { 2432 "type_str": "ContextMessageTemplate[P, DepsT]", 2433 "description": null, 2434 "kind": "generic", 2435 "base_type": { 2436 "type_str": "ContextMessageTemplate", 2437 "description": null, 2438 "kind": "simple", 2439 "symbol_name": "ContextMessageTemplate", 2440 "doc_url": "/docs/api/llm/prompts#context-message-template" 2441 }, 2442 "parameters": [ 2443 { 2444 "type_str": "P", 2445 "description": null, 2446 "kind": "simple", 2447 "symbol_name": "P", 2448 "doc_url": "/docs/api/llm/types#p" 2449 }, 2450 { 2451 "type_str": "DepsT", 2452 "description": null, 2453 "kind": "simple", 2454 "symbol_name": "DepsT", 2455 "doc_url": null 2456 } 2457 ], 2458 "doc_url": null 2459 }, 2460 { 2461 "type_str": "AsyncMessageTemplate[P]", 2462 "description": null, 2463 "kind": "generic", 2464 "base_type": { 2465 "type_str": "AsyncMessageTemplate", 2466 "description": null, 2467 "kind": "simple", 2468 "symbol_name": "AsyncMessageTemplate", 2469 "doc_url": "/docs/api/llm/prompts#async-message-template" 2470 }, 2471 "parameters": [ 2472 { 2473 "type_str": "P", 2474 "description": null, 2475 "kind": "simple", 2476 "symbol_name": "P", 2477 "doc_url": "/docs/api/llm/types#p" 2478 } 2479 ], 2480 "doc_url": null 2481 }, 2482 { 2483 "type_str": "MessageTemplate[P]", 2484 "description": null, 2485 "kind": "generic", 2486 "base_type": { 2487 "type_str": "MessageTemplate", 2488 "description": null, 2489 "kind": "simple", 2490 "symbol_name": "MessageTemplate", 2491 "doc_url": "/docs/api/llm/prompts#message-template" 2492 }, 2493 "parameters": [ 2494 { 2495 "type_str": "P", 2496 "description": null, 2497 "kind": "simple", 2498 "symbol_name": "P", 2499 "doc_url": "/docs/api/llm/types#p" 2500 } 2501 ], 2502 "doc_url": null 2503 }, 2504 { 2505 "type_str": "None", 2506 "description": null, 2507 "kind": "simple", 2508 "symbol_name": "None", 2509 "doc_url": "https://docs.python.org/3/library/constants.html#None" 2510 } 2511 ], 2512 "doc_url": null 2513 }, 2514 "default": "None", 2515 "description": "The prompt function to decorate (optional, for decorator syntax without parens)" 2516 }, 2517 { 2518 "name": "tools", 2519 "type_info": { 2520 "type_str": "Sequence[ToolT] | None", 2521 "description": null, 2522 "kind": "union", 2523 "base_type": { 2524 "type_str": "Union", 2525 "description": null, 2526 "kind": "simple", 2527 "symbol_name": "Union", 2528 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 2529 }, 2530 "parameters": [ 2531 { 2532 "type_str": "Sequence[ToolT]", 2533 "description": null, 2534 "kind": "generic", 2535 "base_type": { 2536 "type_str": "Sequence", 2537 "description": null, 2538 "kind": "simple", 2539 "symbol_name": "Sequence", 2540 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Sequence" 2541 }, 2542 "parameters": [ 2543 { 2544 "type_str": "ToolT", 2545 "description": null, 2546 "kind": "simple", 2547 "symbol_name": "ToolT", 2548 "doc_url": "/docs/api/llm/tools#tool-t" 2549 } 2550 ], 2551 "doc_url": null 2552 }, 2553 { 2554 "type_str": "None", 2555 "description": null, 2556 "kind": "simple", 2557 "symbol_name": "None", 2558 "doc_url": "https://docs.python.org/3/library/constants.html#None" 2559 } 2560 ], 2561 "doc_url": null 2562 }, 2563 "default": "None", 2564 "description": "Optional \`Sequence\` of tools to make available to the LLM" 2565 }, 2566 { 2567 "name": "format", 2568 "type_info": { 2569 "type_str": "type[FormattableT] | Format[FormattableT] | OutputParser[FormattableT] | None", 2570 "description": null, 2571 "kind": "union", 2572 "base_type": { 2573 "type_str": "Union", 2574 "description": null, 2575 "kind": "simple", 2576 "symbol_name": "Union", 2577 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 2578 }, 2579 "parameters": [ 2580 { 2581 "type_str": "type[FormattableT]", 2582 "description": null, 2583 "kind": "generic", 2584 "base_type": { 2585 "type_str": "type", 2586 "description": null, 2587 "kind": "simple", 2588 "symbol_name": "type", 2589 "doc_url": "https://docs.python.org/3/library/functions.html#type" 2590 }, 2591 "parameters": [ 2592 { 2593 "type_str": "FormattableT", 2594 "description": null, 2595 "kind": "simple", 2596 "symbol_name": "FormattableT", 2597 "doc_url": "/docs/api/llm/formatting#formattable-t" 2598 } 2599 ], 2600 "doc_url": null 2601 }, 2602 { 2603 "type_str": "Format[FormattableT]", 2604 "description": null, 2605 "kind": "generic", 2606 "base_type": { 2607 "type_str": "Format", 2608 "description": null, 2609 "kind": "simple", 2610 "symbol_name": "Format", 2611 "doc_url": "/docs/api/llm/formatting#format" 2612 }, 2613 "parameters": [ 2614 { 2615 "type_str": "FormattableT", 2616 "description": null, 2617 "kind": "simple", 2618 "symbol_name": "FormattableT", 2619 "doc_url": "/docs/api/llm/formatting#formattable-t" 2620 } 2621 ], 2622 "doc_url": null 2623 }, 2624 { 2625 "type_str": "OutputParser[FormattableT]", 2626 "description": null, 2627 "kind": "generic", 2628 "base_type": { 2629 "type_str": "OutputParser", 2630 "description": null, 2631 "kind": "simple", 2632 "symbol_name": "OutputParser", 2633 "doc_url": "/docs/api/llm/formatting#output-parser" 2634 }, 2635 "parameters": [ 2636 { 2637 "type_str": "FormattableT", 2638 "description": null, 2639 "kind": "simple", 2640 "symbol_name": "FormattableT", 2641 "doc_url": "/docs/api/llm/formatting#formattable-t" 2642 } 2643 ], 2644 "doc_url": null 2645 }, 2646 { 2647 "type_str": "None", 2648 "description": null, 2649 "kind": "simple", 2650 "symbol_name": "None", 2651 "doc_url": "https://docs.python.org/3/library/constants.html#None" 2652 } 2653 ], 2654 "doc_url": null 2655 }, 2656 "default": "None", 2657 "description": "Optional response format class (\`BaseModel\`) or Format instance" 2658 } 2659]} 2660/> 2661 2662<ReturnTable 2663 returnType={{ 2664 "type_info": { 2665 "type_str": "AsyncContextPrompt[P, DepsT, FormattableT] | ContextPrompt[P, DepsT, FormattableT] | AsyncPrompt[P, FormattableT] | Prompt[P, FormattableT] | PromptDecorator[ToolT, FormattableT]", 2666 "description": null, 2667 "kind": "union", 2668 "base_type": { 2669 "type_str": "Union", 2670 "description": null, 2671 "kind": "simple", 2672 "symbol_name": "Union", 2673 "doc_url": "https://docs.python.org/3/library/typing.html#typing.Union" 2674 }, 2675 "parameters": [ 2676 { 2677 "type_str": "AsyncContextPrompt[P, DepsT, FormattableT]", 2678 "description": null, 2679 "kind": "generic", 2680 "base_type": { 2681 "type_str": "AsyncContextPrompt", 2682 "description": null, 2683 "kind": "simple", 2684 "symbol_name": "AsyncContextPrompt", 2685 "doc_url": "/docs/api/llm/prompts#async-context-prompt" 2686 }, 2687 "parameters": [ 2688 { 2689 "type_str": "P", 2690 "description": null, 2691 "kind": "simple", 2692 "symbol_name": "P", 2693 "doc_url": "/docs/api/llm/types#p" 2694 }, 2695 { 2696 "type_str": "DepsT", 2697 "description": null, 2698 "kind": "simple", 2699 "symbol_name": "DepsT", 2700 "doc_url": null 2701 }, 2702 { 2703 "type_str": "FormattableT", 2704 "description": null, 2705 "kind": "simple", 2706 "symbol_name": "FormattableT", 2707 "doc_url": "/docs/api/llm/formatting#formattable-t" 2708 } 2709 ], 2710 "doc_url": null 2711 }, 2712 { 2713 "type_str": "ContextPrompt[P, DepsT, FormattableT]", 2714 "description": null, 2715 "kind": "generic", 2716 "base_type": { 2717 "type_str": "ContextPrompt", 2718 "description": null, 2719 "kind": "simple", 2720 "symbol_name": "ContextPrompt", 2721 "doc_url": "/docs/api/llm/prompts#context-prompt" 2722 }, 2723 "parameters": [ 2724 { 2725 "type_str": "P", 2726 "description": null, 2727 "kind": "simple", 2728 "symbol_name": "P", 2729 "doc_url": "/docs/api/llm/types#p" 2730 }, 2731 { 2732 "type_str": "DepsT", 2733 "description": null, 2734 "kind": "simple", 2735 "symbol_name": "DepsT", 2736 "doc_url": null 2737 }, 2738 { 2739 "type_str": "FormattableT", 2740 "description": null, 2741 "kind": "simple", 2742 "symbol_name": "FormattableT", 2743 "doc_url": "/docs/api/llm/formatting#formattable-t" 2744 } 2745 ], 2746 "doc_url": null 2747 }, 2748 { 2749 "type_str": "AsyncPrompt[P, FormattableT]", 2750 "description": null, 2751 "kind": "generic", 2752 "base_type": { 2753 "type_str": "AsyncPrompt", 2754 "description": null, 2755 "kind": "simple", 2756 "symbol_name": "AsyncPrompt", 2757 "doc_url": "/docs/api/llm/prompts#async-prompt" 2758 }, 2759 "parameters": [ 2760 { 2761
2761 "type_str": "P", 2762 "description": null, 2763 "kind": "simple", 2764 "symbol_name": "P", 2765 "doc_url": "/docs/api/llm/types#p" 2766 }, 2767 { 2768 "type_str": "FormattableT", 2769 "description": null, 2770 "kind": "simple", 2771 "symbol_name": "FormattableT", 2772 "doc_url": "/docs/api/llm/formatting#formattable-t" 2773 } 2774 ], 2775 "doc_url": null 2776 }, 2777 { 2778 "type_str": "Prompt[P, FormattableT]", 2779 "description": null, 2780 "kind": "generic", 2781 "base_type": { 2782 "type_str": "Prompt", 2783 "description": null, 2784 "kind": "simple", 2785 "symbol_name": "Prompt", 2786 "doc_url": "/docs/api/llm/prompts#prompt" 2787 }, 2788 "parameters": [ 2789 { 2790 "type_str": "P", 2791 "description": null, 2792 "kind": "simple", 2793 "symbol_name": "P", 2794 "doc_url": "/docs/api/llm/types#p" 2795 }, 2796 { 2797 "type_str": "FormattableT", 2798 "description": null, 2799 "kind": "simple", 2800 "symbol_name": "FormattableT", 2801 "doc_url": "/docs/api/llm/formatting#formattable-t" 2802 } 2803 ], 2804 "doc_url": null 2805 }, 2806 { 2807 "type_str": "PromptDecorator[ToolT, FormattableT]", 2808 "description": null, 2809 "kind": "generic", 2810 "base_type": { 2811 "type_str": "PromptDecorator", 2812 "description": null, 2813 "kind": "simple", 2814 "symbol_name": "PromptDecorator", 2815 "doc_url": "/docs/api/llm/prompts#prompt-decorator" 2816 }, 2817 "parameters": [ 2818 { 2819 "type_str": "ToolT", 2820 "description": null, 2821 "kind": "simple", 2822 "symbol_name": "ToolT", 2823 "doc_url": "/docs/api/llm/tools#tool-t" 2824 }, 2825 { 2826 "type_str": "FormattableT", 2827 "description": null, 2828 "kind": "simple", 2829 "symbol_name": "FormattableT", 2830 "doc_url": "/docs/api/llm/formatting#formattable-t" 2831 } 2832 ], 2833 "doc_url": null 2834 } 2835 ], 2836 "doc_url": null 2837 }, 2838 "description": "A \`Prompt\` variant (Prompt, AsyncPrompt, ContextPrompt, or AsyncContextPrompt)" 2839}} 2840/> 2841 2842 2843`};export{n as default};
Line numbers count LF bytes from the start of the resource, as the search results do. Vendor segments are library code the classifier recognised; they are stored but not indexed. Bytes are shown as Latin1 characters, one per byte.