Skip to content

Commit 5a65240

Browse files
authored
Merge pull request #75 Resolve #42
multi user환경을 위한 세션별 분리
2 parents 382d831 + d50826e commit 5a65240

File tree

1 file changed

+15
-1
lines changed

1 file changed

+15
-1
lines changed

interface/lang2sql.py

+15-1
Original file line numberDiff line numberDiff line change
@@ -57,8 +57,12 @@ def execute_query(
5757
Returns:
5858
dict: 변환된 SQL 쿼리 및 관련 메타데이터를 포함하는 결과 딕셔너리.
5959
"""
60+
# 세션 상태에서 그래프 가져오기
61+
graph = st.session_state.get("graph")
62+
if graph is None:
63+
graph = builder.compile()
64+
st.session_state["graph"] = graph
6065

61-
graph = builder.compile()
6266
res = graph.invoke(
6367
input={
6468
"messages": [HumanMessage(content=query)],
@@ -113,6 +117,16 @@ def display_result(
113117

114118
st.title("Lang2SQL")
115119

120+
# 세션 상태 초기화
121+
if "graph" not in st.session_state:
122+
st.session_state["graph"] = builder.compile()
123+
st.info("Lang2SQL이 성공적으로 시작되었습니다.")
124+
125+
# 새로고침 버튼 추가
126+
if st.sidebar.button("Lang2SQL 새로고침"):
127+
st.session_state["graph"] = builder.compile()
128+
st.sidebar.success("Lang2SQL이 성공적으로 새로고침되었습니다.")
129+
116130
user_query = st.text_area(
117131
"쿼리를 입력하세요:",
118132
value=DEFAULT_QUERY,

0 commit comments

Comments
 (0)