Skip to content

Commit

Permalink
fix: add prompt instruction to redeclare variables if needed.
Browse files Browse the repository at this point in the history
  • Loading branch information
asafkorem committed Jan 17, 2025
1 parent 84b908b commit bad3732
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 12 deletions.
1 change: 1 addition & 0 deletions src/utils/PromptCreator.ts
Original file line number Diff line number Diff line change
Expand Up @@ -217,6 +217,7 @@ export class PromptCreator {
}
steps.push(
"If you cannot generate the relevant code due to ambiguity or invalid intent, return code that throws an informative error explaining the problem in one sentence.",
"Each step must be completely independent - do not rely on any variables or assignments from previous steps. Even if a variable was declared or assigned in a previous step, you must redeclare and reassign it in your current step.",
"Wrap the generated code with backticks, without any additional formatting.",
"Do not provide any additional code beyond the minimal executable code required to perform the intent."
);
Expand Down
30 changes: 18 additions & 12 deletions src/utils/__snapshots__/PromptCreator.test.ts.snap
Original file line number Diff line number Diff line change
Expand Up @@ -123,8 +123,9 @@ Please follow these steps carefully:
1. Analyze the provided intent and the view hierarchy to understand the required action.
2. Generate the minimal executable code required to perform the intent using the available API.
3. If you cannot generate the relevant code due to ambiguity or invalid intent, return code that throws an informative error explaining the problem in one sentence.
4. Wrap the generated code with backticks, without any additional formatting.
5. Do not provide any additional code beyond the minimal executable code required to perform the intent.
4. Each step must be completely independent - do not rely on any variables or assignments from previous steps. Even if a variable was declared or assigned in a previous step, you must redeclare and reassign it in your current step.
5. Wrap the generated code with backticks, without any additional formatting.
6. Do not provide any additional code beyond the minimal executable code required to perform the intent.
### Verify the prompt
Expand Down Expand Up @@ -251,8 +252,9 @@ Please follow these steps carefully:
1. Analyze the provided intent and the view hierarchy to understand the required action.
2. Generate the minimal executable code required to perform the intent using the available API.
3. If you cannot generate the relevant code due to ambiguity or invalid intent, return code that throws an informative error explaining the problem in one sentence.
4. Wrap the generated code with backticks, without any additional formatting.
5. Do not provide any additional code beyond the minimal executable code required to perform the intent.
4. Each step must be completely independent - do not rely on any variables or assignments from previous steps. Even if a variable was declared or assigned in a previous step, you must redeclare and reassign it in your current step.
5. Wrap the generated code with backticks, without any additional formatting.
6. Do not provide any additional code beyond the minimal executable code required to perform the intent.
### Verify the prompt
Expand Down Expand Up @@ -393,8 +395,9 @@ Please follow these steps carefully:
1. Analyze the provided intent and the view hierarchy to understand the required action.
2. Generate the minimal executable code required to perform the intent using the available API.
3. If you cannot generate the relevant code due to ambiguity or invalid intent, return code that throws an informative error explaining the problem in one sentence.
4. Wrap the generated code with backticks, without any additional formatting.
5. Do not provide any additional code beyond the minimal executable code required to perform the intent.
4. Each step must be completely independent - do not rely on any variables or assignments from previous steps. Even if a variable was declared or assigned in a previous step, you must redeclare and reassign it in your current step.
5. Wrap the generated code with backticks, without any additional formatting.
6. Do not provide any additional code beyond the minimal executable code required to perform the intent.
### Verify the prompt
Expand Down Expand Up @@ -509,8 +512,9 @@ Please follow these steps carefully:
5. If the visual assertion fails, return code that throws an informative error explaining the failure.
6. If visual validation is not possible, proceed to generate the minimal executable code required to perform the intent.
7. If you cannot generate the relevant code due to ambiguity or invalid intent, return code that throws an informative error explaining the problem in one sentence.
8. Wrap the generated code with backticks, without any additional formatting.
9. Do not provide any additional code beyond the minimal executable code required to perform the intent.
8. Each step must be completely independent - do not rely on any variables or assignments from previous steps. Even if a variable was declared or assigned in a previous step, you must redeclare and reassign it in your current step.
9. Wrap the generated code with backticks, without any additional formatting.
10. Do not provide any additional code beyond the minimal executable code required to perform the intent.
### Verify the prompt
Expand Down Expand Up @@ -626,8 +630,9 @@ Please follow these steps carefully:
1. Analyze the provided intent and the view hierarchy to understand the required action.
2. Generate the minimal executable code required to perform the intent using the available API.
3. If you cannot generate the relevant code due to ambiguity or invalid intent, return code that throws an informative error explaining the problem in one sentence.
4. Wrap the generated code with backticks, without any additional formatting.
5. Do not provide any additional code beyond the minimal executable code required to perform the intent.
4. Each step must be completely independent - do not rely on any variables or assignments from previous steps. Even if a variable was declared or assigned in a previous step, you must redeclare and reassign it in your current step.
5. Wrap the generated code with backticks, without any additional formatting.
6. Do not provide any additional code beyond the minimal executable code required to perform the intent.
### Verify the prompt
Expand Down Expand Up @@ -757,8 +762,9 @@ Please follow these steps carefully:
1. Analyze the provided intent and the view hierarchy to understand the required action.
2. Generate the minimal executable code required to perform the intent using the available API.
3. If you cannot generate the relevant code due to ambiguity or invalid intent, return code that throws an informative error explaining the problem in one sentence.
4. Wrap the generated code with backticks, without any additional formatting.
5. Do not provide any additional code beyond the minimal executable code required to perform the intent.
4. Each step must be completely independent - do not rely on any variables or assignments from previous steps. Even if a variable was declared or assigned in a previous step, you must redeclare and reassign it in your current step.
5. Wrap the generated code with backticks, without any additional formatting.
6. Do not provide any additional code beyond the minimal executable code required to perform the intent.
### Verify the prompt
Expand Down

0 comments on commit bad3732

Please sign in to comment.