Skip to content

Commit fa20628

Browse files
committed
Removed problems with nodes note getting fetched due to bad queries
1 parent 9324ff8 commit fa20628

File tree

5 files changed

+14
-18
lines changed

5 files changed

+14
-18
lines changed

ai-assistant/src/commands/DocumentCommand.ts

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -62,8 +62,6 @@ export class DocumentCommand implements ISlashCommand {
6262
);
6363
if (!result) return null;
6464

65-
console.log(result);
66-
6765
const answer = result
6866
.split("<ANSWER_START>")[1]
6967
.split("<ANSWER_END>")[0]

ai-assistant/src/commands/ImportanceCommand.ts

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ export class ImportanceCommand implements ISlashCommand {
3131
LIMIT 1
3232
`
3333
);
34-
if (!maxOutDegreeQuery) return 0;
34+
if (!maxOutDegreeQuery.length) return 0;
3535
const maxOutDegree = maxOutDegreeQuery[0].get("outDegree").toNumber();
3636

3737
const outDegree = await db.run(
@@ -41,7 +41,7 @@ export class ImportanceCommand implements ISlashCommand {
4141
`,
4242
{ id: node.id }
4343
);
44-
if (!outDegree) return 0;
44+
if (!outDegree.length) return 0;
4545
const centrality = outDegree[0].get("outDegree").toNumber();
4646

4747
const relativeCentrality = centrality / maxOutDegree;
@@ -58,7 +58,7 @@ export class ImportanceCommand implements ISlashCommand {
5858
LIMIT 1
5959
`
6060
);
61-
if (!maxInDegreeQuery) return 0;
61+
if (!maxInDegreeQuery.length) return 0;
6262
const maxInDegree = maxInDegreeQuery[0].get("inDegree").toNumber();
6363

6464
const inDegree = await db.run(
@@ -68,7 +68,7 @@ export class ImportanceCommand implements ISlashCommand {
6868
`,
6969
{ id: node.id }
7070
);
71-
if (!inDegree) return 0;
71+
if (!inDegree.length) return 0;
7272
const criticality = inDegree[0].get("inDegree").toNumber();
7373

7474
const relativeCriticality = criticality / maxInDegree;

ai-assistant/src/core/query.ts

Lines changed: 8 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -15,15 +15,15 @@ export namespace Query {
1515
`
1616
CALL db.index.vector.queryNodes("${indexName}", 2, $vector)
1717
YIELD node, score
18-
WHERE score >= ${threshold}
19-
WITH node, score
20-
MATCH (node)-[r]->(relatedNode)
21-
RETURN node, COLLECT(relatedNode) AS relatedNodes, score
22-
ORDER BY score DESC
18+
WHERE score >= ${threshold}
19+
WITH node, score
20+
OPTIONAL MATCH (node)-[r]->(relatedNode)
21+
RETURN node, COLLECT(relatedNode) AS relatedNodes, score
22+
ORDER BY score DESC
2323
`,
2424
{ vector }
2525
);
26-
if (!result) return [];
26+
if (!result.length) return [];
2727

2828
const nodes: DBNode[] = [];
2929
for (const record of result) {
@@ -42,11 +42,12 @@ export namespace Query {
4242
for (const keyword of keywords) {
4343
const queryVector = await embeddingModel.generate(keyword);
4444
if (!queryVector) continue;
45+
4546
const result = await getDBNodesFromVectorQuery(
4647
db,
4748
"nameEmbeddings",
4849
queryVector,
49-
0.7
50+
0.85
5051
);
5152
results.push(...result);
5253
}

ai-assistant/src/endpoints/purgeDB.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,10 +18,7 @@ export class PurgeDBEndpoint extends ApiEndpoint {
1818

1919
async emptyDB(db: IDB) {
2020
const query = `MATCH (n) DETACH DELETE n`;
21-
const res = await db.run(query);
22-
if (!res) {
23-
throw new Error(JSON.stringify(res));
24-
}
21+
await db.run(query);
2522
}
2623

2724
async setupIndices(db: IDB) {

ai-assistant/src/modals/styleguideModal.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -54,7 +54,7 @@ async function process(http: IHttp, query: string): Promise<string | null> {
5454
* ---------------------------------------------------------------------------------------------
5555
*/
5656
const dbResults = await db.run(`MATCH (n:Styleguide) RETURN n`);
57-
if (!dbResults) return null;
57+
if (!dbResults.length) return null;
5858

5959
const styleGuides = dbResults.map((record) => record.get("n").properties);
6060
if (!styleGuides.length) return null;

0 commit comments

Comments
 (0)