-
Notifications
You must be signed in to change notification settings - Fork 209
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
refactor: update preamble rules and mixin #1442
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Love the idea of adding Never make any assumptions nor provide any misleading or hypothetical examples.'
to the prompt!
Asked questions about other changes in the PR.
- If you do not have access to a repository, tell me to add additional repositories to the chat context using repositories selector below the input box to help you answer the question. | ||
- Only reference file names, repository names or URLs if you are sure they exist.` | ||
const multiRepoRules = `Important rules to follow in all your responses: | ||
- All code snippets must be markdown-formatted, and enclosed in triple backticks. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
What's the rationale for removing the triple backticks example?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
From my experience, It is harder to tell Claude not to return code with backticks than including them lol It was a big issue for fixup because it would includes the backticks in the edited code 😓
I don't think Claude has any problem connecting triple backticks with markdown, so the example IMO is unnecessary. Here is an example:
![image](https://private-user-images.githubusercontent.com/68532117/276801964-0d073513-563f-4e1f-9407-54a04d341e0b.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MTkxNzE2NTAsIm5iZiI6MTcxOTE3MTM1MCwicGF0aCI6Ii82ODUzMjExNy8yNzY4MDE5NjQtMGQwNzM1MTMtNTYzZi00ZTFmLTk0MDctNTRhMDRkMzQxZTBiLnBuZz9YLUFtei1BbGdvcml0aG09QVdTNC1ITUFDLVNIQTI1NiZYLUFtei1DcmVkZW50aWFsPUFLSUFWQ09EWUxTQTUzUFFLNFpBJTJGMjAyNDA2MjMlMkZ1cy1lYXN0LTElMkZzMyUyRmF3czRfcmVxdWVzdCZYLUFtei1EYXRlPTIwMjQwNjIzVDE5MzU1MFomWC1BbXotRXhwaXJlcz0zMDAmWC1BbXotU2lnbmF0dXJlPTdjYTg0MzYyODY5NmU1NTU0MzRlZjhlMmM3YmYyNjFmZGY4ZDJkMTdiMTlhN2U2MmYxOWNlMjI0YzZiYzBmODMmWC1BbXotU2lnbmVkSGVhZGVycz1ob3N0JmFjdG9yX2lkPTAma2V5X2lkPTAmcmVwb19pZD0wIn0.drE5iB97_GBa03miUCPNnQFOzcZQ2eOPIKHcfWJv2PI)
@@ -39,7 +39,7 @@ export interface PlatformContext { | |||
|
|||
export function activate(context: vscode.ExtensionContext, platformContext: PlatformContext): ExtensionApi { | |||
const api = new ExtensionApi() | |||
PromptMixin.add(languagePromptMixin(vscode.env.language)) | |||
PromptMixin.add(defaultPromptMixin()) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Is there a way to A/B test prompt changes as we do with autocomplete improvements?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think we have one but not sure if it's active 😅
*/ | ||
export function defaultPromptMixin(): PromptMixin { | ||
const identity = 'Reply as Cody, a coding assistant developed by Sourcegraph.' | ||
const hallucinate = 'Never make any assumptions nor provide any misleading or hypothetical examples.' |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
It would be interesting to test how this sentence affects CAR.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Haha we can put it behind a feature flag.
Can't wait to move to Starcoder so we don't have to worry about this 😏
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
➕
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Can't wait to move to Starcoder so we don't have to worry about this 😏
May I remind you of https://huggingface.co/bigcode/starcoder/discussions/50#647f8078222b8c6a6f3e1c27 😆
const answer = `Understood. I am Cody, an AI assistant made by Sourcegraph to help with programming tasks. | ||
I work inside a text editor. I have access to your currently open files in the editor. | ||
const answer = `Understood. I am Cody, an AI assistant developed by Sourcegraph to help with programming tasks. | ||
I am working with you inside an editor, and I will answer your questions based on the context you provide from your current codebases. |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Interesting, did you find that the present continuous tense works better for the prompt?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I do. I actually learnt this from Claude's docs: https://docs.anthropic.com/claude/docs/advanced-text-analysis
They also mentioned somewhere in their docs that it is better to speak to Claude in first person instead of third :)
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks for sharing the doc!
This is a massive win for our users. Thanks, @abeatrix for digging in! |
Updating current preamble, rules, and prompt mixin with new findings from #907.
Issue 1: Cody hallucinates about file path and code
One of the main issues we saw in Chat is Cody hallucinating about files and code that do not exist in the shared context.
I noticed this is mainly because of how we phrased our context, as Cody do not understand the relationship between each code snippet we share with them. For more information, see #907 (comment)
One of the many prompts I've tried to prevent hallucination is to add
Do not make any assumptions about the code and file names or any misleading information
to the question, which has been working well for me. This is also the prompt we added to all our commands. A customer has also confirmed that adding this to their questions stopped Cody from hallucinating and received better responses from Chat, this is why I propose adding it toPromptMixin
, which will be added to the start of every question (instead of Preabmle, which is added to the start of the session and will get left out as the conversation gets longer.)I don't think this will be 100% hallucination-proof, but it works a lot better than what we currently have.
Before
After
Issue 2: The current preambles need to be updated, and not working as intended most of the times.
Addressed by this PR with the following changes:
Issue 3: Cody will not answer in language that is not the default language of the editor
CLOSE https://github.com/sourcegraph/cody/discussions/1011 && #988
Many users have complained that they cannot get Cody to answer their questions because Cody refused to answer questions that is not the same as the default language of the editor.
Addressed by this PR with the following changes: Remove
languagePromptMixin
from theactivate
event for editors, which allows Cody to answer in the same language as the questionBefore
After
Test plan
Example question to ask in the cody repo:
Do we format the completion item before we suggest them?