Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 3 additions & 11 deletions application/pages/1_🌍_Generative_BI_Playground.py
Original file line number Diff line number Diff line change
Expand Up @@ -384,8 +384,7 @@ def main():
"intent": "normal_search",
"slot": []
}
# 通过标志位控制后续的逻辑
# 主要的意图有4个, 拒绝, 查询, 思维链, 知识问答

if intent_ner_recognition_flag:
with st.status("Performing intent recognition...") as status_text:
intent_response = get_query_intent(model_type, search_box, prompt_map)
Expand Down Expand Up @@ -413,12 +412,10 @@ def main():
else:
search_intent_flag = True

# 主要的逻辑部分,调用LLM
if reject_intent_flag:
st.write("Your query statement is currently not supported by the system")

elif search_intent_flag:
# 执行普通的查询,并可视化结果
normal_search_result = normal_text_search_streamlit(search_box, model_type,
database_profile,
entity_slot, opensearch_info,
Expand Down Expand Up @@ -456,11 +453,9 @@ def main():
else:
st.error("Intent recognition error")

# 前端结果显示agent cot任务拆分信息, normal_text_search 的显示,做了拆分,为了方便跟API逻辑一致
if search_intent_flag:
if normal_search_result.sql != "":
current_nlq_chain.set_generated_sql(normal_search_result.sql)
# st.code(normal_search_result.sql, language="sql")

current_nlq_chain.set_generated_sql_response(normal_search_result.response)

Expand All @@ -478,7 +473,6 @@ def main():
with st.expander(f'Agent Task Result: {len(agent_search_result)}'):
st.write(agent_search_result)

# 连接数据库,执行SQL, 记录历史记录并展示
if search_intent_flag:
with st.spinner('Executing query...'):
search_intent_result = get_sql_result_tool(
Expand Down Expand Up @@ -544,18 +538,16 @@ def main():
# do something here
pass

# 数据可视化展示
if visualize_results_flag and search_intent_flag:
current_search_sql_result = st.session_state.current_sql_result[selected_profile]
if current_search_sql_result is not None and len(current_search_sql_result) > 0:
st.session_state.messages[selected_profile].append(
{"role": "assistant", "content": current_search_sql_result, "type": "pandas"})
# Reset change flag to False

do_visualize_results(current_nlq_chain, st.session_state.current_sql_result[selected_profile])
else:
st.markdown("No relevant data found")

# 生成推荐问题
if gen_suggested_question_flag and (search_intent_flag or agent_intent_flag):
st.markdown('You might want to further ask:')
with st.spinner('Generating suggested questions...'):
Expand All @@ -576,7 +568,7 @@ def main():
on_click=sample_question_clicked,
args=[gen_sq_list[2]])
else:
# st.error("Please enter a valid query.")

if current_nlq_chain.is_visualization_config_changed():
if visualize_results_flag:
do_visualize_results(current_nlq_chain, st.session_state.current_sql_result[selected_profile])
Expand Down
2 changes: 0 additions & 2 deletions application/pages/2_🪙_Data_Connection_Management.py
Original file line number Diff line number Diff line change
Expand Up @@ -112,8 +112,6 @@ def main():
ConnectionManagement.delete_connection(connection_name)
st.success(f"{connection_name} deleted successfully!")
st.session_state.current_connection = None
# st.session_state.update_connection_mode = False
# st.experimental_rerun() # Rerun the app to update the selectbox options and remove the selected option

st.session_state.update_connection_mode = False

Expand Down
1 change: 0 additions & 1 deletion application/pages/3_🪙_Data_Profile_Management.py
Original file line number Diff line number Diff line change
Expand Up @@ -111,7 +111,6 @@ def main():
st.session_state.profile_page_mode = 'default'

else:
# st.subheader("Data Profile Management")
st.info('Please select connection in the left sidebar.')


Expand Down
3 changes: 0 additions & 3 deletions application/pages/4_🪙_Schema_Description_Management.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,9 +12,6 @@ def main():
st.set_page_config(page_title="Schema Management", )
make_sidebar()

# if 'profile_page_mode' not in st.session_state:
# st.session_state['index_mgt_mode'] = 'default'

with st.sidebar:
st.title("Schema Management")
current_profile = st.selectbox("My Data Profiles", ProfileManagement.get_all_profiles(),
Expand Down
4 changes: 2 additions & 2 deletions application/pages/mainpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,6 +31,6 @@
st.info("The OpenSearch Index is Error, Please Create OpenSearch Index First!!!")
else:
current_profile = "entity_insert_test"
entity = "环比"
comment = "环比增长率是指本期和上期相比较的增长率,计算公式为:环比增长率 =(本期数-上期数)/ 上期数 ×100%"
entity = "Month on month ratio"
comment = "The month on month growth rate refers to the growth rate compared to the previous period, and the calculation formula is: month on month growth rate=(current period number - previous period number)/previous period number x 100%"
VectorStore.add_entity_sample(current_profile, entity, comment)
6 changes: 0 additions & 6 deletions application/utils/tool.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,20 +18,14 @@ def get_generated_sql(generated_sql_response):


def generate_log_id():
# 获取当前时间戳,精确到微秒
timestamp = int(time.time() * 1000000)
# 添加随机数以增加唯一性
random_part = random.randint(0, 9999)
# 拼接时间戳和随机数生成logID
log_id = f"{timestamp}{random_part:04d}"
return log_id


def get_current_time():
# 获取当前时间
now = datetime.now()
# 格式化时间,包括毫秒部分
# 注意:strftime默认不直接支持毫秒,需要单独处理
formatted_time = now.strftime('%Y-%m-%d %H:%M:%S')
return formatted_time

Expand Down