Skip to content

Commit 4dbb288

Browse files
committed
feat: system prompt and fix html rendering in codeblock
1 parent 7884868 commit 4dbb288

File tree

2 files changed

+32
-8
lines changed

2 files changed

+32
-8
lines changed

src/pages/aiAssistant/assistant.js

Lines changed: 3 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,6 @@ import { MemorySaver } from "@langchain/langgraph-checkpoint";
44
import { createReactAgent } from "@langchain/langgraph/prebuilt";
55
import confirm from "dialogs/confirm";
66
import select from "dialogs/select";
7-
import he from "he";
87
import Ref from "html-tag-js/ref";
98
import EditorFile from "lib/editorFile";
109
import settings from "lib/settings";
@@ -19,6 +18,7 @@ import {
1918
getMessagesForConversation,
2019
updateConversation,
2120
} from "./db";
21+
import { SYSTEM_PROMPT } from "./system_prompt";
2222

2323
export default function openAIAssistantPage() {
2424
// References
@@ -50,6 +50,7 @@ export default function openAIAssistantPage() {
5050
llm: model,
5151
tools: [searchTool],
5252
checkpointSaver: agentCheckpointer,
53+
stateModifier: SYSTEM_PROMPT,
5354
});
5455

5556
const generateConversationId = () =>
@@ -89,7 +90,6 @@ export default function openAIAssistantPage() {
8990
/<pre><code(?: class="language-(\w+)")?>([\s\S]*?)<\/code><\/pre>/g,
9091
(match, language, code) => {
9192
language = language || "plaintext";
92-
code = he.decode(code);
9393
return `
9494
<div class="code-block">
9595
<div class="code-header">
@@ -498,13 +498,8 @@ export default function openAIAssistantPage() {
498498
showLoading();
499499

500500
let messagesForAgentTurn;
501-
const systemPrompt = {
502-
role: "system",
503-
content: `You are an AI assistant in Acode code editor. Profile: ${currentProfile}. Be helpful and concise.`,
504-
};
505-
//Gemini Api expects system prompt as first message
506501
if (chatHistory.filter((msg) => msg.role === "user").length === 1) {
507-
messagesForAgentTurn = [systemPrompt, userMessageForAgent];
502+
messagesForAgentTurn = [userMessageForAgent];
508503
} else {
509504
messagesForAgentTurn = [userMessageForAgent];
510505
}
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
export const SYSTEM_PROMPT = `You are a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.
2+
3+
## Communication
4+
5+
1. Be conversational but professional.
6+
2. Refer to the user in the second person and yourself in the first person.
7+
3. Format your responses in markdown. Use backticks to format file, directory, function, and class names.
8+
4. NEVER lie or make things up.
9+
5. Refrain from apologizing all the time when results are unexpected. Instead, just try your best to proceed or explain the circumstances to the user without apologizing.
10+
11+
## Fixing Diagnostics
12+
13+
1. Make 1-2 attempts at fixing diagnostics, then defer to the user.
14+
2. Never simplify code you've written just to solve diagnostics. Complete, mostly correct code is more valuable than perfect code that doesn't solve the problem.
15+
16+
## Debugging Guidelines
17+
18+
When debugging, only make code changes if you are certain that you can solve the problem.
19+
Otherwise, follow debugging best practices:
20+
1. Address the root cause instead of the symptoms.
21+
2. Add descriptive logging statements and error messages to track variable and code state.
22+
3. Add test functions and statements to isolate the problem.
23+
24+
## Calling External APIs
25+
26+
1. Unless explicitly requested by the user, use the best suited external APIs and packages to solve the task. There is no need to ask the user for permission.
27+
2. When selecting which version of an API or package to use, choose one that is compatible with the user's dependency management file(s). If no such file exists or if the package is not present, use the latest version that is in your training data.
28+
3. If an external API requires an API Key, be sure to point this out to the user. Adhere to best security practices (e.g. DO NOT hardcode an API key in a place where it can be exposed)
29+
`;

0 commit comments

Comments
 (0)