Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

do not call llm on empty prompt #614

Merged
merged 1 commit into from
Aug 12, 2024
Merged

do not call llm on empty prompt #614

merged 1 commit into from
Aug 12, 2024

Conversation

pelikhan
Copy link
Member

@pelikhan pelikhan commented Aug 12, 2024

  • The updated code introduces an additional condition in a logical check within the 'expandTemplate' function, in the 'expander.ts' file of the core package. This piece of code handles responses to prompts.
  • Previously, the code only checked if 'prompt.status' was not equal to "success".
  • Now, it also checks whether 'prompt.text' is an empty string or not. The check will pass if either 'prompt.status' is not "success" or 'prompt.text' is an empty string.
  • This means the function will now return early not only when the prompt status is unsuccessful, but also when the prompt text is empty 🧐.
  • This change could be handling a case where the status is successful but no prompt text is provided, avoiding subsequent operations on an empty text 👍.

generated by pr-describe

Copy link

The change in the pull request adds an additional check to the if condition. Previously, it was checking if prompt.status is not equal to "success". Now, it also checks if prompt.text is equal to an empty string.

This change seems to add an additional layer of validation, ensuring that not only the status should be success but also the prompt.text should not be empty.

However, please be aware that this could potentially break any functionality that depends on this function and expects it to return a status of success even when prompt.text is an empty string.

If you are confident that this won't break any dependent functionality or you have handled those cases, then this change looks good to me.

So, "LGTM 🚀" provided the potential impact on dependent functionality has been considered and appropriately handled.

generated by pr-review

@@ -220,7 +220,7 @@ export async function expandTemplate(
if (prompt.aici) trace.fence(prompt.aici, "yaml")
trace.endDetails()

if (prompt.status !== "success")
if (prompt.status !== "success" || prompt.text === "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The check for an empty string in the condition prompt.text === "" might not be necessary if prompt.status is not "success". If the status is not "success", it implies that the operation failed or was cancelled, so the text might not be relevant in this context. 🤔

generated by pr-review-commit empty_string_check

@@ -220,7 +220,7 @@ export async function expandTemplate(
if (prompt.aici) trace.fence(prompt.aici, "yaml")
trace.endDetails()

if (prompt.status !== "success")
if (prompt.status !== "success" || prompt.text === "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The logic of the condition has been changed with the addition of prompt.text === "". This might lead to different behavior of the code if prompt.text is an empty string. If this change was intentional, it would be good to add a comment explaining why this change was made. 😊

generated by pr-review-commit logic_change

@@ -220,7 +220,7 @@ export async function expandTemplate(
if (prompt.aici) trace.fence(prompt.aici, "yaml")
trace.endDetails()

if (prompt.status !== "success")
if (prompt.status !== "success" || prompt.text === "")

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The condition prompt.text === "" has been added without any comment or explanation. It would be helpful to add a comment explaining why this condition is necessary, to make the code easier to understand for other developers. 📝

generated by pr-review-commit missing_comment

@pelikhan pelikhan merged commit 4e8484c into main Aug 12, 2024
10 checks passed
@pelikhan pelikhan deleted the emptyprompt branch August 12, 2024 16:50
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant