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

Merge branch '432636-update-anthropic-code-generation-templates-to-claude-2-1' into 'master'

Resolve "Update Anthropic Code Generation Templates to Claude 2.1"

See merge request https://gitlab.com/gitlab-org/gitlab/-/merge_requests/138088



Merged-by: default avatarVitali Tatarintev <vtatarintev@gitlab.com>
Approved-by: default avatarJan Provaznik <jprovaznik@gitlab.com>
Approved-by: default avatarVitali Tatarintev <vtatarintev@gitlab.com>
Reviewed-by: default avatarJan Provaznik <jprovaznik@gitlab.com>
Co-authored-by: default avatarAllen Cook <acook@gitlab.com>
No related branches found
No related tags found
无相关合并请求
...@@ -20,8 +20,10 @@ def request_params ...@@ -20,8 +20,10 @@ def request_params
def prompt def prompt
<<~PROMPT.strip <<~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. file '#{file_path_info}' based on instructions from the user.
#{examples_section}
#{existing_code_block}
#{existing_code_instruction} #{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. 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 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 ...@@ -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. 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>. If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
#{examples_section} Human: #{instructions}
#{existing_code_block}
#{instructions}
Assistant: <new_code> Assistant: <new_code>
PROMPT PROMPT
...@@ -67,15 +65,7 @@ def comment_review_instructions ...@@ -67,15 +65,7 @@ def comment_review_instructions
end end
def instructions def instructions
return unless params[:instruction].present? params[:instruction].presence || 'Generate the most likely code based on instructions.'
<<~INSTRUCTIONS
Here are instructions provided in <instruction></instruction> tags.
<instruction>
#{params[:instruction]}
</instruction>
INSTRUCTIONS
end end
def existing_code_block def existing_code_block
......
...@@ -68,22 +68,8 @@ ...@@ -68,22 +68,8 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC, model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2, prompt_version: 2,
prompt: <<~PROMPT 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. 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: Here are a few examples of successfully generated code by other autocomplete agents:
<examples> <examples>
...@@ -98,7 +84,6 @@ ...@@ -98,7 +84,6 @@
</examples> </examples>
<existing_code> <existing_code>
package main package main
...@@ -108,13 +93,21 @@ ...@@ -108,13 +93,21 @@
<cursor> <cursor>
</existing_code> </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> Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position.
Print a hello world message If you are not able to write code based on the given instructions return an empty result like <new_code></new_code>.
</instruction>
Human: Print a hello world message
Assistant: <new_code> Assistant: <new_code>
PROMPT PROMPT
...@@ -133,24 +126,8 @@ ...@@ -133,24 +126,8 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC, model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2, prompt_version: 2,
prompt: <<~PROMPT 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. 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: Here are a few examples of successfully generated code by other autocomplete agents:
<examples> <examples>
...@@ -165,7 +142,6 @@ ...@@ -165,7 +142,6 @@
</examples> </examples>
<existing_code> <existing_code>
package main package main
...@@ -175,8 +151,23 @@ ...@@ -175,8 +151,23 @@
<cursor> <cursor>
</existing_code> </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> Assistant: <new_code>
PROMPT PROMPT
...@@ -197,9 +188,11 @@ ...@@ -197,9 +188,11 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC, model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2, prompt_version: 2,
prompt: <<~PROMPT 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. 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. 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 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. likely new code to generate at the cursor position to fulfill the instructions.
...@@ -213,16 +206,7 @@ ...@@ -213,16 +206,7 @@
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position. 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>. 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
Here are instructions provided in <instruction></instruction> tags.
<instruction>
Print a hello world message
</instruction>
Assistant: <new_code> Assistant: <new_code>
PROMPT PROMPT
...@@ -245,8 +229,14 @@ ...@@ -245,8 +229,14 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC, model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2, prompt_version: 2,
prompt: <<~PROMPT 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. 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 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. 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 In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
...@@ -261,20 +251,7 @@ ...@@ -261,20 +251,7 @@
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position. 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>. 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
<existing_code>
main() {
<cursor>
</existing_code>
Here are instructions provided in <instruction></instruction> tags.
<instruction>
Print a hello world message
</instruction>
Assistant: <new_code> Assistant: <new_code>
PROMPT PROMPT
...@@ -295,8 +272,18 @@ ...@@ -295,8 +272,18 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC, model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2, prompt_version: 2,
prompt: <<~PROMPT 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. 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 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. 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 In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
...@@ -311,24 +298,7 @@ ...@@ -311,24 +298,7 @@
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position. 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>. 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
<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>
Assistant: <new_code> Assistant: <new_code>
PROMPT PROMPT
...@@ -349,8 +319,18 @@ ...@@ -349,8 +319,18 @@
model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC, model_provider: ::CodeSuggestions::TaskFactory::ANTHROPIC,
prompt_version: 2, prompt_version: 2,
prompt: <<~PROMPT 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. 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 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. 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 In your process, first, review the existing code to understand its logic and format. Then, try to determine the most
...@@ -365,24 +345,7 @@ ...@@ -365,24 +345,7 @@
Return new code enclosed in <new_code></new_code> tags. We will then insert this at the <cursor> position. 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>. 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
<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>
Assistant: <new_code> Assistant: <new_code>
PROMPT PROMPT
......
0% 加载中 .
You are about to add 0 people to the discussion. Proceed with caution.
先完成此消息的编辑!
想要评论请 注册