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
357 changes: 180 additions & 177 deletions application/pages/1_🌍_Generative_BI_Playground.py

Large diffs are not rendered by default.

3 changes: 2 additions & 1 deletion application/pages/4_🪙_Schema_Description_Management.py
Original file line number Diff line number Diff line change
Expand Up @@ -70,7 +70,8 @@ def main():
origin_table_info['col_a'] = col_annotation
ProfileManagement.update_table_def(current_profile, origin_tables_info)
st.success('saved.')

else:
st.info('Please select data profile in the left sidebar.')

if __name__ == '__main__':
main()
2 changes: 2 additions & 0 deletions application/pages/5_🪙_Prompt_Management.py
Original file line number Diff line number Diff line change
Expand Up @@ -39,6 +39,8 @@ def main():
# save new profile to DynamoDB
ProfileManagement.update_table_prompt(current_profile, system_prompt, user_prompt)
st.success('saved.')
else:
st.info('Please select data profile in the left sidebar.')


if __name__ == '__main__':
Expand Down
49 changes: 26 additions & 23 deletions application/pages/6_📚_Index_Management.py
Original file line number Diff line number Diff line change
Expand Up @@ -32,30 +32,33 @@ def main():

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

with tab_view:
if current_profile is not None:
for sample in VectorStore.get_all_samples(current_profile):
# st.write(f"Sample: {sample}")
with st.expander(sample['text']):
st.code(sample['sql'])
st.button('Delete ' + sample['id'], on_click=delete_sample, args=[current_profile, sample['id']])

with tab_add:
if current_profile is not None:
question = st.text_input('Question', key='index_question')
answer = st.text_area('Answer(SQL)', key='index_answer', height=300)

if st.button('Submit', type='primary'):
if len(question) > 0 and len(answer) > 0:
VectorStore.add_sample(current_profile, question, answer)
st.success('Sample added')
time.sleep(2)
# del st.session_state['index_question']
# del st.session_state['index_answer']
st.rerun()
else:
st.error('please input valid question and answer')
if current_profile is not None:
with tab_view:
if current_profile is not None:
for sample in VectorStore.get_all_samples(current_profile):
# st.write(f"Sample: {sample}")
with st.expander(sample['text']):
st.code(sample['sql'])
st.button('Delete ' + sample['id'], on_click=delete_sample, args=[current_profile, sample['id']])

with tab_add:
if current_profile is not None:
question = st.text_input('Question', key='index_question')
answer = st.text_area('Answer(SQL)', key='index_answer', height=300)

if st.button('Submit', type='primary'):
if len(question) > 0 and len(answer) > 0:
VectorStore.add_sample(current_profile, question, answer)
st.success('Sample added')
time.sleep(2)
# del st.session_state['index_question']
# del st.session_state['index_answer']
st.rerun()
else:
st.error('please input valid question and answer')
else:
st.info('Please select data profile in the left sidebar.')


if __name__ == '__main__':
main()
50 changes: 26 additions & 24 deletions application/pages/7_📚_Entity_Management.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,30 +30,32 @@ def main():
placeholder="Please select data profile...", key='current_profile_name')

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

with tab_view:
if current_profile is not None:
for sample in VectorStore.get_all_entity_samples(current_profile):
# st.write(f"Sample: {sample}")
with st.expander(sample['entity']):
st.code(sample['comment'])
st.button('Delete ' + sample['id'], on_click=delete_entity_sample, args=[current_profile, sample['id']])

with tab_add:
if current_profile is not None:
entity = st.text_input('Entity', key='index_question')
comment = st.text_area('Comment', key='index_answer', height=300)

if st.button('Submit', type='primary'):
if len(entity) > 0 and len(comment) > 0:
VectorStore.add_entity_sample(current_profile, entity, comment)
st.success('Sample added')
time.sleep(2)
# del st.session_state['index_question']
# del st.session_state['index_answer']
st.rerun()
else:
st.error('please input valid question and answer')
if current_profile is not None:
with tab_view:
if current_profile is not None:
for sample in VectorStore.get_all_entity_samples(current_profile):
# st.write(f"Sample: {sample}")
with st.expander(sample['entity']):
st.code(sample['comment'])
st.button('Delete ' + sample['id'], on_click=delete_entity_sample, args=[current_profile, sample['id']])

with tab_add:
if current_profile is not None:
entity = st.text_input('Entity', key='index_question')
comment = st.text_area('Comment', key='index_answer', height=300)

if st.button('Submit', type='primary'):
if len(entity) > 0 and len(comment) > 0:
VectorStore.add_entity_sample(current_profile, entity, comment)
st.success('Sample added')
time.sleep(2)
# del st.session_state['index_question']
# del st.session_state['index_answer']
st.rerun()
else:
st.error('please input valid question and answer')
else:
st.info('Please select data profile in the left sidebar.')


if __name__ == '__main__':
Expand Down
51 changes: 26 additions & 25 deletions application/pages/8_📚_Agent_Cot_Management.py
Original file line number Diff line number Diff line change
Expand Up @@ -30,31 +30,32 @@ def main():
placeholder="Please select data profile...", key='current_profile_name')

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

with tab_view:
if current_profile is not None:
for sample in VectorStore.get_all_agent_cot_samples(current_profile):
# st.write(f"Sample: {sample}")
with st.expander(sample['query']):
st.code(sample['comment'])
st.button('Delete ' + sample['id'], on_click=delete_entity_sample, args=[current_profile, sample['id']])

with tab_add:
if current_profile is not None:
query = st.text_input('Query', key='index_question')
comment = st.text_area('Comment', key='index_answer', height=300)

if st.button('Submit', type='primary'):
if len(query) > 0 and len(comment) > 0:
VectorStore.add_agent_cot_sample(current_profile, query, comment)
st.success('Sample added')
time.sleep(2)
# del st.session_state['index_question']
# del st.session_state['index_answer']
st.rerun()
else:
st.error('please input valid question and answer')

if current_profile is not None:
with tab_view:
if current_profile is not None:
for sample in VectorStore.get_all_agent_cot_samples(current_profile):
# st.write(f"Sample: {sample}")
with st.expander(sample['query']):
st.code(sample['comment'])
st.button('Delete ' + sample['id'], on_click=delete_entity_sample, args=[current_profile, sample['id']])

with tab_add:
if current_profile is not None:
query = st.text_input('Query', key='index_question')
comment = st.text_area('Comment', key='index_answer', height=300)

if st.button('Submit', type='primary'):
if len(query) > 0 and len(comment) > 0:
VectorStore.add_agent_cot_sample(current_profile, query, comment)
st.success('Sample added')
time.sleep(2)
# del st.session_state['index_question']
# del st.session_state['index_answer']
st.rerun()
else:
st.error('please input valid question and answer')
else:
st.info('Please select data profile in the left sidebar.')

if __name__ == '__main__':
main()
4 changes: 2 additions & 2 deletions application/pages/mainpage.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,13 +2,13 @@
from utils.navigation import make_sidebar

st.set_page_config(
page_title="Intelligent BI",
page_title="Generative BI",
page_icon="👋",
)

make_sidebar()

st.write("## Welcome to Intelligent BI Playground!👋")
st.write("## Welcome to Generative BI Playground!👋")

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

Expand Down
3 changes: 2 additions & 1 deletion application/utils/llm.py
Original file line number Diff line number Diff line change
Expand Up @@ -463,7 +463,8 @@ def knowledge_search(model_id, search_box):
messages = [user_message]
logger.info(f'{system_prompt=}')
logger.info(f'{messages=}')
response = invoke_model_claude3(model_id, system_prompt, messages, max_tokens)

response = invoke_llm_model(model_id, system_prompt, user_prompt, max_tokens, with_response_stream=False)
final_response = response.get("content")[0].get("text")
return final_response
except Exception as e:
Expand Down
6 changes: 3 additions & 3 deletions application/utils/navigation.py
Original file line number Diff line number Diff line change
Expand Up @@ -35,16 +35,16 @@ def make_sidebar():
if st.session_state.get('authentication_status'):
st.page_link("pages/mainpage.py", label="Index")
st.page_link("pages/1_🌍_Generative_BI_Playground.py", label="Generative BI Playground", icon="🌍")
st.markdown(":gray[Data Customization Management]")
st.markdown(":gray[Data Customization Management]", help='Add your own datasources and customize description for LLM to better understand them')
st.page_link("pages/2_🪙_Data_Connection_Management.py", label="Data Connection Management", icon="🪙")
st.page_link("pages/3_🪙_Data_Profile_Management.py", label="Data Profile Management", icon="🪙")
st.page_link("pages/4_🪙_Schema_Description_Management.py", label="Schema Description Management", icon="🪙")
st.page_link("pages/5_🪙_Prompt_Management.py", label="Prompt Management", icon="🪙")
st.markdown(":gray[Performance Enhancement]")
st.markdown(":gray[Performance Enhancement]", help='Optimize your LLM for better performance by adding RAG or agent')
st.page_link("pages/6_📚_Index_Management.py", label="Index Management", icon="📚")
st.page_link("pages/7_📚_Entity_Management.py", label="Entity Management", icon="📚")
st.page_link("pages/8_📚_Agent_Cot_Management.py", label="Agent Cot Management", icon="📚")
st.markdown(":gray[Dashboard Customization Management]")
st.markdown(":gray[Dashboard Customization Management]", help='Customize your dashboard for better visualization')
st.page_link("pages/9_🖥_Suggested_Question_Management.py", label="Suggested Question Management",
icon="🖥")

Expand Down
7 changes: 6 additions & 1 deletion application/utils/prompt.py
Original file line number Diff line number Diff line change
Expand Up @@ -62,13 +62,18 @@
{
"intent" : "agent_search"
}
</example>

question : 希尔顿的英文名是什么
answer :
{
"intent" : "knowledge_search"
}

question : What does MTD mean?
answer :
{
"intent" : "knowledge_search"
}
</example>

Please perform intent recognition and entity extraction. Return only the JSON structure, without any other annotations.
Expand Down