vinhnx90 commited on
Commit
ffc1b97
β€’
1 Parent(s): 1612952

Update app

Browse files
Files changed (1) hide show
  1. app.py +27 -21
app.py CHANGED
@@ -113,7 +113,7 @@ def main():
113
 
114
  def build_sidebar():
115
  with st.sidebar:
116
- st.title("πŸ“š InkChatGPT")
117
 
118
  openai_api_key = st.text_input(
119
  "OpenAI API Key",
@@ -122,26 +122,32 @@ def build_sidebar():
122
  )
123
  st.session_state.api_key = openai_api_key
124
 
125
- uploaded_file = st.file_uploader(
126
- "Select a file", type=["pdf", "docx", "txt"], key="file_uploader"
127
- )
128
-
129
- add_file = st.button(
130
- "Process File",
131
- disabled=(not uploaded_file and not st.session_state.api_key),
132
- )
133
- if add_file and uploaded_file and st.session_state.api_key.startswith("sk-"):
134
- with st.spinner("πŸ’­ Thinking..."):
135
- vector_store = load_and_process_file(uploaded_file)
136
-
137
- if vector_store:
138
- msgs.add_ai_message(
139
- f"""
140
- File: `{uploaded_file.name}`, processed successfully!
141
-
142
- Feel free to ask me any question.
143
- """
144
- )
 
 
 
 
 
 
145
 
146
 
147
  if __name__ == "__main__":
 
113
 
114
  def build_sidebar():
115
  with st.sidebar:
116
+ st.subheader("πŸ“š InkChatGPT")
117
 
118
  openai_api_key = st.text_input(
119
  "OpenAI API Key",
 
122
  )
123
  st.session_state.api_key = openai_api_key
124
 
125
+ with st.form("my_form"):
126
+
127
+ uploaded_file = st.file_uploader(
128
+ "Select a file", type=["pdf", "docx", "txt"], key="file_uploader"
129
+ )
130
+
131
+ add_file = st.form_submit_button(
132
+ "Process File",
133
+ disabled=(not uploaded_file and not openai_api_key),
134
+ )
135
+ if (
136
+ add_file
137
+ and uploaded_file
138
+ and st.session_state.api_key.startswith("sk-")
139
+ ):
140
+ with st.spinner("πŸ’­ Thinking..."):
141
+ vector_store = load_and_process_file(uploaded_file)
142
+
143
+ if vector_store:
144
+ msgs.add_ai_message(
145
+ f"""
146
+ File: `{uploaded_file.name}`, processed successfully!
147
+
148
+ Feel free to ask me any question.
149
+ """
150
+ )
151
 
152
 
153
  if __name__ == "__main__":