Skip to content

Commit

Permalink
bump FastAPI version
Browse files Browse the repository at this point in the history
  • Loading branch information
pieroit committed Apr 24, 2024
1 parent 906eaef commit fb53cfd
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 3 deletions.
7 changes: 5 additions & 2 deletions core/cat/routes/upload.py
Original file line number Diff line number Diff line change
@@ -1,6 +1,7 @@
import mimetypes
import requests
from typing import Dict
from copy import deepcopy

from fastapi import Body, Depends, Request, APIRouter, UploadFile, BackgroundTasks, HTTPException

Expand Down Expand Up @@ -44,7 +45,9 @@ async def upload_file(

# upload file to long term memory, in the background
background_tasks.add_task(
stray.rabbit_hole.ingest_file, stray, file, chunk_size, chunk_overlap
# we deepcopy the file because FastAPI does not keep the file in memory after the response returns to the client
# https://github.com/tiangolo/fastapi/discussions/10936
stray.rabbit_hole.ingest_file, stray, deepcopy(file), chunk_size, chunk_overlap
)

# reply to client
Expand Down Expand Up @@ -127,7 +130,7 @@ async def upload_memory(
})

# Ingest memories in background and notify client
background_tasks.add_task(stray.rabbit_hole.ingest_memory, stray, file)
background_tasks.add_task(stray.rabbit_hole.ingest_memory, stray, deepcopy(file))

# reply to client
return {
Expand Down
2 changes: 1 addition & 1 deletion core/pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -10,7 +10,7 @@ authors = [
dependencies = [
"python-multipart==0.0.6",
"pydantic==2.4.2",
"fastapi==0.103.2",
"fastapi==0.110.2",
"websockets==10.4",
"pandas==1.5.3",
"scikit-learn==1.2.1",
Expand Down

0 comments on commit fb53cfd

Please sign in to comment.