Skip to content

Commit

Permalink
fixing for response - openai response and other should be more reliable
Browse files Browse the repository at this point in the history
now
  • Loading branch information
huynle committed Oct 8, 2024
1 parent 6611154 commit fe87e33
Showing 1 changed file with 6 additions and 17 deletions.
23 changes: 6 additions & 17 deletions lua/ogpt/response.lua
Original file line number Diff line number Diff line change
Expand Up @@ -141,29 +141,18 @@ function Response:render()
end

function Response:pop_chunk()
-- -- pop the next chunk and add anything that is not processs
-- local _value = self.not_processed
-- self.not_processed = ""
-- local _chunk = self.processsed_raw_rx.recv()
-- utils.log("Got chunk... now appending to 'not_processed'", vim.log.levels.TRACE)
-- return _value .. _chunk

local _chunk = self.processsed_raw_rx.recv()
utils.log("pushing processed raw to queue: " .. _chunk, vim.log.levels.TRACE)

-- push on to queue
self.not_processed:pushright(_chunk)
utils.log("popping processed raw from queue: " .. _chunk, vim.log.levels.TRACE)
return self.not_processed:popleft()

-- local chunk = _chunk
-- -- clear the queue each time to try to get a full chunk
-- for i, queued_chunk in self.not_processed:ipairs_left() do
-- chunk = chunk .. queued_chunk
-- utils.log("Adding to final processed output: " .. chunk, vim.log.levels.TRACE)
-- self.not_processed[i] = nil
-- end
-- return chunk

local _data = {}
while not self.not_processed:is_empty() do
table.insert(_data, self.not_processed:popleft())
end
return table.concat(_data, "")
end

function Response:get_accumulated_chunks()
Expand Down

0 comments on commit fe87e33

Please sign in to comment.