-
-
Notifications
You must be signed in to change notification settings - Fork 0
/
insert-code.el
62 lines (59 loc) · 1.94 KB
/
insert-code.el
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
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
;; https://beta.openai.com/docs/guides/code/inserting-code
(let ((input
"(m/shift [[1 0] [1 0] [0 0]] 1 (- 1))\n[[0 1] [0 1] [0 0]]\n(m/shift [[0 1] [0 1] [0 0]]\n \n \n")
(suffix
")\n[[0 0]\n [0 1]\n [0 1]]"))
(cl-loop for i below 5 append
(with-current-buffer
(openai-api-retrieve-sync
`((model . "text-davinci-003")
(prompt . ,input)
(suffix . ,suffix)
(max_tokens . 500)
(temperature . ,(* i 0.1))
;; (top_p . 1)
;; (presence_penalty . 0)
;; (stop . ["\n"])
))
(openai-api-choices-text-1
(cl-remove-if-not
(lambda (d)
(equal "stop"
(assoc-default
'finish_reason
d)))
(openai-api-choices))))))
;; lol
'("1
(- 1)"
"1
(- 1)"
" 1
(- 1)"
"1 (- 1)"
" 1
(- 1)")
(let ((input
"(m/shift [[1 0] [1 0] [0 0]] 1 (- 1))\n[[0 1] [0 1] [0 0]]\n(m/shift [[0 1] [0 1] [0 0]]\n \n \n")
(suffix
")\n[[0 0]\n [0 1]\n [0 1]]"))
(cl-loop for i below 5 append
(with-current-buffer
(openai-api-retrieve-sync
`((model . "text-davinci-003")
(prompt . ,input)
(suffix . ,suffix)
(max_tokens . 500)
(temperature . ,(* i 0.1))
;; (top_p . 1)
;; (presence_penalty . 0)
;; (stop . ["\n"])
))
(openai-api-choices-text-1
(cl-remove-if-not
(lambda (d)
(equal "stop"
(assoc-default
'finish_reason
d)))
(openai-api-choices))))))