Skip to content

Commit 64d2a2c

Browse files
authored
Merge pull request #56 from aws-samples/wangzt
code rework for page 1
2 parents cb7d1ee + da479c5 commit 64d2a2c

10 files changed

+275
-257
lines changed

application/pages/1_🌍_Generative_BI_Playground.py

Lines changed: 180 additions & 177 deletions
Large diffs are not rendered by default.

application/pages/4_🪙_Schema_Description_Management.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -70,7 +70,8 @@ def main():
7070
origin_table_info['col_a'] = col_annotation
7171
ProfileManagement.update_table_def(current_profile, origin_tables_info)
7272
st.success('saved.')
73-
73+
else:
74+
st.info('Please select data profile in the left sidebar.')
7475

7576
if __name__ == '__main__':
7677
main()

application/pages/5_🪙_Prompt_Management.py

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -39,6 +39,8 @@ def main():
3939
# save new profile to DynamoDB
4040
ProfileManagement.update_table_prompt(current_profile, system_prompt, user_prompt)
4141
st.success('saved.')
42+
else:
43+
st.info('Please select data profile in the left sidebar.')
4244

4345

4446
if __name__ == '__main__':

application/pages/6_📚_Index_Management.py

Lines changed: 26 additions & 23 deletions
Original file line numberDiff line numberDiff line change
@@ -32,30 +32,33 @@ def main():
3232

3333
tab_view, tab_add = st.tabs(['View Samples', 'Add New Sample'])
3434

35-
with tab_view:
36-
if current_profile is not None:
37-
for sample in VectorStore.get_all_samples(current_profile):
38-
# st.write(f"Sample: {sample}")
39-
with st.expander(sample['text']):
40-
st.code(sample['sql'])
41-
st.button('Delete ' + sample['id'], on_click=delete_sample, args=[current_profile, sample['id']])
42-
43-
with tab_add:
44-
if current_profile is not None:
45-
question = st.text_input('Question', key='index_question')
46-
answer = st.text_area('Answer(SQL)', key='index_answer', height=300)
47-
48-
if st.button('Submit', type='primary'):
49-
if len(question) > 0 and len(answer) > 0:
50-
VectorStore.add_sample(current_profile, question, answer)
51-
st.success('Sample added')
52-
time.sleep(2)
53-
# del st.session_state['index_question']
54-
# del st.session_state['index_answer']
55-
st.rerun()
56-
else:
57-
st.error('please input valid question and answer')
35+
if current_profile is not None:
36+
with tab_view:
37+
if current_profile is not None:
38+
for sample in VectorStore.get_all_samples(current_profile):
39+
# st.write(f"Sample: {sample}")
40+
with st.expander(sample['text']):
41+
st.code(sample['sql'])
42+
st.button('Delete ' + sample['id'], on_click=delete_sample, args=[current_profile, sample['id']])
5843

44+
with tab_add:
45+
if current_profile is not None:
46+
question = st.text_input('Question', key='index_question')
47+
answer = st.text_area('Answer(SQL)', key='index_answer', height=300)
48+
49+
if st.button('Submit', type='primary'):
50+
if len(question) > 0 and len(answer) > 0:
51+
VectorStore.add_sample(current_profile, question, answer)
52+
st.success('Sample added')
53+
time.sleep(2)
54+
# del st.session_state['index_question']
55+
# del st.session_state['index_answer']
56+
st.rerun()
57+
else:
58+
st.error('please input valid question and answer')
59+
else:
60+
st.info('Please select data profile in the left sidebar.')
61+
5962

6063
if __name__ == '__main__':
6164
main()

application/pages/7_📚_Entity_Management.py

Lines changed: 26 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -30,30 +30,32 @@ def main():
3030
placeholder="Please select data profile...", key='current_profile_name')
3131

3232
tab_view, tab_add = st.tabs(['View Samples', 'Add New Sample'])
33-
34-
with tab_view:
35-
if current_profile is not None:
36-
for sample in VectorStore.get_all_entity_samples(current_profile):
37-
# st.write(f"Sample: {sample}")
38-
with st.expander(sample['entity']):
39-
st.code(sample['comment'])
40-
st.button('Delete ' + sample['id'], on_click=delete_entity_sample, args=[current_profile, sample['id']])
41-
42-
with tab_add:
43-
if current_profile is not None:
44-
entity = st.text_input('Entity', key='index_question')
45-
comment = st.text_area('Comment', key='index_answer', height=300)
46-
47-
if st.button('Submit', type='primary'):
48-
if len(entity) > 0 and len(comment) > 0:
49-
VectorStore.add_entity_sample(current_profile, entity, comment)
50-
st.success('Sample added')
51-
time.sleep(2)
52-
# del st.session_state['index_question']
53-
# del st.session_state['index_answer']
54-
st.rerun()
55-
else:
56-
st.error('please input valid question and answer')
33+
if current_profile is not None:
34+
with tab_view:
35+
if current_profile is not None:
36+
for sample in VectorStore.get_all_entity_samples(current_profile):
37+
# st.write(f"Sample: {sample}")
38+
with st.expander(sample['entity']):
39+
st.code(sample['comment'])
40+
st.button('Delete ' + sample['id'], on_click=delete_entity_sample, args=[current_profile, sample['id']])
41+
42+
with tab_add:
43+
if current_profile is not None:
44+
entity = st.text_input('Entity', key='index_question')
45+
comment = st.text_area('Comment', key='index_answer', height=300)
46+
47+
if st.button('Submit', type='primary'):
48+
if len(entity) > 0 and len(comment) > 0:
49+
VectorStore.add_entity_sample(current_profile, entity, comment)
50+
st.success('Sample added')
51+
time.sleep(2)
52+
# del st.session_state['index_question']
53+
# del st.session_state['index_answer']
54+
st.rerun()
55+
else:
56+
st.error('please input valid question and answer')
57+
else:
58+
st.info('Please select data profile in the left sidebar.')
5759

5860

5961
if __name__ == '__main__':

application/pages/8_📚_Agent_Cot_Management.py

Lines changed: 26 additions & 25 deletions
Original file line numberDiff line numberDiff line change
@@ -30,31 +30,32 @@ def main():
3030
placeholder="Please select data profile...", key='current_profile_name')
3131

3232
tab_view, tab_add = st.tabs(['View Samples', 'Add New Sample'])
33-
34-
with tab_view:
35-
if current_profile is not None:
36-
for sample in VectorStore.get_all_agent_cot_samples(current_profile):
37-
# st.write(f"Sample: {sample}")
38-
with st.expander(sample['query']):
39-
st.code(sample['comment'])
40-
st.button('Delete ' + sample['id'], on_click=delete_entity_sample, args=[current_profile, sample['id']])
41-
42-
with tab_add:
43-
if current_profile is not None:
44-
query = st.text_input('Query', key='index_question')
45-
comment = st.text_area('Comment', key='index_answer', height=300)
46-
47-
if st.button('Submit', type='primary'):
48-
if len(query) > 0 and len(comment) > 0:
49-
VectorStore.add_agent_cot_sample(current_profile, query, comment)
50-
st.success('Sample added')
51-
time.sleep(2)
52-
# del st.session_state['index_question']
53-
# del st.session_state['index_answer']
54-
st.rerun()
55-
else:
56-
st.error('please input valid question and answer')
57-
33+
if current_profile is not None:
34+
with tab_view:
35+
if current_profile is not None:
36+
for sample in VectorStore.get_all_agent_cot_samples(current_profile):
37+
# st.write(f"Sample: {sample}")
38+
with st.expander(sample['query']):
39+
st.code(sample['comment'])
40+
st.button('Delete ' + sample['id'], on_click=delete_entity_sample, args=[current_profile, sample['id']])
41+
42+
with tab_add:
43+
if current_profile is not None:
44+
query = st.text_input('Query', key='index_question')
45+
comment = st.text_area('Comment', key='index_answer', height=300)
46+
47+
if st.button('Submit', type='primary'):
48+
if len(query) > 0 and len(comment) > 0:
49+
VectorStore.add_agent_cot_sample(current_profile, query, comment)
50+
st.success('Sample added')
51+
time.sleep(2)
52+
# del st.session_state['index_question']
53+
# del st.session_state['index_answer']
54+
st.rerun()
55+
else:
56+
st.error('please input valid question and answer')
57+
else:
58+
st.info('Please select data profile in the left sidebar.')
5859

5960
if __name__ == '__main__':
6061
main()

application/pages/mainpage.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,13 +2,13 @@
22
from utils.navigation import make_sidebar
33

44
st.set_page_config(
5-
page_title="Intelligent BI",
5+
page_title="Generative BI",
66
page_icon="👋",
77
)
88

99
make_sidebar()
1010

11-
st.write("## Welcome to Intelligent BI Playground!👋")
11+
st.write("## Welcome to Generative BI Playground!👋")
1212

1313
st.sidebar.success("Select a demo above.")
1414

application/utils/llm.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -463,7 +463,8 @@ def knowledge_search(model_id, search_box):
463463
messages = [user_message]
464464
logger.info(f'{system_prompt=}')
465465
logger.info(f'{messages=}')
466-
response = invoke_model_claude3(model_id, system_prompt, messages, max_tokens)
466+
467+
response = invoke_llm_model(model_id, system_prompt, user_prompt, max_tokens, with_response_stream=False)
467468
final_response = response.get("content")[0].get("text")
468469
return final_response
469470
except Exception as e:

application/utils/navigation.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -35,16 +35,16 @@ def make_sidebar():
3535
if st.session_state.get('authentication_status'):
3636
st.page_link("pages/mainpage.py", label="Index")
3737
st.page_link("pages/1_🌍_Generative_BI_Playground.py", label="Generative BI Playground", icon="🌍")
38-
st.markdown(":gray[Data Customization Management]")
38+
st.markdown(":gray[Data Customization Management]", help='Add your own datasources and customize description for LLM to better understand them')
3939
st.page_link("pages/2_🪙_Data_Connection_Management.py", label="Data Connection Management", icon="🪙")
4040
st.page_link("pages/3_🪙_Data_Profile_Management.py", label="Data Profile Management", icon="🪙")
4141
st.page_link("pages/4_🪙_Schema_Description_Management.py", label="Schema Description Management", icon="🪙")
4242
st.page_link("pages/5_🪙_Prompt_Management.py", label="Prompt Management", icon="🪙")
43-
st.markdown(":gray[Performance Enhancement]")
43+
st.markdown(":gray[Performance Enhancement]", help='Optimize your LLM for better performance by adding RAG or agent')
4444
st.page_link("pages/6_📚_Index_Management.py", label="Index Management", icon="📚")
4545
st.page_link("pages/7_📚_Entity_Management.py", label="Entity Management", icon="📚")
4646
st.page_link("pages/8_📚_Agent_Cot_Management.py", label="Agent Cot Management", icon="📚")
47-
st.markdown(":gray[Dashboard Customization Management]")
47+
st.markdown(":gray[Dashboard Customization Management]", help='Customize your dashboard for better visualization')
4848
st.page_link("pages/9_🖥_Suggested_Question_Management.py", label="Suggested Question Management",
4949
icon="🖥")
5050

application/utils/prompt.py

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -62,13 +62,18 @@
6262
{
6363
"intent" : "agent_search"
6464
}
65-
</example>
6665
6766
question : 希尔顿的英文名是什么
6867
answer :
6968
{
7069
"intent" : "knowledge_search"
7170
}
71+
72+
question : What does MTD mean?
73+
answer :
74+
{
75+
"intent" : "knowledge_search"
76+
}
7277
</example>
7378
7479
Please perform intent recognition and entity extraction. Return only the JSON structure, without any other annotations.

0 commit comments

Comments
 (0)