-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathgpt-settings.el
109 lines (87 loc) · 4.67 KB
/
gpt-settings.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
(setq python-shell-prompt-regexp "python\\|chatbot3?\\>")
(defun start-chatbot (arguments)
"Starts a chatbot session with the given arguments."
;; (message (concat "Run python as: " (format "chatbot %s" arguments)))
(run-python
(format "python -m chatbot %s" arguments) t t))
(defun replace-tics-in-string (string)
"Replaces tics in a string with double tics."
(replace-regexp-in-string "\"" "\\\\\"" string)
)
(defun get-formatted-buffer-region ()
"Returns the current buffer region formatted as a string."
(let ((start (region-beginning))
(end (region-end)))
(replace-tics-in-string (buffer-substring-no-properties start end))))
(defun chatbot-create-docstring ()
"Starts a chatbot session with the current buffer as the context to create a docstring from"
(interactive)
(let ((docstring (get-formatted-buffer-region)))
(start-chatbot (concat "--model gpt-3.5-turbo --message \"Create documentation for :\n```\n" docstring "\n```\n\""))))
(defun start-assistant ()
"Starts a chatbot session with the current region as the context and ask what to do with it"
(interactive)
(start-chatbot (concat "--mode assistant")))
(defun start-grant-writer ()
"Starts a chatbot session with the current region as the context and ask what to do with it"
(interactive)
(start-chatbot (concat "--mode grant_writer")))
(defun ask-assistant-on-region (message)
"Starts a chatbot session with the current region as the context and ask what to do with it"
(interactive "sEnter your message: ")
(let ((reg (get-formatted-buffer-region)))
(start-chatbot (concat "--mode assistant --message \""
(concat (replace-tics-in-string message) "\n" reg) "\""))))
(defun ask-assistant (message)
"Starts a chatbot session with the current region as the context and ask what to do with it"
(interactive "sEnter your message: ")
(start-chatbot (concat "--mode assistant --message \""
(concat (replace-tics-in-string message)) "\"")))
(defun ask-coder (message)
"Starts a coder bot session and ask what to do with it"
(interactive "sEnter your message: ")
(start-chatbot (concat "--model gpt-3.5-turbo --message \""
(concat (replace-tics-in-string message)) "\"")))
(defun ask-coder-on-region (message)
"Starts a coder bot session and ask what to do with it with the current region as the context"
(interactive "sEnter your message: ")
(let ((reg (get-formatted-buffer-region)))
(start-chatbot (concat "--model gpt-3.5-turbo --message \""
(concat (replace-tics-in-string message) "\n" reg) "\""))))
(defun ask-coder-4 (message)
"Starts a coder bot session and ask what to do with it"
(interactive "sEnter your message: ")
(start-chatbot (concat "--message \""
(concat (replace-tics-in-string message)) "\"")))
(defun ask-coder-4-on-region (message)
"Starts a coder bot session and ask what to do with it with the current region as the context"
(interactive "sEnter your message: ")
(let ((reg (get-formatted-buffer-region)))
(start-chatbot (concat "--message \""
(concat (replace-tics-in-string message) "\n" reg) "\""))))
(global-set-key (kbd "C-c C-o a") 'ask-coder)
(global-set-key (kbd "C-c C-o r") 'ask-coder-on-region)
(defun ask-simpl-chatbot (message)
"Starts a simpl chatbot session with as message"
(interactive "sEnter your message: ")
(start-chatbot (concat "--mode assistant --memory --memory_file simpl --message \""
(concat (replace-tics-in-string message)) "\"")))
(defun ask-simpl-chatbot-region (message)
"Starts a simpl chatbot session with as message"
(interactive "sEnter your message: ")
(let ((reg (get-formatted-buffer-region)))
(start-chatbot (concat "--mode assistant --memory --memory_file simpl --message \""
(concat (replace-tics-in-string message) "\n" reg) "\""))))
(defun train-simpl-chatbot (message)
"Starts a simpl chatbot session with as message"
(interactive "sEnter your message: ")
(start-chatbot (concat "--mode assistant --memory --train --memory_file simpl --message \""
(concat (replace-tics-in-string message)) "\"")))
(defun train-simpl-chatbot-region (message)
"Starts a simpl chatbot session with as message"
(interactive "sEnter your message: ")
(let ((reg (get-formatted-buffer-region)))
(start-chatbot (concat "--mode assistant --memory --train --memory_file simpl --message \""
(concat (replace-tics-in-string message) "\n" reg) "\""))))
(setenv "GPT_KNOWLEDGE_BASE" "/home/christopher/git/source/gpt-knowledge-base")
(provide 'gpt-settings)