Skip to content

Commit

Permalink
Edit: Use system prompt format (#3579)
Browse files Browse the repository at this point in the history
  • Loading branch information
umpox authored Mar 27, 2024
1 parent 65354ed commit 9c8c47f
Show file tree
Hide file tree
Showing 8 changed files with 5,542 additions and 5,466 deletions.
10,586 changes: 5,325 additions & 5,261 deletions agent/recordings/defaultClient_631904893/recording.har.yaml

Large diffs are not rendered by default.

165 changes: 67 additions & 98 deletions agent/recordings/enterpriseClient_3965582033/recording.har.yaml

Large diffs are not rendered by default.

29 changes: 16 additions & 13 deletions agent/src/index.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -880,11 +880,11 @@ describe('Agent', () => {
checkDocumentCommand(client, 'commands/document (basic function)', 'sum.ts', obtained =>
expect(obtained).toMatchInlineSnapshot(`
"/**
* Sums two numbers together.
* Adds two numbers together and returns the result.
*
* @param a - The first number to add.
* @param b - The second number to add.
* @returns The sum of the two numbers.
* @param a The first number to add.
* @param b The second number to add.
* @returns The sum of \`a\` and \`b\`.
*/
export function sum(a: number, b: number): number {
/* CURSOR */
Expand All @@ -905,7 +905,7 @@ describe('Agent', () => {
constructor(private shouldGreet: boolean) {}
/**
* Logs a greeting message to the console if the \`shouldGreet\` flag is true.
* Greets the user with "Hello World!" if the \`shouldGreet\` flag is true.
*/
public functionName() {
if (this.shouldGreet) {
Expand Down Expand Up @@ -964,8 +964,8 @@ describe('Agent', () => {
it('does something else', () => {
// This line will error due to incorrect usage of \`performance.now\`
/**
* Retrieves the current time in milliseconds since the page was loaded.
* This can be used to measure the elapsed time of an operation.
* Returns the current time in milliseconds since the page was loaded.
* This can be used to measure the duration of an operation.
*/
const startTime = performance.now(/* CURSOR */)
})
Expand Down Expand Up @@ -1130,14 +1130,16 @@ describe('Agent', () => {
const originalDocument = client.workspace.getDocument(animalUri)!
expect(trimEndOfLine(originalDocument.getText())).toMatchInlineSnapshot(
`
"export interface Animal {
"/* SELECTION_START */
export interface Animal {
name: string
makeAnimalSound(): string
isMammal: boolean
logName(): void {
console.log(this.name)
console.log(this.name);
}
}
/* SELECTION_END */
"
`,
explainPollyError
Expand Down Expand Up @@ -1290,10 +1292,11 @@ describe('Agent', () => {
import { describe } from 'vitest'
/**
* Test block that contains 3 sample test cases.
* The 1st case asserts true is true.
* The 2nd case asserts true is true.
* The 3rd case attempts to error by incorrectly using \`performance.now\`.
* Describe block that runs vitest tests.
* Contains 3 test cases:
* - Does test 1
* - Does test 2
* - Does something else (has incorrect usage of performance.now)
*/
describe('test block', () => {
it('does 1', () => {
Expand Down
4 changes: 2 additions & 2 deletions vscode/src/edit/prompt/index.ts
Original file line number Diff line number Diff line change
Expand Up @@ -101,7 +101,7 @@ export const buildInteraction = async ({

const promptBuilder = new PromptBuilder(contextWindow)

const preamble = getSimplePreamble(model, codyApiVersion)
const preamble = getSimplePreamble(model, codyApiVersion, prompt.system)
promptBuilder.tryAddToPrefix(preamble)

// Add pre-instruction for edit commands to end of human prompt to override the default
Expand All @@ -111,7 +111,7 @@ export const buildInteraction = async ({
.get('preInstruction')
const additionalRule = preInstruction ? `\nIMPORTANT: ${preInstruction.trim()}` : ''

const transcript: ChatMessage[] = [{ speaker: 'human', text: prompt + additionalRule }]
const transcript: ChatMessage[] = [{ speaker: 'human', text: prompt.instruction + additionalRule }]
if (assistantText) {
transcript.push({ speaker: 'assistant', text: assistantText })
}
Expand Down
Loading

0 comments on commit 9c8c47f

Please sign in to comment.