Skip to content

Commit 6f07c06

Browse files
authored
refactor(inline): re-structure error checking (#986)
Co-authored-by: Oli Morris <olimorris@users.noreply.github.com>
1 parent 34a6d25 commit 6f07c06

File tree

1 file changed

+9
-5
lines changed
  • lua/codecompanion/strategies/inline

1 file changed

+9
-5
lines changed

lua/codecompanion/strategies/inline/init.lua

Lines changed: 9 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -434,18 +434,22 @@ function Inline:done(output)
434434
log:error("[%s] %s", adapter_name, xml.error)
435435
return self:reset()
436436
end
437-
if xml and not xml.code and string.lower(xml.placement) ~= "chat" then
438-
log:error("[%s] Returned no code", adapter_name)
439-
return self:reset()
440-
end
441437

438+
-- There should always be a placement whether that's from the LLM or the user's prompt
442439
local placement = xml and string.lower(xml.placement) or string.lower(self.classification.placement)
443-
log:debug("[Inline] Placement: %s", placement)
444440
if not placement then
445441
log:error("[%s] No placement returned", adapter_name)
446442
return self:reset()
447443
end
448444

445+
log:debug("[Inline] Placement: %s", placement)
446+
447+
-- An LLM won't send code if it deems the placement should go to a chat buffer
448+
if xml and not xml.code and placement ~= "chat" then
449+
log:error("[%s] Returned no code", adapter_name)
450+
return self:reset()
451+
end
452+
449453
if placement == "chat" then
450454
self:reset()
451455
return self:to_chat()

0 commit comments

Comments
 (0)