|
Calling Sequence
|
|
GenerateDocument()
:= GenerateDocument(, )
:= GenerateDocument(, history = , )
GenerateDocument[interactive]()
|
|
Parameters
|
|
|
-
|
string, (optional) query to send to a large language model.
|
|
-
|
object, (optional) history object resulting from an earlier call to GenerateDocument
|
|
-
|
(optional) one or more options of the form , , , or .
|
|
|
|
|
Description
|
|
•
|
The GenerateDocument command is a technology preview that generates a document using a large language model (LLM).
|
•
|
The first call to GenerateDocument must have a prompt argument: a string describing what you want the document to be about. By default, this opens a new document and returns an object representing the interactions with the LLM. This 'history object' is a special form of the object returned by NaturalLanguage:-Dialog.
|
|
In later calls, you can include the argument , where is such an object, to continue this conversation with the large language model. In such a case you do not need to include a prompt, though you can if you want to include instructions to refine what the document should be about. Alternatively, if you do not include the option, you start a new dialog with the large language model.
|
•
|
To fine tune how the actual document is created, you can use the option. The result depends on the value of :
|
|
This just returns the history object.
|
|
With these options, Maple will call Worksheet:-FromMarkdown with the same option, passing it the returned string from the large language model. The documentation of that command explains these options. In short, with , a new document is created; with , the content is inserted into the current document; and with , the content is returned in an XML representation. Any return values from Worksheet:-FromMarkdown are ignored (GenerateDocument will return NULL), except with .
|
|
You can also pass in a list as the value of the option, if each entry of the list is one of the names above. In this case, Maple will perform the actions for the corresponding entries in sequence. The corresponding results, if any, are returned as an expression sequence.
|
|
The default value of the output option is ; that is, the history object is returned and the resulting document is opened as a new document.
|
•
|
You can modify the document generated by using the and options. By using the option, where is a string or symbol, you change the tone and focus of the document by instructing the large language model to play the role of an . By default, is "scientist", but for example teacher or engineer can also be useful roles.
|
•
|
The large language model is by default instructed to write five paragraphs of content. You can modify this by using the option, where is a positive integer. This changes the instruction to writing paragraphs, where is replaced by the value of the option. Note that setting higher is more likely to lead to time out errors, as the large language model is given only limited time to generate its response.
|
•
|
The final calling sequence, , displays an interactive application that allows you to interact with the facilities provided by the command. It is described on its own help page.
|
•
|
Maple can interface with OpenAI's GPT-4o, o1-mini, and o3-mini models. You can select these by using the options ; ; and , respectively. By default, or when explicitly selected with the option, a Maplesoft server chooses an appropriate model. (At the time of release of Maple 2025, this was the o3-mini model.) Note that OpenAI may deprecate and disable models, so the set of models supported may change in the future.
|
|
Note: Large language models often generate inaccurate statements. Please keep this in mind: this is not technology for building a bridge with.
|
|
|
Examples
|
|
>
|
|
>
|
|
>
|
|
>
|
|
>
|
|
|
|
References
|
|
|
|
Compatibility
|
|
•
|
The NaturalLanguage:-GenerateDocument command was introduced in Maple 2025.
|
|
|
|