Update BrainBot.py
Browse files- BrainBot.py +3 -3
BrainBot.py
CHANGED
@@ -18,7 +18,7 @@ def save_uploaded_file(uploaded_file):
|
|
18 |
|
19 |
# Create a directory if it doesn't exist
|
20 |
data_dir = "/data"
|
21 |
-
os.makedirs(data_dir, exist_ok=True)
|
22 |
|
23 |
# Create a temporary file in the data directory
|
24 |
with tempfile.NamedTemporaryFile(delete=False, dir=data_dir) as temp_file:
|
@@ -30,7 +30,7 @@ def save_uploaded_file(uploaded_file):
|
|
30 |
def save_uploaded_image(uploaded_image):
|
31 |
# Create a directory named "images" if it doesn't exist
|
32 |
images_dir = "/images"
|
33 |
-
os.makedirs(images_dir, exist_ok=True)
|
34 |
|
35 |
# Create a temporary file path within the "images" directory with .png extension
|
36 |
temp_file_path = os.path.join(images_dir, tempfile.NamedTemporaryFile(suffix=".png").name)
|
@@ -126,12 +126,12 @@ if uploaded_file is not None:
|
|
126 |
with st.spinner("Loading file..."):
|
127 |
# Save the uploaded file to a temporary path
|
128 |
temp_file_path = save_uploaded_file(uploaded_file)
|
|
|
129 |
|
130 |
try:
|
131 |
# Send POST request to a FastAPI endpoint to load the file into a vectorstore
|
132 |
data = {"file_path": temp_file_path, "file_type": uploaded_file.type}
|
133 |
FASTAPI_URL = f"http://localhost:7860/load_file/{llm}"
|
134 |
-
st.write(FASTAPI_URL)
|
135 |
response = requests.post(FASTAPI_URL, json=data)
|
136 |
st.success(response.text)
|
137 |
st.session_state['current_file'] = uploaded_file.name
|
|
|
18 |
|
19 |
# Create a directory if it doesn't exist
|
20 |
data_dir = "/data"
|
21 |
+
# os.makedirs(data_dir, exist_ok=True)
|
22 |
|
23 |
# Create a temporary file in the data directory
|
24 |
with tempfile.NamedTemporaryFile(delete=False, dir=data_dir) as temp_file:
|
|
|
30 |
def save_uploaded_image(uploaded_image):
|
31 |
# Create a directory named "images" if it doesn't exist
|
32 |
images_dir = "/images"
|
33 |
+
# os.makedirs(images_dir, exist_ok=True)
|
34 |
|
35 |
# Create a temporary file path within the "images" directory with .png extension
|
36 |
temp_file_path = os.path.join(images_dir, tempfile.NamedTemporaryFile(suffix=".png").name)
|
|
|
126 |
with st.spinner("Loading file..."):
|
127 |
# Save the uploaded file to a temporary path
|
128 |
temp_file_path = save_uploaded_file(uploaded_file)
|
129 |
+
st.write(temp_file_path)
|
130 |
|
131 |
try:
|
132 |
# Send POST request to a FastAPI endpoint to load the file into a vectorstore
|
133 |
data = {"file_path": temp_file_path, "file_type": uploaded_file.type}
|
134 |
FASTAPI_URL = f"http://localhost:7860/load_file/{llm}"
|
|
|
135 |
response = requests.post(FASTAPI_URL, json=data)
|
136 |
st.success(response.text)
|
137 |
st.session_state['current_file'] = uploaded_file.name
|