-
Notifications
You must be signed in to change notification settings - Fork 0
/
gptel-custom.el
132 lines (123 loc) · 5.18 KB
/
gptel-custom.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
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
(setq long-prompt "You are an AI assistant named ChatGPT. Please respond concisely and helpfully.")
(setq short-prompt "Please answer the query **as briefly as possible**, without any comments. Your answer will be directly used as a piece of code, or a command. It should work without any postprocessing.")
(setq continue-prompt "Please complete the code in the file you're presented in the context. Don't return any code you've already seen, only the continuation. Your answer will be directly used as a piece of code, don't add any comments, any markdown formatting, just the code itself.")
(defun gptel-send-to-gpt4--general ()
(interactive)
(let ((gptel-backend (gptel-make-openai
"Custom ChatGPT"
:models '("gpt-4-turbo-preview")
:key 'gptel-api-key
:stream t))
(gptel-model "gpt-4-turbo-preview")
(gptel--system-message long-prompt))
(gptel-send)
(message "Full buffer or region sent to gpt4")))
(defun gptel-send-to-claude-opus--general ()
(interactive)
(let ((gptel-backend (gptel-make-anthropic
"Custom Claude Opus"
:models '("claude-3-opus-20240229")
:key 'gptel-anthropic-api-key
:stream t))
(gptel-model "claude-3-opus-20240229")
(gptel--system-message long-prompt))
(gptel-send)
(message "Full buffer or region sent to opus")))
(defun gptel-send-to-claude-haiku--general ()
(interactive)
(let ((gptel-backend (gptel-make-anthropic
"Custom Claude Haiku"
:models '("claude-3-haiku-20240307")
:key 'gptel-anthropic-api-key
:stream t))
(gptel-model "claude-3-haiku-20240307")
(gptel--system-message long-prompt))
(gptel-send)
(message "Full buffer or region sent to haiku")))
(defun gptel-send-to-gpt4--continue ()
(interactive)
(let ((gptel-backend (gptel-make-openai
"Custom ChatGPT"
:models '("gpt-4-turbo-preview")
:key 'gptel-api-key
:stream t))
(gptel-model "gpt-4-turbo-preview")
(gptel--system-message continue-prompt))
(gptel-send)
(message "Continue code with gpt4...")))
(defun gptel-send-to-opus--continue ()
(interactive)
(let ((gptel-backend (gptel-make-anthropic
"Custom Claude Opus"
:models '("claude-3-opus-20240229")
:key 'gptel-anthropic-api-key
:stream t))
(gptel-model "claude-3-opus-20240229")
(gptel--system-message continue-prompt))
(gptel-send)
(message "Continue code with opus...")))
(defun gptel-send-to-haiku--continue ()
(interactive)
(let ((gptel-backend (gptel-make-anthropic
"Custom Claude Haiku"
:models '("claude-3-haiku-20240307")
:key 'gptel-anthropic-api-key
:stream t))
(gptel-model "claude-3-haiku-20240307")
(gptel--system-message continue-prompt))
(gptel-send)
(message "Continue code with haiku...")))
(defun gptel-send-to-gpt4--short ()
(interactive)
(let ((gptel-backend (gptel-make-openai
"Custom ChatGPT"
:models '("gpt-4-turbo-preview")
:key 'gptel-api-key
:stream t))
(gptel-model "gpt-4-turbo-preview")
(gptel--system-message short-prompt))
(save-excursion
(beginning-of-line)
(set-mark (point))
(end-of-line)
(gptel-send)
(delete-region (line-beginning-position) (progn (forward-line 2) (point)))
)
(deactivate-mark)
(message "Sending current line to gpt4...")))
(defun gptel-send-to-claude-opus--short ()
(interactive)
(let ((gptel-backend (gptel-make-anthropic
"Custom Claude Opus"
:models '("claude-3-opus-20240229")
:key 'gptel-anthropic-api-key
:stream t))
(gptel-model "claude-3-opus-20240229")
(gptel--system-message short-prompt))
(save-excursion
(beginning-of-line)
(set-mark (point))
(end-of-line)
(gptel-send)
(delete-region (line-beginning-position) (progn (forward-line 2) (point)))
)
(deactivate-mark)
(message "Sending current line to opus...")))
(defun gptel-send-to-claude-haiku--short ()
(interactive)
(let ((gptel-backend (gptel-make-anthropic
"Custom Claude Haiku"
:models '("claude-3-haiku-20240307")
:key 'gptel-anthropic-api-key
:stream t))
(gptel-model "claude-3-haiku-20240307")
(gptel--system-message short-prompt))
(save-excursion
(beginning-of-line)
(set-mark (point))
(end-of-line)
(gptel-send)
(delete-region (line-beginning-position) (progn (forward-line 2) (point)))
)
(deactivate-mark)
(message "Sending current line to haiku...")))