Skip to content

Commit cd9faa0

Browse files
authored
Add math formatting hints to common prompts (#212)
Tells the agent if KaTeX should be used in responses and how to format these equations
1 parent 20e8e2f commit cd9faa0

File tree

2 files changed

+28
-1
lines changed

2 files changed

+28
-1
lines changed

src/extension/prompts/node/agent/agentInstructions.tsx

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -11,6 +11,7 @@ import { InstructionMessage } from '../base/instructionMessage';
1111
import { ResponseTranslationRules } from '../base/responseTranslationRules';
1212
import { Tag } from '../base/tag';
1313
import { CodeBlockFormattingRules, EXISTING_CODE_MARKER } from '../panel/codeBlockFormattingRules';
14+
import { MathIntegrationRules } from '../panel/editorIntegrationRules';
1415
import { getKeepGoingReminder } from './agentPrompt';
1516

1617
interface DefaultAgentPromptProps extends BasePromptElementProps {
@@ -115,6 +116,7 @@ export class DefaultAgentPrompt extends PromptElement<DefaultAgentPromptProps> {
115116
<Tag name='example'>
116117
The class `Person` is in `src/models/person.ts`.
117118
</Tag>
119+
<MathIntegrationRules />
118120
</Tag>
119121
<ResponseTranslationRules />
120122
</InstructionMessage>;

src/extension/prompts/node/panel/editorIntegrationRules.tsx

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,7 +3,8 @@
33
* Licensed under the MIT License. See License.txt in the project root for license information.
44
*--------------------------------------------------------------------------------------------*/
55

6-
import { PromptElement } from '@vscode/prompt-tsx';
6+
import { BasePromptElementProps, PromptElement } from '@vscode/prompt-tsx';
7+
import { IConfigurationService } from '../../../../platform/configuration/common/configurationService';
78

89
export class EditorIntegrationRules extends PromptElement {
910
render() {
@@ -12,10 +13,34 @@ export class EditorIntegrationRules extends PromptElement {
1213
Use Markdown formatting in your answers.<br />
1314
Make sure to include the programming language name at the start of the Markdown code blocks.<br />
1415
Avoid wrapping the whole response in triple backticks.<br />
16+
<MathIntegrationRules />
1517
The user works in an IDE called Visual Studio Code which has a concept for editors with open files, integrated unit test support, an output pane that shows the output of running the code as well as an integrated terminal.<br />
1618
The active document is the source code the user is looking at right now.<br />
1719
You can only give one reply for each conversation turn.<br />
1820
</>
1921
);
2022
}
2123
}
24+
25+
export class MathIntegrationRules extends PromptElement {
26+
27+
constructor(
28+
props: BasePromptElementProps,
29+
@IConfigurationService private readonly configService: IConfigurationService
30+
) {
31+
super(props);
32+
}
33+
34+
render() {
35+
const mathEnabled = this.configService.getNonExtensionConfig<boolean>('chat.math.enabled');
36+
if (mathEnabled) {
37+
return (
38+
<>
39+
Use KaTeX for math equations in your answers.<br />
40+
Wrap inline math equations in $.<br />
41+
Wrap more complex blocks of math equations in $$.<br />
42+
</>
43+
);
44+
}
45+
}
46+
}

0 commit comments

Comments
 (0)