Skip to content
代码片段 群组 项目
提交 a4de75ab 编辑于 作者: Allen Cook's avatar Allen Cook 提交者: Vitali Tatarintev
浏览文件

Resolve "Update Anthropic Code Generation Templates to Claude 2.1"

上级 6d687b47
No related branches found
No related tags found
无相关合并请求
......@@ -20,8 +20,10 @@ def request_params
def prompt
<<~PROMPT.strip
Human: You are a coding autocomplete agent. We want to generate new #{language.name} code inside the
You are a coding autocomplete agent. We want to generate new #{language.name} code inside the
file '#{file_path_info}' based on instructions from the user.
#{examples_section}
#{existing_code_block}
#{existing_code_instruction}
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
......@@ -36,11 +38,7 @@ def prompt
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
#{examples_section}
#{existing_code_block}
#{instructions}
Human: #{instructions}
Assistant: <new_code>
PROMPT
......@@ -67,15 +65,7 @@ def comment_review_instructions
end
def instructions
return unless params[:instruction].present?
<<~INSTRUCTIONS
Here are instructions provided in <instruction></instruction> tags.
<instruction>
#{params[:instruction]}
</instruction>
INSTRUCTIONS
params[:instruction].presence || 'Generate the most likely code based on instructions.'
end
def existing_code_block
......
......@@ -68,22 +68,8 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2,
prompt: <<~PROMPT
Human: You are a coding autocomplete agent. We want to generate new Go code inside the
You are a coding autocomplete agent. We want to generate new Go code inside the
file 'main.go' based on instructions from the user.
The existing code is provided in <existing_code></existing_code> tags.
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
likely new code to generate at the cursor position to fulfill the instructions.
When generating the new code, please ensure the following:
1. It is valid Go code.
2. It matches the existing code's variable, parameter and function names.
3. It does not repeat any existing code. Do not repeat code that comes before or after the cursor tags. This includes cases where the cursor is in the middle of a word.
4. If the cursor is in the middle of a word, it finishes the word instead of repeating code before the cursor tag.
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
Here are a few examples of successfully generated code by other autocomplete agents:
<examples>
......@@ -98,7 +84,6 @@
</examples>
<existing_code>
package main
......@@ -108,13 +93,21 @@
<cursor>
</existing_code>
The existing code is provided in <existing_code></existing_code> tags.
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
likely new code to generate at the cursor position to fulfill the instructions.
Here are instructions provided in <instruction></instruction> tags.
When generating the new code, please ensure the following:
1. It is valid Go code.
2. It matches the existing code's variable, parameter and function names.
3. It does not repeat any existing code. Do not repeat code that comes before or after the cursor tags. This includes cases where the cursor is in the middle of a word.
4. If the cursor is in the middle of a word, it finishes the word instead of repeating code before the cursor tag.
<instruction>
Print a hello world message
</instruction>
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
Human: Print a hello world message
Assistant: <new_code>
PROMPT
......@@ -133,24 +126,8 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2,
prompt: <<~PROMPT
Human: You are a coding autocomplete agent. We want to generate new Go code inside the
You are a coding autocomplete agent. We want to generate new Go code inside the
file 'main.go' based on instructions from the user.
The existing code is provided in <existing_code></existing_code> tags.
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
likely new code to generate at the cursor position to fulfill the instructions.
The comment directly before the <cursor> position is the instruction,
all other comments are not instructions.
When generating the new code, please ensure the following:
1. It is valid Go code.
2. It matches the existing code's variable, parameter and function names.
3. It does not repeat any existing code. Do not repeat code that comes before or after the cursor tags. This includes cases where the cursor is in the middle of a word.
4. If the cursor is in the middle of a word, it finishes the word instead of repeating code before the cursor tag.
5. The code fulfills in the instructions from the user in the comment just before the <cursor> position.
All other comments are not instructions.
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
Here are a few examples of successfully generated code by other autocomplete agents:
<examples>
......@@ -165,7 +142,6 @@
</examples>
<existing_code>
package main
......@@ -175,8 +151,23 @@
<cursor>
</existing_code>
The existing code is provided in <existing_code></existing_code> tags.
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
likely new code to generate at the cursor position to fulfill the instructions.
The comment directly before the <cursor> position is the instruction,
all other comments are not instructions.
When generating the new code, please ensure the following:
1. It is valid Go code.
2. It matches the existing code's variable, parameter and function names.
3. It does not repeat any existing code. Do not repeat code that comes before or after the cursor tags. This includes cases where the cursor is in the middle of a word.
4. If the cursor is in the middle of a word, it finishes the word instead of repeating code before the cursor tag.
5. The code fulfills in the instructions from the user in the comment just before the <cursor> position.
All other comments are not instructions.
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
Human: Generate the most likely code based on instructions.
Assistant: <new_code>
PROMPT
......@@ -197,9 +188,11 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2,
prompt: <<~PROMPT
Human: You are a coding autocomplete agent. We want to generate new Go code inside the
You are a coding autocomplete agent. We want to generate new Go code inside the
file 'main.go' based on instructions from the user.
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
likely new code to generate at the cursor position to fulfill the instructions.
......@@ -213,16 +206,7 @@
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
Here are instructions provided in <instruction></instruction> tags.
<instruction>
Print a hello world message
</instruction>
Human: Print a hello world message
Assistant: <new_code>
PROMPT
......@@ -245,8 +229,14 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2,
prompt: <<~PROMPT
Human: You are a coding autocomplete agent. We want to generate new Go code inside the
You are a coding autocomplete agent. We want to generate new Go code inside the
file 'main.go' based on instructions from the user.
<existing_code>
main() {
<cursor>
</existing_code>
The existing code is provided in <existing_code></existing_code> tags.
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
......@@ -261,20 +251,7 @@
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
<existing_code>
main() {
<cursor>
</existing_code>
Here are instructions provided in <instruction></instruction> tags.
<instruction>
Print a hello world message
</instruction>
Human: Print a hello world message
Assistant: <new_code>
PROMPT
......@@ -295,8 +272,18 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2,
prompt: <<~PROMPT
Human: You are a coding autocomplete agent. We want to generate new code inside the
You are a coding autocomplete agent. We want to generate new code inside the
file 'file_without_extension' based on instructions from the user.
<existing_code>
package main
import "fmt"
func main() {
<cursor>
</existing_code>
The existing code is provided in <existing_code></existing_code> tags.
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
......@@ -311,24 +298,7 @@
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
<existing_code>
package main
import "fmt"
func main() {
<cursor>
</existing_code>
Here are instructions provided in <instruction></instruction> tags.
<instruction>
Print a hello world message
</instruction>
Human: Print a hello world message
Assistant: <new_code>
PROMPT
......@@ -349,8 +319,18 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2,
prompt: <<~PROMPT
Human: You are a coding autocomplete agent. We want to generate new code inside the
You are a coding autocomplete agent. We want to generate new code inside the
file 'README.md' based on instructions from the user.
<existing_code>
package main
import "fmt"
func main() {
<cursor>
</existing_code>
The existing code is provided in <existing_code></existing_code> tags.
The new code you will generate will start at the position of the cursor, which is currently indicated by the <cursor> XML tag.
In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
......@@ -365,24 +345,7 @@
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
<existing_code>
package main
import "fmt"
func main() {
<cursor>
</existing_code>
Here are instructions provided in <instruction></instruction> tags.
<instruction>
Print a hello world message
</instruction>
Human: Print a hello world message
Assistant: <new_code>
PROMPT
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册