feat(suggestions): add tags around json (#1441)
This commit is contained in:
@@ -110,6 +110,7 @@ L5: pass
|
|||||||
{
|
{
|
||||||
role = "assistant",
|
role = "assistant",
|
||||||
content = [[
|
content = [[
|
||||||
|
<suggestions>
|
||||||
[
|
[
|
||||||
[
|
[
|
||||||
{
|
{
|
||||||
@@ -136,6 +137,7 @@ L5: pass
|
|||||||
},
|
},
|
||||||
]
|
]
|
||||||
]
|
]
|
||||||
|
</suggestions>
|
||||||
]],
|
]],
|
||||||
},
|
},
|
||||||
}
|
}
|
||||||
@@ -165,6 +167,7 @@ L5: pass
|
|||||||
if cursor_row ~= doc.position.row or cursor_col ~= doc.position.col then return end
|
if cursor_row ~= doc.position.row or cursor_col ~= doc.position.col then return end
|
||||||
-- Clean up markdown code blocks
|
-- Clean up markdown code blocks
|
||||||
full_response = Utils.trim_think_content(full_response)
|
full_response = Utils.trim_think_content(full_response)
|
||||||
|
full_response = full_response:gsub("<suggestions>\n(.-)\n</suggestions>", "%1")
|
||||||
full_response = full_response:gsub("^```%w*\n(.-)\n```$", "%1")
|
full_response = full_response:gsub("^```%w*\n(.-)\n```$", "%1")
|
||||||
full_response = full_response:gsub("(.-)\n```\n?$", "%1")
|
full_response = full_response:gsub("(.-)\n```\n?$", "%1")
|
||||||
-- Remove everything before the first '[' to ensure we get just the JSON array
|
-- Remove everything before the first '[' to ensure we get just the JSON array
|
||||||
|
|||||||
@@ -36,6 +36,37 @@ Your task is to suggest code modifications at the cursor position. Follow these
|
|||||||
start_row: The starting row of the code snippet you want to replace, start from 1, inclusive
|
start_row: The starting row of the code snippet you want to replace, start from 1, inclusive
|
||||||
end_row: The ending row of the code snippet you want to replace, start from 1, inclusive
|
end_row: The ending row of the code snippet you want to replace, start from 1, inclusive
|
||||||
content: The suggested code you want to replace the original code with
|
content: The suggested code you want to replace the original code with
|
||||||
|
3. JSON must be wrapped with <suggestions></suggestions> tags, for example:
|
||||||
|
{% raw %}
|
||||||
|
<suggestions>
|
||||||
|
[
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"start_row": 1,
|
||||||
|
"end_row": 1,
|
||||||
|
"content": "Your suggested code here"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start_row": 3,
|
||||||
|
"end_row": 9,
|
||||||
|
"content": "Your suggested code here"
|
||||||
|
}
|
||||||
|
],
|
||||||
|
[
|
||||||
|
{
|
||||||
|
"start_row": 2,
|
||||||
|
"end_row": 6,
|
||||||
|
"content": "Your suggested code here"
|
||||||
|
},
|
||||||
|
{
|
||||||
|
"start_row": 9,
|
||||||
|
"end_row": 22,
|
||||||
|
"content": "Your suggested code here"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
]
|
||||||
|
</suggestions>
|
||||||
|
{% endraw %}
|
||||||
|
|
||||||
Guidelines:
|
Guidelines:
|
||||||
1. Make sure you have maintained the user's existing whitespace and indentation. This is REALLY IMPORTANT!
|
1. Make sure you have maintained the user's existing whitespace and indentation. This is REALLY IMPORTANT!
|
||||||
|
|||||||
Reference in New Issue
Block a user