Skip to content

Commit ffd9dc8

Browse files
committed
feat(graph): query_refiner_with_profile_node 추가 \
질문 재정의시 특징 정보 활용해 재정의하는 노드 utils.py 안 profile_to_text (질문 특징 정보 프롬프트 추가 함수)
1 parent 5e5accd commit ffd9dc8

File tree

2 files changed

+38
-0
lines changed

2 files changed

+38
-0
lines changed

llm_utils/graph.py

Lines changed: 21 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,6 +16,7 @@
1616

1717
from llm_utils.tools import get_info_from_db
1818
from llm_utils.retrieval import search_tables
19+
from llm_utils.utils import profile_to_text
1920

2021
# 노드 식별자 정의
2122
QUERY_REFINER = "query_refiner"
@@ -65,6 +66,26 @@ def query_refiner_node(state: QueryMakerState):
6566
return state
6667

6768

69+
# 노드 함수: QUERY_REFINER 노드
70+
def query_refiner_with_profile_node(state: QueryMakerState):
71+
72+
profile_bullets = profile_to_text(state["question_profile"])
73+
res = query_refiner_with_profile_chain.invoke(
74+
input={
75+
"user_input": [state["messages"][0].content],
76+
"user_database_env": [state["user_database_env"]],
77+
"best_practice_query": [state["best_practice_query"]],
78+
"searched_tables": [json.dumps(state["searched_tables"])],
79+
"profile_prompt": [profile_bullets],
80+
}
81+
)
82+
state["messages"].append(res)
83+
state["refined_input"] = res
84+
85+
print("refined_input before context enrichment : ", res.content)
86+
return state
87+
88+
6889
# 노드 함수: CONTEXT_ENRICHMENT 노드
6990
def context_enrichment_node(state: QueryMakerState):
7091

llm_utils/utils.py

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,17 @@
1+
def profile_to_text(profile_obj) -> str:
2+
mapping = {
3+
"is_timeseries": "• 시계열 분석 필요",
4+
"is_aggregation": "• 집계 함수 필요",
5+
"has_filter": "• WHERE 조건 필요",
6+
"is_grouped": "• GROUP BY 필요",
7+
"has_ranking": "• 정렬/순위 필요",
8+
"has_temporal_comparison": "• 기간 비교 필요",
9+
}
10+
bullets = [
11+
text for field, text in mapping.items() if getattr(profile_obj, field, False)
12+
]
13+
intent = getattr(profile_obj, "intent_type", None)
14+
if intent:
15+
bullets.append(f"• 의도 유형 → {intent}")
16+
17+
return "\n".join(bullets)

0 commit comments

Comments
 (0)