From a19e715faa747f18cc95b93175a6858a84aed5cb Mon Sep 17 00:00:00 2001 From: Erik Cowley Date: Sat, 18 Nov 2023 14:21:16 -0500 Subject: [PATCH] Fixes to functionality for wrapping localai response --- init.lua | 11 +++++++++++ 1 file changed, 11 insertions(+) diff --git a/init.lua b/init.lua index 693cc93..75cba33 100644 --- a/init.lua +++ b/init.lua @@ -390,9 +390,20 @@ function call_localai(model, prompt, temperature) }, } local function on_complete(stdout) + -- decode response local out_json = vim.json.decode(stdout) + -- get content of response + -- TODO make this more dynamic local response_str = out_json["choices"][1]["message"]["content"] + -- display content of response display_string_in_buf(response_str) + -- apply formatting + local line = vim.fn.line("$") + while line > 0 do + vim.cmd(tostring(line)) + vim.cmd.normal("gqq") + line = line - 1 + end end local function on_error(stderr) print("Error: " .. stderr)