Skip to content

Exclude code from Explain Vulnerability prompt when there is too much

mo khan requested to merge mokhax/too-many-tokens into master

What does this MR do and why?

When generating an explanation for a vulnerability we sometimes include the snippet of vulnerable code to the AI API. In some cases this code is too large to fit within the maximum token limits offered by the AI API. In these situations, we would like to generate a prompt without the vulnerable code. This change removes the vulnerable code from the AI API request when it exceeds a specific character limit.

Screenshots or screen recordings

Before:

Screenshot_2023-05-10_at_11.56.25

After:

Screenshot_2023-05-10_at_12.05.16

MR acceptance checklist

This checklist encourages us to confirm any changes have been analyzed to reduce risks in quality, performance, reliability, security, and maintainability.

Edited by mo khan

Merge request reports

Loading