Summary

I add consistency to results for prompting functions by remembering the previous output to that function and prepending it into the next prompting function prompt.

Prompt format addition (prepend-previous)

Example prompt
http://github.com/semiosis/prompts/blob/master/prompts/imagine-evaluating-emacs-lisp-2.prompt

When prepend-previous is switched on, the previous prompt as well as its generated result are prepended before the new prompt to obtain consistency in output.

This is useful for mocking APIs, for example, or any situation where you need consistency in results, such as for formatting.

 1
 2
 3
 4
 5
 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
task: "imagine evaluating emacs lisp"
doc: "Given some elisp return the imagined result"
prompt-version: 1
prompt: |+
  <code-or-comment>
  (message (eval <expression>))
  -->  
engine: "OpenAI Codex"
temperature: 0.2
max-generated-tokens: 200
top-p: 1.0
cache: on
# This prepends the previously selected prompt+generation
# to obtain consistency in output.
# This is useful for mocking APIs.
prepend-previous: on
stop-sequences:
- "\n"
vars:
- "code or comment"
- "expression"
validator: "grep -qv '(:return'"
examples:
- |-
    (defun double-number (x)
      (x * x))    
- "(double-number 5)"
filter: on
completion: off
insertion: off

Example

1
2
(idefun colour-of-thing (thing)
        "Given the name of a thing, provide the hash colour")
1
(colour-of-thing "Sea")

This is a blue. Notice the formatting of the colour.

"\"0x0000FF\""
1
(colour-of-thing "Navy blue")

As you can see, the same format as previous is used.

"\"0x000080\""

Underlying prompt

This is the text supplied to prompt for the hex colour of Navy blue. The previous evaluation and result is used as an example.

 1
 2
 3
 4
 5
 6
 7
 8
 9
10
;; Given the name of a thing, provide the hash colour
;; arguments: (thing)
(message (eval '(colour-of-thing "Sea")))
--> "0x0000FF"


;; Given the name of a thing, provide the hash colour
;; arguments: (thing)
(message (eval '(colour-of-thing "Navy blue")))
-->