Skip to content

Commit 7715ae6

Browse files
committed
fix: handle error message case and add workspace info in prompt
1 parent a1d34ce commit 7715ae6

File tree

2 files changed

+19
-1
lines changed

2 files changed

+19
-1
lines changed

src/pages/aiAssistant/assistant.js

Lines changed: 14 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -237,7 +237,11 @@ export default function openAIAssistantPage() {
237237
if (message.role === "user") {
238238
messageContent.textContent = message.content;
239239
} else {
240-
const md = markdownIt();
240+
const md = markdownIt({
241+
html: true,
242+
linkify: true,
243+
typographer: true,
244+
});
241245
messageContent.innerHTML = md.render(message.content);
242246
}
243247

@@ -680,6 +684,15 @@ export default function openAIAssistantPage() {
680684
);
681685
if (targetMessageElContent) {
682686
targetMessageElContent.innerHTML += errorContent;
687+
} else {
688+
const assistantErrorMsg = {
689+
id: assistantMsgId,
690+
conversationId: currentConversationId,
691+
role: "assistant",
692+
content: errorContent,
693+
timestamp: Date.now(),
694+
};
695+
addMessage(assistantErrorMsg);
683696
}
684697
} finally {
685698
currentController = null;

src/pages/aiAssistant/system_prompt.js

Lines changed: 5 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,5 @@
1+
import { addedFolder } from "lib/openFolder";
2+
13
export const SYSTEM_PROMPT = `You are a highly skilled software engineer with extensive knowledge in many programming languages, frameworks, design patterns, and best practices.
24
35
## Communication
@@ -26,4 +28,7 @@ Otherwise, follow debugging best practices:
2628
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.
2729
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.
2830
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)
31+
32+
SideBar workspace projects(name, absolutePath or url):
33+
${addedFolder.map((node) => `name: ${node.title}\nurl: ${node.url}`).join("\n")}
2934
`;

0 commit comments

Comments
 (0)