Skip to content

Guard against zero total count

Tan Le requested to merge 323-zero-division-error-model-reflection into main

What does this merge request do and why?

This fixes a ZeroDivisionError error caused by completion that contain multiple lines of empty characters in model reflection post processing.

How to set up and validate locally

I am unable to reproduce this with code-gecko@latest since we do not log user's prompts. The only things I can get a hold of from the log are:

  • json.jsonPayload.prompt_length: 421
  • json.jsonPayload.prompt_length_stripped: 376
  • json.jsonPayload.model_output_length: 9
  • json.jsonPayload.model_output_length_stripped: 0

Combined with the logic in the code, I have speculated an example in the spec that could trigger this error and provide the appropriate fix.

Merge request checklist

  • Tests added for new functionality. If not, please raise an issue to follow up.
  • Documentation added/updated, if needed.

Closes #323 (closed)

Edited by Tan Le

Merge request reports