eagle0504 commited on
Commit
3b77f3a
1 Parent(s): 3db05f5

add submit button

Browse files
Files changed (1) hide show
  1. app.py +36 -33
app.py CHANGED
@@ -58,6 +58,9 @@ with st.sidebar:
58
  "Upload documents", accept_multiple_files=True, type=["txt", "pdf"]
59
  )
60
 
 
 
 
61
  # Input filter
62
  top_n = st.number_input(
63
  "Insert a number (top n rows to be selected):", value=5, step=1
@@ -66,9 +69,11 @@ with st.sidebar:
66
  # Use dictionary
67
  use_dict_format = st.checkbox("Use dictionary format.")
68
 
 
 
 
69
  # Clear button
70
  clear_button = st.sidebar.button("Clear Conversation", key="clear")
71
-
72
  # Credit
73
  current_year = current_year() # This will print the current year
74
  st.markdown(
@@ -102,38 +107,36 @@ if uploaded_files is None:
102
 
103
 
104
  elif uploaded_files:
105
- # Inform the user how many documents have been loaded
106
- st.sidebar.success(f"{len(uploaded_files)} document(s) loaded...")
107
-
108
- # Process the uploaded files to extract text and source information
109
- textify_output = read_and_textify(uploaded_files)
110
 
111
- # Separate the output into documents (text) and their corresponding sources
112
- documents, sources = textify_output
113
 
114
- # Call the function
115
- query_database = list_to_nums(documents)
116
 
117
- # Create reference table
118
- refs_tab = query_search(
119
- "pful for understanding federal income", documents, query_database, sources
120
- )
121
- refs_tab.head(math.ceil(top_n))
122
-
123
- # React to user input
124
- if prompt := st.chat_input("What is up?"):
125
- # Display user message in chat message container
126
- st.chat_message("user").markdown(prompt)
127
- # Add user message to chat history
128
- st.session_state.messages.append({"role": "user", "content": prompt})
129
-
130
- result = refs_tab
131
-
132
- # Display assistant response in chat message container
133
- with st.chat_message("assistant"):
134
- if not use_dict_format:
135
- st.table(result)
136
- else:
137
- st.write(result.to_json())
138
- # Add assistant response to chat history
139
- st.session_state.messages.append({"role": "assistant", "content": result})
 
58
  "Upload documents", accept_multiple_files=True, type=["txt", "pdf"]
59
  )
60
 
61
+ # Inform the user how many documents have been loaded
62
+ st.success(f"{len(uploaded_files)} document(s) loaded...")
63
+
64
  # Input filter
65
  top_n = st.number_input(
66
  "Insert a number (top n rows to be selected):", value=5, step=1
 
69
  # Use dictionary
70
  use_dict_format = st.checkbox("Use dictionary format.")
71
 
72
+ # Submit button
73
+ submit_it = st.sidebar.button("Submit", type="primary")
74
+
75
  # Clear button
76
  clear_button = st.sidebar.button("Clear Conversation", key="clear")
 
77
  # Credit
78
  current_year = current_year() # This will print the current year
79
  st.markdown(
 
107
 
108
 
109
  elif uploaded_files:
110
+ if submit_it:
111
+ # Process the uploaded files to extract text and source information
112
+ textify_output = read_and_textify(uploaded_files)
 
 
113
 
114
+ # Separate the output into documents (text) and their corresponding sources
115
+ documents, sources = textify_output
116
 
117
+ # Call the function
118
+ query_database = list_to_nums(documents)
119
 
120
+ # Create reference table
121
+ refs_tab = query_search(
122
+ "pful for understanding federal income", documents, query_database, sources
123
+ )
124
+ refs_tab.head(math.ceil(top_n))
125
+
126
+ # React to user input
127
+ if prompt := st.chat_input("What is up?"):
128
+ # Display user message in chat message container
129
+ st.chat_message("user").markdown(prompt)
130
+ # Add user message to chat history
131
+ st.session_state.messages.append({"role": "user", "content": prompt})
132
+
133
+ result = refs_tab
134
+
135
+ # Display assistant response in chat message container
136
+ with st.chat_message("assistant"):
137
+ if not use_dict_format:
138
+ st.table(result)
139
+ else:
140
+ st.write(result.to_json())
141
+ # Add assistant response to chat history
142
+ st.session_state.messages.append({"role": "assistant", "content": result})