Skip to content
This repository was archived by the owner on Feb 24, 2026. It is now read-only.

[Do Not Merge] Use compression in file transfer#90

Closed
Lance Martin (rlancemartin) wants to merge 1 commit into
mainfrom
zip_files_transfer
Closed

[Do Not Merge] Use compression in file transfer#90
Lance Martin (rlancemartin) wants to merge 1 commit into
mainfrom
zip_files_transfer

Conversation

@rlancemartin

@rlancemartin Lance Martin (rlancemartin) commented May 2, 2023

Copy link
Copy Markdown
Contributor

Compress files on the client prior to transfer to server.

Odd / unhelpful error b/c I can't see where specifically it is getting thrown by the server.

Logging suggests that it's never getting to here:

logger.info("*** Run Evaluator ***")
return EventSourceResponse(...)

Possible problem with the files files: List[bytes] = File(...),:

async def create_response(
    files: List[bytes] = File(...),
    num_eval_questions: int = Form(5),
    chunk_chars: int = Form(1000),
    overlap: int = Form(100),
    split_method: str = Form("RecursiveTextSplitter"),
    retriever_type: str = Form("similarity-search"),
    embeddings: str = Form("OpenAI"),
    model_version: str = Form("gpt-3.5-turbo"),
    grade_prompt: str = Form("Fast"),
    num_neighbors: int = Form(3),
    test_dataset: str = Form("[]"),
):

Trace:

  File "/Users/31treehaus/opt/anaconda3/envs/ml/lib/python3.9/site-packages/starlette/routing.py", line 680, in __call__
    await route.handle(scope, receive, send)
  File "/Users/31treehaus/opt/anaconda3/envs/ml/lib/python3.9/site-packages/starlette/routing.py", line 275, in handle
    await self.app(scope, receive, send)
  File "/Users/31treehaus/opt/anaconda3/envs/ml/lib/python3.9/site-packages/starlette/routing.py", line 65, in app
    response = await func(request)
  File "/Users/31treehaus/opt/anaconda3/envs/ml/lib/python3.9/site-packages/fastapi/routing.py", line 221, in app
    solved_result = await solve_dependencies(
  File "/Users/31treehaus/opt/anaconda3/envs/ml/lib/python3.9/site-packages/fastapi/dependencies/utils.py", line 561, in solve_dependencies
    ) = await request_body_to_args(  # body_params checked above
  File "/Users/31treehaus/opt/anaconda3/envs/ml/lib/python3.9/site-packages/fastapi/dependencies/utils.py", line 693, in request_body_to_args
    tg.start_soon(process_fn, sub_value.read)
AttributeError: 'str' object has no attribute 'read'

Problem is with FastAPI's File class:

It expects an instance of the UploadFile class, which provides a read() method to access the contents of the file.

Interesting discussion here:
https://stackoverflow.com/questions/73442335/how-to-upload-a-large-file-%E2%89%A53gb-to-fastapi-backend

@vercel

vercel Bot commented May 2, 2023

Copy link
Copy Markdown

The latest updates on your projects. Learn more about Vercel for Git ↗︎

Name Status Preview Updated (UTC)
auto-evaluator ✅ Ready (Inspect) Visit Preview May 2, 2023 8:38pm

@rlancemartin Lance Martin (rlancemartin) changed the title Use compression in file transfer [Do Not Merge] Use compression in file transfer May 2, 2023
@rainso9988

Copy link
Copy Markdown

I discovered a security vulnerability in your code. Please take a look and let's address it together.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

bug Something isn't working

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants