Spaces:
Sleeping
Sleeping
Refactor app
Browse files
app.py
CHANGED
@@ -138,17 +138,6 @@ def clear_history():
|
|
138 |
del st.session_state["history"]
|
139 |
|
140 |
|
141 |
-
def process_data(uploaded_file, openai_api_key):
|
142 |
-
if uploaded_file and openai_api_key.startswith("sk-"):
|
143 |
-
with st.spinner("π Thinking..."):
|
144 |
-
vector_store = load_and_process_file(uploaded_file)
|
145 |
-
|
146 |
-
if vector_store:
|
147 |
-
crc = initialize_chat_model(vector_store)
|
148 |
-
st.session_state.crc = crc
|
149 |
-
st.success(f"File: `{uploaded_file.name}`, processed successfully!")
|
150 |
-
|
151 |
-
|
152 |
def build_sidebar():
|
153 |
with st.sidebar:
|
154 |
st.title("π InkChatGPT")
|
@@ -168,12 +157,17 @@ def build_sidebar():
|
|
168 |
"Select a file", type=["pdf", "docx", "txt"], key="file_uploader"
|
169 |
)
|
170 |
|
171 |
-
st.form_submit_button(
|
172 |
-
|
173 |
-
|
174 |
-
|
175 |
-
|
176 |
-
|
|
|
|
|
|
|
|
|
|
|
177 |
|
178 |
|
179 |
if __name__ == "__main__":
|
|
|
138 |
del st.session_state["history"]
|
139 |
|
140 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
141 |
def build_sidebar():
|
142 |
with st.sidebar:
|
143 |
st.title("π InkChatGPT")
|
|
|
157 |
"Select a file", type=["pdf", "docx", "txt"], key="file_uploader"
|
158 |
)
|
159 |
|
160 |
+
add_file = st.form_submit_button("Process File")
|
161 |
+
if add_file and uploaded_file and openai_api_key.startswith("sk-"):
|
162 |
+
with st.spinner("π Thinking..."):
|
163 |
+
vector_store = load_and_process_file(uploaded_file)
|
164 |
+
|
165 |
+
if vector_store:
|
166 |
+
crc = initialize_chat_model(vector_store)
|
167 |
+
st.session_state.crc = crc
|
168 |
+
st.success(
|
169 |
+
f"File: `{uploaded_file.name}`, processed successfully!"
|
170 |
+
)
|
171 |
|
172 |
|
173 |
if __name__ == "__main__":
|