Skip to content

Commit d1caa08

Browse files
committed
Improved prompt for extractDBKeywords
1 parent 4bb8959 commit d1caa08

File tree

2 files changed

+16
-25
lines changed

2 files changed

+16
-25
lines changed
Lines changed: 15 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,29 +1,23 @@
11
export const PROMPT_EXTRACT_DB_KEYWORDS = `
2-
You are an expert in extracting and predicting the possible keywords from the user's query about a codebase. The user might ask questions like:
3-
1. "Find the codebase for the user query CRC_TABLE in the main.ts"
4-
2. "Where is the function calculateChecksum defined in the repository?"
5-
3. "Which file contains the class definition for UserProfile?"
6-
4. "Show me the implementation of the handleSubmit method in the formHandler.js file."
7-
5. "Where is the API_BASE_URL constant declared?"
8-
6. "Find the test cases for the loginUser function."
2+
You are an expert in understanding and answering questions of user when given a proper context of the codebase.
93
10-
You have to answer these by predicting the possible keywords from the user's query that might be referenced in the codebase. For eg:
11-
- CRC_TABLE, main.ts
12-
- calculateChecksum, repository
13-
- UserProfile
14-
- handleSubmit, formHandler.js
15-
- API_BASE_URL
16-
- loginUser
4+
INPUT: User's text query in either natural language or code format.
175
18-
But you have to output them the following way:
19-
- <ANSWER>[CRC_TABLE,main.ts]</ANSWER>
20-
- <ANSWER>[calculateChecksum,repository]</ANSWER>
21-
- <ANSWER>[UserProfile]</ANSWER>
22-
- <ANSWER>[handleSubmit,formHandler.js]</ANSWER>
23-
- <ANSWER>[API_BASE_URL]</ANSWER>
24-
- <ANSWER>[loginUser]</ANSWER>
6+
TASKS:
7+
- NEVER USE backslash in any of the keywords even if it's part of the query.
8+
- Extract the possible keywords from the user's query.
9+
- Query the database to find the nodes names of which are similar to what user has requested.
10+
- If you are unable to extract the keywords, return an empty array.
11+
- EXTRACT THE KEYWORDS IN SUCH A WAY THAT EACH STRING AS ONE WORD ELEMENT ONLY.
12+
13+
EXAMPLE:
14+
- INPUT:
15+
"Find the codebase for the user query CRC_TABLE in the main.ts'
16+
- OUTPUT:
17+
<ANSWER_START>CRC_TABLE, main.ts<ANSWER_END>
2518
2619
RULES:
2720
- DO NOT REPEAT THE KEYWORDS MULTIPLE TIMES.
21+
- DO NOT SAY ANYTHING ELSE APART FROM THE PROVIDED OUTPUT FORMAT.
2822
- STRICTLY, do not make anything other than the answer to the user's query.
2923
`;

ai-assistant/src/core/prompt/prompt.factory.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,6 @@
11
import { PROMPT_ASK_COMMAND } from "./contents/ask";
22
import { PROMPT_DIAGRAM_COMMAND } from "./contents/diagram";
33
import { PROMPT_DOCUMENT_COMMAND } from "./contents/document";
4-
import { PROMPT_EXTRACT_DB_KEYWORDS } from "./contents/extractDBKeywords";
54
import { PROMPT_STYLEGUIDE_COMMAND } from "./contents/styleguide";
65
import { PROMPT_SUGGEST_COMMAND } from "./contents/suggest";
76
import { PROMPT_TRANSLATE_COMMAND } from "./contents/translate";
@@ -11,8 +10,6 @@ import { Prompt } from "./prompt";
1110
export namespace PromptFactory {
1211
export function makeDBKeywordQueryPrompt(query: string): Prompt {
1312
const prompt = new Prompt();
14-
15-
prompt.pushSystem(PROMPT_EXTRACT_DB_KEYWORDS);
1613
prompt.pushAssistant(
1714
"Sure, I will strictly follow my instructions. I will provide the answer the above specified format only."
1815
);
@@ -25,7 +22,7 @@ export namespace PromptFactory {
2522
prompt.pushAssistant(
2623
"Yeah sure. I understand this codebase very well and I am able to extract the possible keywords from the user's query. If I can't find the keywords, I'll return an empty array."
2724
);
28-
prompt.pushSystem("<ANSWER>");
25+
prompt.pushUser(query);
2926

3027
return prompt;
3128
}

0 commit comments

Comments
 (0)