Spaces:
Sleeping
Sleeping
Update app
Browse files
app.py
CHANGED
@@ -113,7 +113,7 @@ def main():
|
|
113 |
|
114 |
def build_sidebar():
|
115 |
with st.sidebar:
|
116 |
-
st.
|
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 |
-
|
126 |
-
|
127 |
-
|
128 |
-
|
129 |
-
|
130 |
-
|
131 |
-
|
132 |
-
|
133 |
-
|
134 |
-
|
135 |
-
|
136 |
-
|
137 |
-
|
138 |
-
|
139 |
-
|
140 |
-
|
141 |
-
|
142 |
-
|
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__":
|