Skip to content

Commit

Permalink
Remove dummy nodes from qtd rewrite query
Browse files Browse the repository at this point in the history
  • Loading branch information
dayesouza committed Nov 13, 2024
1 parent c3fedf5 commit 0de97b2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions intelligence_toolkit/query_text_data/query_rewriter.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# Licensed under the MIT license. See LICENSE file in the project.

import networkx as nx

import intelligence_toolkit.AI.utils as utils
import intelligence_toolkit.query_text_data.prompts as prompts

Expand All @@ -20,12 +21,13 @@ async def rewrite_query(ai_configuration, query, concept_graph, top_concepts):
Returns:
str: The rewritten query.
"""
concepts = sorted(concept_graph.degree(), key=lambda x: x[1], reverse=True)[
:top_concepts
]
concepts = sorted(concept_graph.degree(), key=lambda x: x[1], reverse=True)
if "dummynode" in concepts:
concepts.remove("dummynode")

concepts = concepts[:top_concepts]
concepts_str = ", ".join([concept for concept, _ in concepts])
messages = utils.prepare_messages(
prompts.query_anchoring_prompt, {"query": query, "concepts": concepts_str}
)
response = await utils.generate_text_async(ai_configuration, messages)
return response
return await utils.generate_text_async(ai_configuration, messages)

0 comments on commit 0de97b2

Please sign in to comment.