feat(suggestions): add tags around json (#1441)

This commit is contained in:
yetone
2025-03-01 13:11:12 +08:00
committed by GitHub
parent 86feaf3e38
commit 5bb055795f
2 changed files with 34 additions and 0 deletions

View File

@@ -110,6 +110,7 @@ L5: pass
{
role = "assistant",
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
-- Clean up markdown code blocks
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("(.-)\n```\n?$", "%1")
-- Remove everything before the first '[' to ensure we get just the JSON array