File tree Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Expand file tree Collapse file tree 2 files changed +38
-0
lines changed Original file line number Diff line number Diff line change 1616
1717from llm_utils .tools import get_info_from_db
1818from llm_utils .retrieval import search_tables
19+ from llm_utils .utils import profile_to_text
1920
2021# 노드 식별자 정의
2122QUERY_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 노드
6990def context_enrichment_node (state : QueryMakerState ):
7091
Original file line number Diff line number Diff line change 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 )
You can’t perform that action at this time.
0 commit comments