Skip to content

Commit 56740e0

Browse files
tetoRobitx
authored andcommitted
feat: expose default_(chat|code)_system_prompt to user
When adding your own agents, you have to provide default prompts. Let's expose gp.nvim's default ones t avoid the user troubling him/herself with the issue.
1 parent 360ee31 commit 56740e0

File tree

2 files changed

+30
-28
lines changed

2 files changed

+30
-28
lines changed

lua/gp/config.lua

Lines changed: 14 additions & 28 deletions
Original file line numberDiff line numberDiff line change
@@ -5,20 +5,6 @@
55
-- Default config
66
--------------------------------------------------------------------------------
77

8-
local default_chat_system_prompt = "You are a general AI assistant.\n\n"
9-
.. "The user provided the additional info about how they would like you to respond:\n\n"
10-
.. "- If you're unsure don't guess and say you don't know instead.\n"
11-
.. "- Ask question if you need clarification to provide better answer.\n"
12-
.. "- Think deeply and carefully from first principles step by step.\n"
13-
.. "- Zoom out first to see the big picture and then zoom in to details.\n"
14-
.. "- Use Socratic method to improve your thinking and coding skills.\n"
15-
.. "- Don't elide any code from your output if the answer requires coding.\n"
16-
.. "- Take a deep breath; You've got this!\n"
17-
18-
local default_code_system_prompt = "You are an AI working as a code editor.\n\n"
19-
.. "Please AVOID COMMENTARY OUTSIDE OF THE SNIPPET RESPONSE.\n"
20-
.. "START AND END YOUR ANSWER WITH:\n\n```"
21-
228
local config = {
239
-- Please start with minimal config possible.
2410
-- Just openai_api_key if you don't have OPENAI_API_KEY env set up.
@@ -110,7 +96,7 @@ local config = {
11096
-- string with model name or table with model name and parameters
11197
model = { model = "gpt-4o", temperature = 1.1, top_p = 1 },
11298
-- system prompt (use this to specify the persona/role of the AI)
113-
system_prompt = default_chat_system_prompt,
99+
system_prompt = require'gp.defaults'.chat_system_prompt,
114100
},
115101
{
116102
provider = "openai",
@@ -120,7 +106,7 @@ local config = {
120106
-- string with model name or table with model name and parameters
121107
model = { model = "gpt-3.5-turbo", temperature = 1.1, top_p = 1 },
122108
-- system prompt (use this to specify the persona/role of the AI)
123-
system_prompt = default_chat_system_prompt,
109+
system_prompt = require'gp.defaults'.chat_system_prompt,
124110
},
125111
{
126112
provider = "copilot",
@@ -130,7 +116,7 @@ local config = {
130116
-- string with model name or table with model name and parameters
131117
model = { model = "gpt-4", temperature = 1.1, top_p = 1 },
132118
-- system prompt (use this to specify the persona/role of the AI)
133-
system_prompt = default_chat_system_prompt,
119+
system_prompt = require'gp.defaults'.chat_system_prompt,
134120
},
135121
{
136122
provider = "googleai",
@@ -140,7 +126,7 @@ local config = {
140126
-- string with model name or table with model name and parameters
141127
model = { model = "gemini-pro", temperature = 1.1, top_p = 1 },
142128
-- system prompt (use this to specify the persona/role of the AI)
143-
system_prompt = default_chat_system_prompt,
129+
system_prompt = require'gp.defaults'.chat_system_prompt,
144130
},
145131
{
146132
provider = "pplx",
@@ -150,7 +136,7 @@ local config = {
150136
-- string with model name or table with model name and parameters
151137
model = { model = "mixtral-8x7b-instruct", temperature = 1.1, top_p = 1 },
152138
-- system prompt (use this to specify the persona/role of the AI)
153-
system_prompt = default_chat_system_prompt,
139+
system_prompt = require'gp.defaults'.chat_system_prompt,
154140
},
155141
{
156142
provider = "anthropic",
@@ -160,7 +146,7 @@ local config = {
160146
-- string with model name or table with model name and parameters
161147
model = { model = "claude-3-5-sonnet-20240620", temperature = 0.8, top_p = 1 },
162148
-- system prompt (use this to specify the persona/role of the AI)
163-
system_prompt = default_chat_system_prompt,
149+
system_prompt = require'gp.defaults'.chat_system_prompt,
164150
},
165151
{
166152
provider = "anthropic",
@@ -170,7 +156,7 @@ local config = {
170156
-- string with model name or table with model name and parameters
171157
model = { model = "claude-3-haiku-20240307", temperature = 0.8, top_p = 1 },
172158
-- system prompt (use this to specify the persona/role of the AI)
173-
system_prompt = default_chat_system_prompt,
159+
system_prompt = require'gp.defaults'.chat_system_prompt,
174160
},
175161
{
176162
provider = "ollama",
@@ -208,7 +194,7 @@ local config = {
208194
-- string with model name or table with model name and parameters
209195
model = { model = "gpt-4o", temperature = 0.8, top_p = 1 },
210196
-- system prompt (use this to specify the persona/role of the AI)
211-
system_prompt = default_code_system_prompt,
197+
system_prompt = require'gp.defaults'.code_system_prompt,
212198
},
213199
{
214200
provider = "openai",
@@ -218,7 +204,7 @@ local config = {
218204
-- string with model name or table with model name and parameters
219205
model = { model = "gpt-3.5-turbo", temperature = 0.8, top_p = 1 },
220206
-- system prompt (use this to specify the persona/role of the AI)
221-
system_prompt = default_code_system_prompt,
207+
system_prompt = require'gp.defaults'.code_system_prompt,
222208
},
223209
{
224210
provider = "copilot",
@@ -228,7 +214,7 @@ local config = {
228214
-- string with the Copilot engine name or table with engine name and parameters if applicable
229215
model = { model = "gpt-4", temperature = 0.8, top_p = 1, n = 1 },
230216
-- system prompt (use this to specify the persona/role of the AI)
231-
system_prompt = default_code_system_prompt,
217+
system_prompt = require'gp.defaults'.code_system_prompt,
232218
},
233219
{
234220
provider = "googleai",
@@ -237,7 +223,7 @@ local config = {
237223
command = true,
238224
-- string with model name or table with model name and parameters
239225
model = { model = "gemini-pro", temperature = 0.8, top_p = 1 },
240-
system_prompt = default_code_system_prompt,
226+
system_prompt = require'gp.defaults'.code_system_prompt,
241227
},
242228
{
243229
provider = "pplx",
@@ -246,7 +232,7 @@ local config = {
246232
command = true,
247233
-- string with model name or table with model name and parameters
248234
model = { model = "mixtral-8x7b-instruct", temperature = 0.8, top_p = 1 },
249-
system_prompt = default_code_system_prompt,
235+
system_prompt = require'gp.defaults'.code_system_prompt,
250236
},
251237
{
252238
provider = "anthropic",
@@ -255,7 +241,7 @@ local config = {
255241
command = true,
256242
-- string with model name or table with model name and parameters
257243
model = { model = "claude-3-5-sonnet-20240620", temperature = 0.8, top_p = 1 },
258-
system_prompt = default_code_system_prompt,
244+
system_prompt = require'gp.defaults'.code_system_prompt,
259245
},
260246
{
261247
provider = "anthropic",
@@ -264,7 +250,7 @@ local config = {
264250
command = true,
265251
-- string with model name or table with model name and parameters
266252
model = { model = "claude-3-haiku-20240307", temperature = 0.8, top_p = 1 },
267-
system_prompt = default_code_system_prompt,
253+
system_prompt = require'gp.defaults'.code_system_prompt,
268254
},
269255
{
270256
provider = "ollama",

lua/gp/defaults.lua

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,16 @@
1+
local M = {}
2+
M.chat_system_prompt = "You are a general AI assistant.\n\n"
3+
.. "The user provided the additional info about how they would like you to respond:\n\n"
4+
.. "- If you're unsure don't guess and say you don't know instead.\n"
5+
.. "- Ask question if you need clarification to provide better answer.\n"
6+
.. "- Think deeply and carefully from first principles step by step.\n"
7+
.. "- Zoom out first to see the big picture and then zoom in to details.\n"
8+
.. "- Use Socratic method to improve your thinking and coding skills.\n"
9+
.. "- Don't elide any code from your output if the answer requires coding.\n"
10+
.. "- Take a deep breath; You've got this!\n"
11+
12+
M.code_system_prompt = "You are an AI working as a code editor.\n\n"
13+
.. "Please AVOID COMMENTARY OUTSIDE OF THE SNIPPET RESPONSE.\n"
14+
.. "START AND END YOUR ANSWER WITH:\n\n```"
15+
16+
return M

0 commit comments

Comments
 (0)