Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Create different file store object for different users. #29

Open
CakeCrusher opened this issue May 9, 2024 · 0 comments
Open

Create different file store object for different users. #29

CakeCrusher opened this issue May 9, 2024 · 0 comments

Comments

@CakeCrusher
Copy link
Contributor

Entry point to address this issue:

@router.post("/files", response_model=FileObject)
async def create_file(
    file: UploadFile = File(...),
    purpose: Literal["fine-tune", "assistants"] = File(...),
    db: Session = Depends(get_db),
    minio_client: Minio = Depends(minio_client),
):
    if purpose not in ["fine-tune", "assistants"]:
        raise HTTPException(status_code=400, detail="Invalid purpose")

    # Ensure file data is read before any operation that might exhaust the stream
    file_data_bytes = await file.read()

    # Check if file data is empty
    if not file_data_bytes:
        raise HTTPException(status_code=400, detail="File is empty")

    uploaded_file = actions.upload_file(
        minio_client=minio_client, bucket_name=BUCKET_NAME, file=file
    )

    crud.create_file(db=db, file=uploaded_file)

    # # File data is passed here after ensuring it's not empty
    # wv_actions.upload_file_chunks(
    #     file_data=file_data_bytes,
    #     file_name=file.filename,
    #     file_id=uploaded_file.id,
    # )

    return uploaded_file
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant