Skip to content

Commit 09d87f6

Browse files
committed
Fixed prompt for extracting keywords from query
1 parent 7ccb5de commit 09d87f6

File tree

4 files changed

+24
-23
lines changed

4 files changed

+24
-23
lines changed

ai-assistant/src/commands/AskCommand.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,7 +10,7 @@ import {
1010

1111
import { Neo4j } from "../core/db/neo4j";
1212
import { MiniLML6 } from "../core/embeddings/minilml6";
13-
import { Mistral_7B } from "../core/llm/mistral_7b";
13+
import { Llama3_70B } from "../core/llm/llama3_70B";
1414
import { PromptFactory } from "../core/prompt/prompt.factory";
1515
import { Query } from "../core/query";
1616
import { handleCommandResponse } from "../utils/handleCommandResponse";
@@ -23,7 +23,7 @@ export class AskCommand implements ISlashCommand {
2323

2424
private async process(http: IHttp, query: string): Promise<string | null> {
2525
const db = new Neo4j(http);
26-
const llm = new Mistral_7B(http);
26+
const llm = new Llama3_70B(http);
2727
const embeddingModel = new MiniLML6(http);
2828

2929
/**
Lines changed: 19 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,23 +1,25 @@
11
export const PROMPT_EXTRACT_DB_KEYWORDS = `
2-
You are an expert in understanding and answering questions of user when given a proper context of the codebase.
2+
You are an expert in understanding and answering questions of user.
33
4+
---
45
INPUT: User's text query in either natural language or code format.
5-
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-
6+
---
7+
RULES:
8+
1. Extract the possible keywords from the user's query.
9+
2. If you are unable to extract the keywords, return an empty array.
10+
3. Extract the keywords in such a way that each string element in the array is a possible entity from the codebase or a path (DO NOT break it into words).
11+
4. STRICTLY, do not make anything other than the answer to the user's query.
12+
---
1313
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>
14+
1. INPUT: "Find the codebase for the user query CRC_TABLE in the main.ts"
15+
OUTPUT: <ANSWER>CRC_TABLE, main.ts</ANSWER>
16+
2. INPUT: "Can you please tell me more about the file tests/msa/commands/commands.spec.ts?"
17+
OUTPUT: <ANSWER>tests/msa/commands/commands.spec.ts</ANSWER>
18+
3. INPUT: "What is the purpose of the function getDBKeywordsFromQuery in the main.ts?"
19+
OUTPUT: <ANSWER>getDBKeywordsFromQuery, main.ts</ANSWER>
20+
4. INPUT: "Can you please tell me more about the file tests/commands.spec.ts?"
21+
OUTPUT: <ANSWER>tests/commands.spec.ts</ANSWER>
1822
19-
RULES:
20-
- DO NOT REPEAT THE KEYWORDS MULTIPLE TIMES.
21-
- DO NOT SAY ANYTHING ELSE APART FROM THE PROVIDED OUTPUT FORMAT.
22-
- STRICTLY, do not make anything other than the answer to the user's query.
23+
OUTPUT FORMAT: <ANSWER>keyword1,keyword2,full/path/1,full/path/2</ANSWER>
24+
---
2325
`;

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

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,7 +13,7 @@ export namespace PromptFactory {
1313
const prompt = new Prompt();
1414
prompt.pushSystem(PROMPT_EXTRACT_DB_KEYWORDS);
1515
prompt.pushUser(
16-
`Hey I have this query, can you please extract the possible keywords from it? Please answer in the format only and don't say literally anything else <ANSWER_START>keyword1, keyword2<ANSWER_END>.\n\nHere's my query:\n${query}`
16+
`Hey I have this query, can you please extract the possible keywords from it? Please answer in <ANSWER_START>keyword1, keyword2<ANSWER_END> format only and don't say literally anything else.\n\nHere's my query:\n${query}`
1717
);
1818

1919
return prompt;

ai-assistant/src/core/query.ts

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -66,8 +66,8 @@ export namespace Query {
6666

6767
// @ts-ignore
6868
const keywords = content
69-
.split("<ANSWER_START>")[1]
70-
.split("<ANSWER_END>")[0]
69+
.split("<ANSWER>")[1]
70+
.split("</ANSWER>")[0]
7171
.split(",")
7272
.map((x) => x.trim())
7373
.map((x) => {
@@ -76,7 +76,6 @@ export namespace Query {
7676
}
7777
return x;
7878
});
79-
console.log(keywords);
8079

8180
return keywords;
8281
}

0 commit comments

Comments
 (0)