LLMPromptGenerator
✖
LLMPromptGenerator
Details

- LLMPromptGenerator is used to add message-dependent context to an LLM prompt.
- Possible values for inputspec are:
-
"Input" the last user input (default) "Messages" the list of messages "LLMEvaluator" the current LLMConfiguration[…] "ChatObject" the whole conversation as ChatObject[…] {spec1,…} an association of inputs - The result of f has to be valid prompt. Possible values include:
-
"text" static text LLMPrompt["name"] a repository prompt StringTemplate[…] templated text TemplateObject[…] template for creating a prompt Image[…] an image SemanticSearchIndex[…] a semantic search index {prompt1,…} a list of prompts - Template objects are automatically converted to strings via TemplateObject[…][].
- A prompt created with TemplateObject can contain text and images.
- Not every LLM supports image input.
- If the result of f is not a string, a list of strings or an image, it will be converted using TextString.
Examples
open allclose allBasic Examples (1)Summary of the most common use cases
Define a prompt generator that always prepends the current evaluation date and time:

https://wolfram.com/xid/0mfghvsxgg095irqgu-ue9sgi


https://wolfram.com/xid/0mfghvsxgg095irqgu-5kk6bh

Use the generator in an interaction with an LLM:

https://wolfram.com/xid/0mfghvsxgg095irqgu-6myitv

Scope (5)Survey of the scope of standard use cases
Function (3)

https://wolfram.com/xid/0mfghvsxgg095irqgu-417jjn

Use a function to define the tone of the answer at evaluation time based on the input:

https://wolfram.com/xid/0mfghvsxgg095irqgu-rsdgr8


https://wolfram.com/xid/0mfghvsxgg095irqgu-cdy2ww

Define a generator on a SemanticSearchIndex:

https://wolfram.com/xid/0mfghvsxgg095irqgu-kke12b

Use it to add content semantically relevant to the query:

https://wolfram.com/xid/0mfghvsxgg095irqgu-ce4wkd

Compare with the uninformed LLM answer:

https://wolfram.com/xid/0mfghvsxgg095irqgu-1ycnc

Possible Issues (1)Common pitfalls and unexpected behavior
A list of prompts does not evaluate when applied to the input:

https://wolfram.com/xid/0mfghvsxgg095irqgu-190hv8

Wrap the list using TemplateObject or Function:

https://wolfram.com/xid/0mfghvsxgg095irqgu-eo7x5q

Wolfram Research (2024), LLMPromptGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMPromptGenerator.html.
Text
Wolfram Research (2024), LLMPromptGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMPromptGenerator.html.
Wolfram Research (2024), LLMPromptGenerator, Wolfram Language function, https://reference.wolfram.com/language/ref/LLMPromptGenerator.html.
CMS
Wolfram Language. 2024. "LLMPromptGenerator." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LLMPromptGenerator.html.
Wolfram Language. 2024. "LLMPromptGenerator." Wolfram Language & System Documentation Center. Wolfram Research. https://reference.wolfram.com/language/ref/LLMPromptGenerator.html.
APA
Wolfram Language. (2024). LLMPromptGenerator. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LLMPromptGenerator.html
Wolfram Language. (2024). LLMPromptGenerator. Wolfram Language & System Documentation Center. Retrieved from https://reference.wolfram.com/language/ref/LLMPromptGenerator.html
BibTeX
@misc{reference.wolfram_2025_llmpromptgenerator, author="Wolfram Research", title="{LLMPromptGenerator}", year="2024", howpublished="\url{https://reference.wolfram.com/language/ref/LLMPromptGenerator.html}", note=[Accessed: 05-May-2025
]}
BibLaTeX
@online{reference.wolfram_2025_llmpromptgenerator, organization={Wolfram Research}, title={LLMPromptGenerator}, year={2024}, url={https://reference.wolfram.com/language/ref/LLMPromptGenerator.html}, note=[Accessed: 05-May-2025
]}