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

Change the "code-repair" and "write-tests" task prompt to enforce the generated code to be inside code fences, to ensure we can extract the code from the LLMs response #259

Merged
merged 2 commits into from
Jul 11, 2024
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions model/llm/llm.go
Original file line number Diff line number Diff line change
Expand Up @@ -77,7 +77,7 @@ type llmSourceFilePromptContext struct {
var llmGenerateTestForFilePromptTemplate = template.Must(template.New("model-llm-generate-test-for-file-prompt").Parse(bytesutil.StringTrimIndentations(`
Given the following {{ .Language.Name }} code file "{{ .FilePath }}" with package "{{ .ImportPath }}", provide a test file for this code{{ with $testFramework := .Language.TestFramework }} with {{ $testFramework }} as a test framework{{ end }}.
The tests should produce 100 percent code coverage and must compile.
The response must contain only the test code and nothing else.
The response must contain only the test code in a fenced code block and nothing else.

` + "```" + `{{ .Language.ID }}
{{ .Code }}
Expand Down Expand Up @@ -108,7 +108,7 @@ type llmCodeRepairSourceFilePromptContext struct {
// llmCodeRepairSourceFilePromptTemplate is the template for generating an LLM code repair prompt.
var llmCodeRepairSourceFilePromptTemplate = template.Must(template.New("model-llm-code-repair-source-file-prompt").Parse(bytesutil.StringTrimIndentations(`
Given the following {{ .Language.Name }} code file "{{ .FilePath }}" with package "{{ .ImportPath }}" and a list of compilation errors, modify the code such that the errors are resolved.
The response must contain only the source code and nothing else.
The response must contain only the source code in a fenced code block and nothing else.

` + "```" + `{{ .Language.ID }}
{{ .Code }}
Expand Down
2 changes: 1 addition & 1 deletion model/llm/llm_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -324,7 +324,7 @@ func TestLLMCodeRepairSourceFilePrompt(t *testing.T) {

ExpectedMessage: bytesutil.StringTrimIndentations(`
Given the following Go code file "/path/to/foobar.go" with package "foobar" and a list of compilation errors, modify the code such that the errors are resolved.
The response must contain only the source code and nothing else.
The response must contain only the source code in a fenced code block and nothing else.

` + "```" + `golang
package foobar
Expand Down
Loading